Reputation: 1
I have products stored in a database. These items have ID, NAME, QUANTITY, and STOCK_NUMBER fields. I want to make an href
for all of the data in the database:
$Result=mysql_query("SELECT * FROM Products");
while($row=mysql_fetch_array($Result)){
href .....
}
I want the result like this
item_id=1&name_1_tv&quantity_1=2&stock_number_1=1411
&item_id=2&name_2_mobile&quantity_2=5&stock_number_2=5894
&item_id=3&name_3_radio&quantity_3=2&stock_number_3=18541
&item_id=4&name_4_tv&quantity_4=2&stock_number_4=1025
&item_id=5&name_5_computer&quantity_5=1&stock_number_5=1455
&item_id=6&name_6_cd&quantity_6=2&stock_number_6=5888
all these under the link
Upvotes: 0
Views: 89
Reputation: 449813
Use http_build_query()
.
while($row=mysql_fetch_assoc($Result)) // note the change to assoc
{
$query = http_build_query($row);
echo "&$query<br>";
}
Note that GET requests have very low maximum length limits. IE chokes on URLs longer than 2 kilobytes, for example.
Upvotes: 1