hi there! i'm a newbie on php and i would like to ask on how to display the sql output correctly. It involves 2 php files and the codes are posted below. display.php echo "<a href=view_post.php?xval="; echo $row["incval"]; echo ">"; echo $row["item_title"]; echo "</a>"; view_post.php $result = mysql_query("select * from classified_postings where category ='xval'") or die (mysql_error()); while ($row = mysql_fetch_array($result)) { echo $row["date"]; echo "<br>"; echo $row["category"]; echo "<br>"; echo "<a href=view_post.php?xval="; echo $row["incval"]; echo ">"; echo $row["item_title"]; echo "</a>"; echo "<br>"; echo $row["item_description"]; echo "<br><br>"; } mysql_free_result($result); any help would greatly be appreciated
Can you explain what you are trying to do and what the error is you are getting. From looking over your code I spotted this error: $result = mysql_query("select * from classified_postings where category ='xval'") PHP: should be relaced with $xval = (int)$_POST['xval']; $result = mysql_query("select * from classified_postings where category ='$xval'"); PHP: This is assuming that xval is a numeric value. Brew
Are you trying to echo the query that you're sending to the SQL server? If so it may be worth trying storing the query as text in a variable, echoing the contents of the variable and then running mysql_query. $query = "select something from somewhere"; echo $query; $query = mysql_query($query);