On Thursday, June 13, 2002, 1:22:07 PM, Stephen Brewster wrote:
> HTML
> ----
> <table>
> <products type="loop">
> <tr>
> <td><products type="text" field="name"></td>
> <td><products type="text" field="price"></td>
> </tr>
> <products type="endloop">
> </tr>
> PHP
> ---
> if($type == 'LOOP') {
> $sql = 'SELECT * FROM products';
> $result = mysql_query($sql, $db);
> $record = $mysql_fetch_array($result, MYSQL_ASSOC);
> {
> }
>
> if($type == 'TEXT')
> echo($record[$field]);
>
> if($type == 'ENDLOOP') {
> }
> }
Ok, I'm not entirely sure what you're trying to do, but your "loop" should
probably look something like this...
if ($type == 'LOOP')
{
$sql = 'SELECT * FROM products';
$result = mysql_query($sql, $db);
$record = $mysql_fetch_array($result, MYSQL_ASSOC);
while ($type != 'ENDLOOP')
{
if($type == 'TEXT')
echo($record[$field]);
}
}
That's going by your code. However, it still doesn't make sense and will result
in an endless loop since $type never changes.
For the record, a goto would be the worst way to implement something like this!
I hope that helps a bit.
--
Stuart
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php