When i try to run this script i get an error (You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1) include'mysql.php'; $result = mysql_query("SELECT * FROM cat_gambling")or die(mysql_error()); $id = $row['id']; while($row = mysql_fetch_array( $result )) { $result2 = mysql_query("SELECT * FROM listings WHERE id = $id")or die(mysql_error()); while($row2 = mysql_fetch_array( $result2 )) { echo $row['site']; };}; Can anyone help me find a way to fix it please ?
the purpose of the script is to get all id's (int) from table cat_gambling Then use the id's to grab information from the listings table eventually i will display the info in seperate tables using (while) function
Fixed it myself using tizag.com // Get all the data from the "example" table $result = mysql_query("SELECT * FROM cat_gambling")or die(mysql_error()); // keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { $id = $row['poker']; $result2 = mysql_query("SELECT * FROM listings WHERE id = $id")or die(mysql_error()); $row2 = mysql_fetch_array($result2) or die(mysql_error()); echo $row2['site']; };