Having problems displaying results with a while loop
Posted by: Catling (213.121.151.---)
Date: April 07, 2008 01:05AM

Hi, I am trying to output the results of my query into a table using a while loop but I am having trouble with it because I cant figure out which bits I need in my <?php ?> braces. Can you help me please?

<html>
<body>
<?php

// This page will list all of the items
// from the items table. Each item will have
// a link to add it to the cart

include("db.php"winking smiley;

// Get a connection to the database
$cxn = @ConnectToDb($dbServer, $dbUser, $dbPass, $dbName);
$query = "SELECT * FROM movie ORDER BY Movie_Title ASC";
$result = mysql_query($query);
?>

<?php
//For each item, we output its name, price, genre, and a link to add it to that users shopping cart:
while($row = mysql_fetch_array($result))
{
?>


<table>
<tr>
<td width="30%" height="25">
<font face="verdana" size="1" color="black">
<?php echo $row["Movie_Title"]; ?>
</font>
</td>
<td width="10%" height="25">
<font face="verdana" size="1" color="black">
£<?php echo $row["DVD_Price"]; ?>
</font>
</td>
<td width="50%" height="25">
<font face="verdana" size="1" color="black">
<?php echo $row["Genre"]; ?>
</font>
</td>
<td width="10%" height="25">
<font face="verdana" size="1" color="black">
<a href="cart.php?action=add_item&id=<?php echo $row["itemId"]; ?>&qty=1">Add Item</a>
</font>
</td>
</tr>
<tr>
<td width="100%" colspan="4">
<hr size="1" color="red" NOSHADE>
</td>
</tr>
<tr>
<td width="100%" colspan="4">
<font face="verdana" size="1" color="black">
<a href="cart.php">Your Shopping Cart &gt;&gt;</a>
</font>
</td>
</tr>
</table>

</body>
</html>

Options: ReplyQuote
Re: Having problems displaying results with a while loop
Posted by: yfastud (Moderator)
Date: April 07, 2008 01:59PM

Quote

<font face="verdana" size="1" color="black">
£<?php echo $row["DVD_Price"]; ?>
</font>
Did you put £ there or is it a mistake?

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote
Re: Having problems displaying results with a while loop
Posted by: Catling (213.121.151.---)
Date: April 07, 2008 06:00PM

I've put it there because I need to get the £ sign to come up next to the price of a DVD.

I got it to output something now but I cant get the £ sign to come out

Options: ReplyQuote
Re: Having problems displaying results with a while loop
Posted by: yfastud (Moderator)
Date: April 07, 2008 06:24PM

In that case, is should be

<?php echo "£".$row["DVD_Price"]; ?>

Have fun,

FREE One A Day
FREE Photo
FREE Games
FREE Websites
FREE Portable GPS
FREE WAMP Guides

Options: ReplyQuote


Sorry, only registered users may post in this forum.