Re: [PHP] I wish I knew more about multi-dimensional arrays

2003-08-23 Thread Verdon vaillancourt
Hey bigdog, that's beautiful! I laughed, I cried, so elegant ;)

Thanks, that did the job nicely.

Salut,
verdon



On 8/23/03 2:02 AM, [EMAIL PROTECTED]
[EMAIL PROTECTED] wrote:

 From: Ray Hunter [EMAIL PROTECTED]
 Reply-To: [EMAIL PROTECTED]
 Date: Fri, 22 Aug 2003 11:03:10 -0600
 To: 'PHP-General' [EMAIL PROTECTED]
 Subject: Re: [PHP] I wish I knew more about multi-dimensional arrays
 
 mysql result as a multi-dimensional array:
 
 while( $row = mysql_fetch_array($result) ) {
 $rows[] = $row;
 }
 
 now you have a multi-dimensional array that contains each row in rows...
 
 examples:
 row 1 col 1 - $rows[0][0]
 row 3 col 2 - $rows[3][2]
 
 hth
 
 --
 bigdog
 
 
 On Fri, 2003-08-22 at 10:37, Verdon vaillancourt wrote:
 Hi, please don't chuckle (too loudly) at my attempts to learn ;)
 
 I'm trying to create what I think would be a multi-dimensional array from a
 mysql result set, to use in some example code I got off this list last week.
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP] I wish I knew more about multi-dimensional arrays

2003-08-22 Thread Verdon vaillancourt
Hi, please don't chuckle (too loudly) at my attempts to learn ;)

I'm trying to create what I think would be a multi-dimensional array from a
mysql result set, to use in some example code I got off this list last week.

The example renedring code I want to work with is...

?php

$data = array('A', 'B', 'C', 'D', 'E', 'F', 'G');
$rowlength = 3;

echo (table);
for ($i = 0; $i  sizeof ($data); $i += $rowlength)
{
echo (tr);
for ($j = 0; $j  $rowlength; $j++)
{
if (isset ($data[$i+$j]))
{
echo (td{$data[$i+$j]}/td);
} else {
echo (tdnbsp;/td);
}
}
echo (/tr);
}
echo (/table);



?

I trying to create the $data array from my query results like this...

$sql = select * from table limit 0,5;
$result = mysql_query ($sql);
$number = mysql_numrows ($result);

for ($x = 0; $x  sizeof (mysql_fetch_array($result)); $x ++) {
$data = implode (',',$result[$x]);
}

I had hoped this would get me the six arrays on the page (where I could then
extract the values). I've also tried a number of similar approaches but am
consistently getting six error messages on the page along the lines of

Warning :  implode() [ function.implode ]: Bad arguments. in

I know I'm missing something basic and would appreciate any pointers.

Thanks,
Verdon


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] I wish I knew more about multi-dimensional arrays

2003-08-22 Thread Ray Hunter
mysql result as a multi-dimensional array:

while( $row = mysql_fetch_array($result) ) {
  $rows[] = $row;
}

now you have a multi-dimensional array that contains each row in rows...

examples:
row 1 col 1 - $rows[0][0]
row 3 col 2 - $rows[3][2]

hth

--
bigdog


On Fri, 2003-08-22 at 10:37, Verdon vaillancourt wrote:
 Hi, please don't chuckle (too loudly) at my attempts to learn ;)
 
 I'm trying to create what I think would be a multi-dimensional array from a
 mysql result set, to use in some example code I got off this list last week.
 
 The example renedring code I want to work with is...
 
 ?php
 
 $data = array('A', 'B', 'C', 'D', 'E', 'F', 'G');
 $rowlength = 3;
 
 echo (table);
 for ($i = 0; $i  sizeof ($data); $i += $rowlength)
 {
 echo (tr);
 for ($j = 0; $j  $rowlength; $j++)
 {
 if (isset ($data[$i+$j]))
 {
 echo (td{$data[$i+$j]}/td);
 } else {
 echo (tdnbsp;/td);
 }
 }
 echo (/tr);
 }
 echo (/table);
 
 
 
 ?
 
 I trying to create the $data array from my query results like this...
 
 $sql = select * from table limit 0,5;
 $result = mysql_query ($sql);
 $number = mysql_numrows ($result);
 
 for ($x = 0; $x  sizeof (mysql_fetch_array($result)); $x ++) {
 $data = implode (',',$result[$x]);
 }
 
 I had hoped this would get me the six arrays on the page (where I could then
 extract the values). I've also tried a number of similar approaches but am
 consistently getting six error messages on the page along the lines of
 
 Warning :  implode() [ function.implode ]: Bad arguments. in
 
 I know I'm missing something basic and would appreciate any pointers.
 
 Thanks,
 Verdon
 


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php