php3-list | 199903
Date: 03/28/99
- Next message: Leonardo Creo: "[PHP3] PHP3.ini"
- Previous message: Rasmus Lerdorf: "Re: [PHP3] Reformatting paragraphs"
- Maybe in reply to: Steve Douville: "[PHP3] Array Question"
- Next in thread: Graeme Merrall: "RE: [PHP3] Array Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
-
>Hey all, im tired and stuck on this....below is a db call that i loop 14
times. The
>variable $a is already defined and not shown here, its just some text, this
part works
>fine. It loops 14 times showing the 14 different lines of text. But the
2nd one, $row,
>is causing me problems. It should grab the 14 different rows, q1, q2, q3,
q4 etc., but
>obviously im doing it wrong. My question is, how do i get $row[q$i] to do
this: $row[q1]
>$row[q2] and so forth..
>
>$i = 1;
>while ($i <= 14): /* This sets how many questions there are */
>$user = mysql_query("select q$i from table where id = $id ");
>
>$row = mysql_fetch_array($user);
>
>echo("<tr><td bgcolor=\"#D6D5FF\"><b>$a[$i]</b></td><td
>bgcolor=\"#cccccc\">$row[q$i]</td></tr>");
>
>$i++;
>endwhile;
>
>
Hey, I know this solution to your problem.
Put this:
$i = 1;
while ($i <= 14): /* This sets how many questions there are */
$user = mysql_query("select q$i from table where id = $id ");
$row = mysql_fetch_array($user);
$tmp="\$var= \$row[q$i]";
eval($tem);
// Now $var contain the value of $row[q$i] for each $i value on loop
echo("<tr><td bgcolor=\"#D6D5FF\"><b>$a[$i]</b></td><td
bgcolor=\"#cccccc\">$var</td></tr>");
$i++;
endwhile;
-- PHP 3 Mailing List http://www.php.net/ To unsubscribe send an empty message to php3-unsubscribe <email protected> To subscribe to the digest list: php3-digest-subscribe <email protected> For help: php3-help <email protected> Archive: http://www.php.net/mailsearch.php3 List administrator: zeev-list-admin <email protected>
- Next message: Leonardo Creo: "[PHP3] PHP3.ini"
- Previous message: Rasmus Lerdorf: "Re: [PHP3] Reformatting paragraphs"
- Maybe in reply to: Steve Douville: "[PHP3] Array Question"
- Next in thread: Graeme Merrall: "RE: [PHP3] Array Question"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

