Re: Looping problem?
| From: | Brad Pauly | Date: | Tue, 06 Jan 2004 22:12:34 +0000 |
| Subject: | Re: Looping problem? | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-173917@lists.php.net to get a copy of this message | ||
On Tue, 2004-01-06 at 15:04, Jas wrote:
> require 'database.php';
> $t_02 = "subnets";
> $sql_subs = mysql_query("SELECT * FROM $t_02",$db)or
> die(mysql_error()); while(list($id,$sub,$msk,$dns01,$dns02,$rtrs,$rnge)
> = mysql_fetch_array($sql_subs)) {
> $num = mysql_num_rows($sql_subs);
> for($z = 0; $z < $num; $z++) {
> $vlans[] = "subnet $sub<br>netmask $msk {<br>option domain-name-servers
> $dns01, $dns02;<br>option routers $rtrs;<br>range
> $rnge;<br>}<br>"; }
> }
> // Write everything out formated...
> echo $vlans[$z]<br />\n;
>
> Right now it only pulling the last record???
You are only echo'ing the last record, $vlanz[$z]. You will need to loop
over $vlans again or put the echo line inside the for loop.
- Brad