
March 3rd, 2000, 07:58 AM
|
|
Junior Member
|
|
Join Date: Feb 2000
Posts: 16
Time spent in forums: < 1 sec
Reputation Power: 0
|
|
|
I apologize if this makes absolutely NO sense.
Ok I got a little problem, which I have a solution for but I would like to know if the is a better way.
I am making query to a mysql DB like so:
$query="Select * from DEMOTABLE";
$thisquery=mysql_query($query);
$demoinfo=mysql_fetch_array($thisquery);
Now I would like to make a table in HTML like
so:
<TABLE>
<?
while($demoinfo=mysql_fetch_array($thisquery);{
?>
<TR>
<?php
while($key=key($demoinfo)){
?>
<TD>
<?echo $demoinfo($key);?>
</TD>
<?
next($demoinfo);
}?>
</TR>
<?}?>
This does not work.
i get output as such.
column1 column1 column2 column2 column3 column3
becuase the keys for the $demoinfo array
are 'KEY0' 0 'KEY1' 1 'KEY2' 2
The keys are both the numeric and the alphenumeric. Doubling my output.
Now my stupid work around is to
add 2 next($demoinfo) commands. So I skip evry other column.
This works but there has to be another way.
Any help would be greate.
Thanks.
ps
the above code does not acutally prodce duoble output. becase it will stop here
while($key=key($demoinfo)){
on the second pass becuase the second pass
the key=0, the numeric key, which is false.
meaning I actually only get 1 column printed.
|