Click here to Skip to main content
15,921,174 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,

i am new to php.
I created a dropdownmenu to list some productnames.
when i select a product out of this list, it should go to a common page "product.php"
and show details as per the selected product.

so i want to get the selected product value into the product.php page.

I am looping the below code.

echo"<ul><li><a href="product.php">$row[Name]</a></li></ul>";




i just want to pass the $row[Name] value to the product.php page, from the above line.

please help me.

regards
Posted
Updated 13-Oct-15 1:50am
v2

1 solution

To start with, your statement cannot work:
echo"<ul><li><a href="product.php">$row[Name]</a></li></ul>";


You're breaking the string for the ECHO by using double quotes throughout.

You really need to mix single and double quotes, with care, so that you don't make a string that's sure to return an error.

echo"<ul><li><a href='product.php'>$row['Name']</a></li></ul>";
is part of the fix. You also need to handle array elements differently if they're inside a string. You need to us curly braces:

echo"<ul><li><a href='product.php'>{$row['Name']}</a></li></ul>";
should fix that part of the problems, too. Note the single quotes around 'Name'!

The real question, then, falls to whatever you have in you $row array whose source is a mystery and so I'm treating it as the simplest possible case.

 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900