animal
2-6-02, 06:43 AM
I was working on a shopping cart and I wrote an order script in PHP. I am sending the script numbered variables for each item ordered. name1,quantity1,price1,itemtotal1. There would be a set of these variables for each item ordered, Ex name2, name3. These variables are coming out of the cart software and I never know how many there will be.
I wrote this loop to display the items ordered in a table. The problem is I have the limit hard-coded to 15 items. I wanted to check and see if quantity$i was null and stop looping. Any ideas?
for ($i=1; $i <= 15; $i++)
{
$temp_a = "Name$i";
$temp_b = "Quantity$i";
$temp_c = "Price$i";
$temp_d = "ItemTotal$i";
print "<tr>";
print "<td width=70%>".$$temp_a."</td>";
print "<td width=10%>".$$temp_b."</td>";
print "<td width=10%>".$$temp_c."</td>";
print "<td width=10%>".$$temp_d."</td>";
print "</tr>";
}
I wrote this loop to display the items ordered in a table. The problem is I have the limit hard-coded to 15 items. I wanted to check and see if quantity$i was null and stop looping. Any ideas?
for ($i=1; $i <= 15; $i++)
{
$temp_a = "Name$i";
$temp_b = "Quantity$i";
$temp_c = "Price$i";
$temp_d = "ItemTotal$i";
print "<tr>";
print "<td width=70%>".$$temp_a."</td>";
print "<td width=10%>".$$temp_b."</td>";
print "<td width=10%>".$$temp_c."</td>";
print "<td width=10%>".$$temp_d."</td>";
print "</tr>";
}