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
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>
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.