laflair13 Posted January 19, 2015 Share Posted January 19, 2015 I added a search form on my site but I cannot figure out how to add links to the search results. The results are being posted as the item name and the item pages look like this used-product.php?Item=102 I am not understanding how I can have that url match up with my item name. Here is my results.php code In the header <?php include_once('mysql_connect.php'); if (!isset($_POST['search'])) { header ("Location:index.php"); } $search_sql="SELECT * FROM new_equip WHERE itemname LIKE '% " .$_POST ['search'] . " %'"; $search_query=mysql_query($search_sql); if(mysql_num_rows($search_query)!=0) { $search_rs=mysql_fetch_assoc($search_query); } ?> and where the results are being displayed <?phpif (mysql_num_rows($search_query)!=0){ do {?> <p><a href="new-product.php?Item=<?php echo $eid; ?>"><?php echo $search_rs ['itemname']?></a></p> <?php } while ($search_rs=mysql_fetch_assoc($search_query)) ; } else { echo "No Results Found"; } ?> I have been on this and trying to figure out another issue I am having and I cannot figure out either of them. (The other is deleting a row from a table with the click of a link) Any help on this would be greatly appreciated it. I have looked and trial and error all day and I cannot seem to get it. Quote Link to comment Share on other sites More sharing options...
cyberRobot Posted January 20, 2015 Share Posted January 20, 2015 The results are being posted as the item name and the item pages look like this used-product.php?Item=102 I am not understanding how I can have that url match up with my item name. Are the item IDs stored in the new_equip table? Assuming they are and the column name is "eid", you could change this: <p><a href="new-product.php?Item=<?php echo $eid; ?>"><?php echo $search_rs ['itemname']?></a></p> To this: <p><a href="new-product.php?Item=<?php echo $search_rs['eid']; ?>"><?php echo $search_rs ['itemname']?></a></p> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.