while loop

From: Date: Wed, 08 Nov 2000 15:14:28 +0000
Subject: while loop
Groups: php.general 
Request: Send a blank email to php-general+get-24316@lists.php.net to get a copy of this message
Hello all, I have got a while loop which retrieve data from a DB. Within this while loop I have got another while loop which retrieve its data from the same DB if the if statement is fulfilled. My piece of code looks: <? if ($action == "alle") { $sql = "SELECT * FROM Rubriken ORDER BY rub_id"; $q -> query ($DB, $sql); while ($row = $q ->getrow()) { echo $row['rubrik']; if ($rubrik == $row['run_name']) { $sql = "SELECT * FROM $rubrik ORDER BY id"; $q -> query ($DB, $sql); $num = $q -> numrows(); if ($num > 0) { while ($row = $q ->getrow()) { echo $row['unterrubrik']; } } } } } ?> Now my problem is that when $rubrik does not exists the first while loop works fine. But when $rubrik exists the first while loop stops after doing the second loop for the first time. Does anyone know why the first loop behaves like this and not going through. I appreciate any help. Thank you. Ali

« previous php.general (#24316) next »