0

Hi

Normally I would use the mysql_fetch_array command to get vallues from a DB array to print in seperate tables like below:

echo "<table width=\"100%\" border=\"1\"body bgcolor=\"#ffffff\"align=\"center\"text=\"#ffffff\">";
echo "<th>THUMBNAIL</th><th>NAME</th><th>SIZE</th><th>LOCATION</th>";

while($r = mysql_fetch_array($TagSearch))
{
$Code = $r["Code"];
$Name = $r["Name"];
$Size = $r["Size"];
$ImgPath = $r["ImgPath"];
$PurchaseDate = $r["PurchaseDate"];
$StartCycle = $r["StartCycle"];
$CycleLength= $r["CycleLength"];
$Location = $r["Location"];
$Status = $r["Status"];
$idClient = $r["idClient"];
$ShipTo = $r["ShipTo"];
$Medium = $r["Medium"];

echo "<tr>";
print "<td align='center'><a href=art.php?Code={$Code}><img src='{$ImgPath}' height=75 width=75 border='0' /></a></td><td align='center'>$Name</td><td align='center'>$Size</td><td align='center'>$Location</td>";
echo "</tr>";

How would I go about doing the same thing with a normal array
I tried:

echo "<table width=\"100%\" border=\"1\"body bgcolor=\"#ffffff\"align=\"center\"text=\"#ffffff\">";
echo "<th>CODES</th><th>THUMBNAIL</th><th>NAME</th><th>SIZE</th><th>MEDIUM</th><th>PRICE</th>";


while($r = current($_SESSION["Cart"]))
{
$Code = $r["Code"];
$ImgPath = $r["ImgPath"];
$Name = $r["Name"];
$Size = $r["Size"];
$Price = $r["Price"];
$Medium = $r["Medium"];

echo "<tr>";
print "<td align='center'>$Code</td><td align='center'><a href=art.php?Code={$Code}><img src='{$ImgPath}' height=75 width=75 border='0' /></a></td><td align='center'>$Name</td><td align='center'>$Size</td><td align='center'>$Medium</td><td align='center'>$Price</td>";
echo "</tr>";

Now all that does is print the first value in the array over and over.

I would love to use a method close to the first one to do this.

Any suggestions?

Edited by fabzster: n/a

3
Contributors
2
Replies
3
Views
7 Years
Discussion Span
Last Post by muralikalpana
0

Unless $_SESSION["Cart"] is an array, as opposed to $_SESSION being an array, there is nothing new to fetch. In other words, there is only one $_SESSION["Cart"] and each time you set $r, there is nothing new to retrieve, thus the same data over again.
If you have $_SESSION["Cart"][0] and $_SESSION["Cart"][1], then you would get different results.
Also, your while statement will only work, if the array is incremented and you are checking to see if the next array element is_set.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.