php - Ajax to retrieve data from mySQL database and create a table -


hello guys , sorry if double post.

i have created database contains 4 values flid, depid, arrid, distance. managed use ajax method display data of 1 of rows of database:

<?php      if( isset($_post['depid']) === true && empty($_post['depid']) ===false){         require'../db/connect.php';         $query = mysql_query("             select `flights`.`flid`,`flights`.`depid`,`flights`.`arrid`,`flights`.`distance`             `flights`              `flights`.`depid` ='".mysql_real_escape_string(trim($_post['depid'])) ."'");           echo(mysql_num_rows($query)!== 0) ? mysql_result($query, 0, 'flid') : 'departure airport not found ';         echo(mysql_num_rows($query)!== 0) ? mysql_result($query, 0, 'depid') : 'departure airport not found ';                                echo(mysql_num_rows($query)!== 0) ? mysql_result($query, 0, 'arrid') : 'departure airport not found ';                                echo(mysql_num_rows($query)!== 0) ? mysql_result($query, 0, 'distance') : 'departure airport not found ';                                                         } ?> 

my question how make code retrieve of rows in database has same depid , how add results table.

i have created following code in attempt solve problem , have reached point:

<?php  if( isset($_post['depid']) === true && empty($_post['depid']) ===false){     require'../db/connect.php';     $query = mysql_query("select * flights depid ='depid'");                               $result = mysql_query($mysql_connect,$query) or die ("error");                            echo "<table><tr><th>flight id</th><th>departure airport</th><th>arrival airport</th><th>distance</th></tr>";      while($row = mysql_fetch_array($result)) {         echo "<tr><td>" . $row['flid'] . "</td><td>" . $row['depid'] . "</td><td>" . $row['arrid'] . "</td><td>" . $row['distance'] . "</td></tr>";     }     echo "</table>";                              } 

now have problem code fails message:

warning: mysql_query() expects parameter 2 resource, boolean given in /home/ak118043/public_html/ajax/name.php on line 9 in advance.

use ajax data retrieve example data fetch

$.ajax({ type: "post", url: "someurl.php", datatype: "json", success: function(data) { echo "<table> example demo </table>";  }  }); } }); 

Comments

Popular posts from this blog

asp.net mvc - SSO between MVCForum and Umbraco7 -

Python Tkinter keyboard using bind -

ubuntu - Selenium Node Not Connecting to Hub, Not Opening Port -