Jump to content

Adding links to my search results


laflair13

Recommended Posts

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.

Link to comment
https://forums.phpfreaks.com/topic/294075-adding-links-to-my-search-results/
Share on other sites

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>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.