On Tue, 2003-06-03 at 02:12, Bix wrote:
> I'm fine with using while loops, use them for most of my listing work, but I
> wanted to try using a foreach loop instead but it seemed not to work as
> expected. For ym table generation, I need the $key to do some maths on in
> order to get my table lookin
I've decided to drop foreach altogether now and just used good old while on
its own with a counter to use as the key. The second foreach in your example
would run on each column on the row, when i need to just be able to access
the columns.
I appreciate the help though, thanks ;o)
Am now using:
And doesn't this solve your problem? While loop will loop for each row,
foreach will give you the key and value. How else do you want to loop?
while($row=mysql_fetch_array($result)) {
foreach($row as $key => $article){
//here you have $key and $article
}
}
Bix wrot
I need to access the row by colum name...
eg:
$row['id'] $row['title'] $row['detail']
My table gen script puts the relelvant fields into the right boxes, and my
maths works from the $key to put s in the right place.
So i need a loop that will loop as many times as there are rows, so while
works
I need to access the row by colum name...
eg:
$row['id'] $row['title'] $row['detail']
My table gen script puts the relelvant fields into the right boxes, and my
maths works from the $key to put s in the right place.
So i need a loop that will loop as many times as there are rows, so while
works
Try:
Bix wrote:
Hi all,
I am trying to build up a table using values from a db as follows...
mysql_select_db($db, $sql_connection);
$result = mysql_query("SELECT * FROM $table WHERE $query LIMIT
$limit",$sql_connection);
$output = "\n";
while($row=mysql_fetch_array($result)) {
foreach
I'm fine with using while loops, use them for most of my listing work, but I
wanted to try using a foreach loop instead but it seemed not to work as
expected. For ym table generation, I need the $key to do some maths on in
order to get my table looking right. All the guts are done, but for some
rea
This is correct:
while($myrow = mysql_fetch_array($result))
{
// ...
}
The iteration of the while loop represents one returned row from the mysql
result, with $myrow being an array of values returned.
Rather than a SELECT * query, let's look at a something where we know the
column na
Hi all,
I am trying to build up a table using values from a db as follows...
mysql_select_db($db, $sql_connection);
$result = mysql_query("SELECT * FROM $table WHERE $query LIMIT
$limit",$sql_connection);
$output = "\n";
foreach(mysql_fetch_array($result) as $key => $article){
//stuff
}
n
9 matches
Mail list logo