Page 1 of 1

Trying to output a link with referenced information

Posted: Wed Jun 08, 2005 2:56 pm
by Tycho81
Please forgive me if this question doesn't make any sense. I'm fairly new to PHP (learning as I go).
Anyway. I have a small MySQL database that I'm running a simple search on. I've got it outputting the rows that I want.
What I want to do is also output a link that's pulling "some" of it's info from the db.
ie. "www.somewebsite.com/prod.php?prod_link=13" where "www.somewebsite.com/prod.php?prod_link=" will always be the same but "13" will change depending on what product is found. Each product in the database has a product catagory number.

so if 4 results were found, two of them might be product type 1, one might be product type 3 and one might be product type 25. I want each to have a link pointing to it's appropriate product page.

Make sense? can this be done.? any help is appreciated. the simpler the better. prod_type is the name of the row in the db that contains the value I want to change on the link

I have this line outputting a field already in case someone was wondering (there are others, this is just one of them):
echo '<p>'.stripslashes($row->prod_info).'</p>';

I'd think something along these lines. (makes sense to me, but that doesn't mean anything).
echo '<a href="http://www.somewebsite.com/prod.php?pro ... e)</a><br/>';

Thanks again

Posted: Wed Jun 08, 2005 3:16 pm
by John Cartwright

Code: Select all

echo '<a href="http://www.somewebsite.com/prod.php?prod_link='.$row->prod_type.'">'.$row->prod_name.'</a><br/>';
assuming $row->prod_name exists

Posted: Wed Jun 08, 2005 3:42 pm
by Tycho81
Did the job.

Muchly appreciated.!