Jump to content


Photo

Search to display links???


  • Please log in to reply
4 replies to this topic

#1 crazylegseddie

crazylegseddie
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 19 August 2006 - 12:22 PM

I used the php freaks search full text search facility tutorial to create my search function, which i have managed to link to my table and carry out correct searches. How do I edit the script to now turn the title of my search into a link to the product? all my products are linked like this: categories.php?c=0&p=70 ie 'p=70' being the product id.
for those who hasnt seen the tutorial to display the results the code looks like.
  
    while($row = mysql_fetch_object($result)) 
    { 
      echo '<strong>Title: '.stripslashes(htmlspecialchars($row->pd_name)).'</strong><br />'; 
      echo '<p>'.stripslashes(htmlspecialchars($row->pd_more)).'</p>';  
      echo '<p>'.stripslashes(htmlspecialchars($row->pd_more2)).'</p>'; 
      echo '<hr size="1" />'; 
    } 

?> 

I need the title ie. $row->pd_name to be the link.

Any info regarding my query will be cool.

THX

#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 19 August 2006 - 12:39 PM

Something like this:

echo "<a href='categories.php?c=0&amp;p=". $row['product_id']. "'>more info</a>";

Legend has it that reading the manual never killed anyone.
My site

#3 crazylegseddie

crazylegseddie
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 19 August 2006 - 01:28 PM

Hi thx for reply but i tried to add that code but received this error:

Fatal error: Cannot use object of type stdClass as array in C:\Documents and Settings\ben\Desktop\Bens Briefcase\www\whitedisc\searchtemp\search.php on line 64

what I needed was to turn the title row (shown below) into a link from the search results if
thats possible??


echo '<strong>'.stripslashes(htmlspecialchars($row->pd_name)).'</strong><br />'; 



#4 crazylegseddie

crazylegseddie
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 19 August 2006 - 01:47 PM

I have also tried:
echo "<a href='categories.php?c=0p=". $row['pd_id']. "'>".stripslashes(htmlspecialchars($row->pd_name)).'</a><br />'; 

but still get the same error message?  ???



#5 crazylegseddie

crazylegseddie
  • Members
  • PipPipPip
  • Advanced Member
  • 36 posts

Posted 20 August 2006 - 10:57 AM

problem solved with:

while($row = mysql_fetch_assoc($result)) 
    { 
      echo "<a href='categories.php?c=0p=". $row['pd_id']. "'>".stripslashes(htmlspecialchars($row->pd_name)).'</a><br />'; 
      echo '<p>'.stripslashes(htmlspecialchars($row['pd_more'])).'</p>';   
      echo '<p>'.stripslashes(htmlspecialchars($row['pd_more2'])).'</p>'; 






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users