Re: goto

From: Date: Tue, 03 Sep 2002 21:02:57 +0000
Subject: Re: goto
References: 1  Groups: php.lang 
Request: Send a blank email to php-lang+get-374@lists.php.net to get a copy of this message
<posted & mailed> Hey, GOTO's would be ok.....functions work just as well for me. Anyway, you problem is the extra {}s. I'm not exactly sure about how your setup works but I think the following code would do what you want. PHP --- if($type == 'LOOP') { $sql = 'SELECT * FROM products'; $result = mysql_query($sql, $db); $record = $mysql_fetch_array($result, MYSQL_ASSOC); $looped = TRUE; } if($type == 'TEXT') { if($looped) { echo($record[$field]); } } if($type == 'ENDLOOP') { $looped = FALSE; } --- Let me know if it works or if you need any more help.....prolly should be on the php-general list ~Pauly Stephen Brewster wrote: > I am wirting a code seperation engine for PHP, the idea of which is it > will remove the need for me to have to build the majority of the websites > at my company. The designers will be able to build the html in dreamweaver > or similar and then insert custom tags into their code. The engine will > parse the code and insert the necessary PHP code. For the most part this > engine is working. However under some cirtumstances (like the one shown > below) I need to be able to perfom a loop or if statement. This is proving > to be incredably difficult since I would end up with code like below. For > obvious reasons the compiler does not like this code. This would be simple > if PHP had GOTO's. Does anyone know of a way around this situation? > > 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') { > } > } > > -- > > ------------------------------------------------------ > Stephen Brewster > Email: steve@cite.co.uk > Tel: 0116 2335545 > Mobile: 07776 475849 > ICQ: 383095 > ------------------------------------------------------

« previous php.lang (#374) next »