Hi Folks, I decide to try and learn a little php and created my first database yesterday. It is simple one table with 7 fields (id, item, period, CDN, US, GBP, EURO). I want to display the contents of this database in a table. So that the price related to period (1, 2, 3, 5 or 10) is displayed in the appropriate table cell. Although my code sample doens't include it I will use an If/Else statement and a form to display and select the various currencies:
<table width="550" border="1">
<tr>
<th>domains</td>
<th>1 year</td>
<th>2 years</td>
<th>5 years</td>
<th>10 years</td>
</tr>
<?php
$username="xxxx";
$password="xxxx";
$database="xxxx";
mysql_connect(localhost,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM pricing";
$result=mysql_query($query);
$num=mysql_numrows($result);
mysql_close();
$i=0;
while ($i < $num) {
$item=mysql_result($result,$i,"item");
$period=mysql_result($result,$i,"period");
$cdn=mysql_result($result,$i,"cdn");
?>
<tr>
<td><font face="Arial, Helvetica, sans-serif"><b><center>.ca, .bc.ca etc.</center></font></td>
<td><font face="Arial, Helvetica, sans-serif">$<? echo $cdn; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif">$<? echo $cdn; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif">$<? echo $cdn; ?></font></td>
<td><font face="Arial, Helvetica, sans-serif">$<? echo $cdn; ?></font></td>
</tr>
<?
$i++;
}
echo "</table>";
?>
For some reason this displayes only one value (the CDN price for period 1) in each of the cells. I'm certain that when I first tested it displayed (all the CDN priced for the periods I needed.
Not being a programmer or db designer I may not be able to do this easily witht eh db design I've used or with the lack of php-coding skill. So joined this baord jsut in case this is rather simple and its something I'm jsut not aware of or didn't consider when designing my database. Any help would be appreciate. Please not that some items won't have pricing for period's 3 or 5 & 10.