help with displaying variables

Hi,

i need help any answer is appreciated
Im trying to implement a part of my site that shows certain food types and then a link under each food that says see more details,
eg. Title : $var1
type: $var2
SeemoreDetails

  Title : $var1
  type: $var2
  [u]SeemoreDetails[/u]

this brings you to an other page and displays more information about the product (from the phpmyadmin database) i have the foods displayed and the see details buttons using a while loop (while($rows=mysql_fetch_array($result)) )
but how to i make it so when you click the see more details button it displays more about the product by the variables in the sql database?

So when you hit the first option it will display everything about that product from the phpmyadmin to the screen … a dynamic variable if you would.
After clicking see more details

Title: $var1
type: $var2
weight: $var3
size: $var4

regards
Barry

Hi Barry,

As far as I could understand, you want to display full product details if a user clicks on “See More” link. We can accomplish this by passing variable/data by URL.

Suppose this is your selection:
[php]$results=mysql_query(“SELECT * FROM PRODUCTS”);[/php]
You should populate your products like this:
[php]
while($row=mysql_fetch_array($results)){
echo "Title: ". $row[‘title’] . “”;
echo "Type: ". $row[‘type’] . “”;
echo “<a href=details.php?product_id=” . $row[‘id’] . “>See More”;
}[/php]

Using POST or GET method, you should be able display products details in details.php.

Hi codeguru

Really appreciate the feedback ! :slight_smile:
forgot to mention that the information i am displaying from the database is actually from two different tables in a join sql query… does that effect the code you have given ?
(you can guess i’m new to php)
Regards !!!

i used the code given and it only posts the first word of the string on the new page.
so for example if $title = Red Apple
it will only display ‘Red’

Any ideas? regards

Can you post your SQL JOIN select statement here?

SELECT title, oldprice, newprice, name, body, email, phone, address, latitude, longitude
FROM food, store
WHERE food.id = store.dealid
AND categoryid = ‘3’ ";
AND starttime <= now()
AND endtime >= now().

Thanks

Hi Barry,

You miss to include food ID and food type in your selection. Your query should look like this:

[php]
$q = “SELECT food.id, food.type, title, oldprice, newprice, name, body, email, phone, address, latitude, longitude
FROM food, store
WHERE food.id = store.dealid
AND categoryid = ‘value’
AND starttime <= now() AND endtime >= now()”;
$results=mysql_query($q) or die(mysql_error());
while($row=mysql_fetch_array($results)){
echo "Title: " . $row[‘title’] . “”;
echo "Type: " . $row[‘food.type’] . “”;
echo "<a href=details.php?product_id= " . $row[‘food.id’] . “>See More”;
}
[/php]

As to the question why you’re getting only the first word of the string, make sure (varchar) size of field ‘title’ is large enough…I am making an assumption you’ve stored ‘title’ properly in your database…

where are you trying to display ‘title’ by the way? If you’re to display it in your form’s text field, make sure you’ve set maxsize properly…

Sponsor our Newsletter | Privacy Policy | Terms of Service