Re: goto
| From: | Stuart Dallas | Date: | Thu, 13 Jun 2002 13:34:13 +0000 |
| Subject: | Re: goto | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-101953@lists.php.net to get a copy of this message | ||
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