|
Posted by Mark Sargent on 05/10/05 09:50
Mary-Anne Nayler wrote:
> oh, and the i++ should be inside the while loop and there is also a
> missing semi colon after the echo, ie;
>
> $i=0;
> while ($i < $num){
> $product_type=mysql_result($result,$i,"product_type_detail");
> echo "<tr><td><? echo $product_type ?></td></tr>";
> $i++ ;
> }
>
>
> Mark Sargent wrote, On 10/05/05 02:23 PM:
>
>> Hi All,
>>
>> this page,
>>
>> http://www.freewebmasterhelp.com/tutorials/phpmysql/5
>>
>> has the below code,
>>
>> <?
>> $i=0;
>> while ($i < $num) {
>>
>> $first=mysql_result($result,$i,"first");
>> $last=mysql_result($result,$i,"last");
>> $phone=mysql_result($result,$i,"phone");
>> $mobile=mysql_result($result,$i,"mobile");
>> $fax=mysql_result($result,$i,"fax");
>> $email=mysql_result($result,$i,"email");
>> $web=mysql_result($result,$i,"web");
>> ?>
>>
>> <tr>
>> <td><font face="Arial, Helvetica, sans-serif"><? echo $first."
>> ".$last; ?></font></td>
>> <td><font face="Arial, Helvetica, sans-serif"><? echo $phone;
>> ?></font></td>
>> <td><font face="Arial, Helvetica, sans-serif"><? echo $mobile;
>> ?></font></td>
>> <td><font face="Arial, Helvetica, sans-serif"><? echo $fax;
>> ?></font></td>
>> <td><font face="Arial, Helvetica, sans-serif"><a href="mailto:<? echo
>> $email; ?>">E-mail</a></font></td>
>> <td><font face="Arial, Helvetica, sans-serif"><a href="<? echo $web;
>> ?>">Website</a></font></td>
>> </tr>
>>
>> <?
>> $i++;
>> }
>>
>>
>> echo "</table>";
>>
>> which I basically understand, except the html generation. I am trying
>> to create something similiar, although, I think there are some errors
>> in even perhaps my logic..?
>>
>> <html>
>> <body>
>> <h1><center>Jumbo Status</center></h1><br>
>> <?php
>> $db = mysql_connect("localhost", "root", "grunger");
>> mysql_select_db("status",$db);
>> $result = mysql_query("SELECT ProductTypes.product_type_detail FROM
>> ProductTypes",$db);
>> $myrow = mysql_fetch_array($result);
>> $num = mysql_num_rows($result);
>> ?>
>> <table aligh="center" border="2">
>> <tr>
>> <td>Product Type</td>
>> </tr>
>> <?
>> $i=0;
>> while ($i < $num){
>> $product_type=mysql_result($result,$i,"product_type_detail");
>> echo "<tr><td><? echo $product_type ?></td></tr>"
>> }
>> $i++
>> ?>
>> </table>
>> </body>
>> </html>
>>
>> I get the folowing error,
>>
>> *Parse error*: parse error, unexpected '}', expecting ',' or ';' in
>> */var/www/html/products.php* on line *20
>> *
>> which is the $i++ section.
>>
>> Cheers.
>>
>> Mark Sargent.
>>
>
Hi All,
yes, changed it a little. Works fine now. Suprised at how much I've
forgotten about HTML too. Cheers.
Mark Sargent.
<html>
<body>
<h1><center>Jumbo Status</center></h1><br>
<table aligh="center" border="2">
<tr>
<td>Product Type</td>
</tr>
<?php
$db = mysql_connect("localhost", "root", "grunger");
mysql_select_db("status",$db);
$result = mysql_query("SELECT ProductTypes.product_type_detail FROM
ProductTypes",$db);
$num = mysql_num_rows($result);
for ($i=0; $i<$num; $i++){
$myrow = mysql_fetch_array($result);
$product_type=mysql_result($result,$i,"product_type_detail");
echo "<tr><td>$product_type</td></tr>";
}
?>
</table>
</body>
</html>
[Back to original message]
|