Re: contents of fetch array into a string
| From: | Steve Cayford | Date: | Wed, 06 Mar 2002 19:12:00 +0000 |
| Subject: | Re: contents of fetch array into a string | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-87504@lists.php.net to get a copy of this message | ||
On Wednesday, March 6, 2002, at 12:13 PM, Kris Vose wrote:
I have a problem with reading the contents of $r[1] into a string called = $mail. Does anyone have any suggestions? Any help is greatly appreciated. Kris Vose if ($czero != "") { $t = mysql_query("SELECT * FROM AddExisting");$t is now a resource variable, not an array. If you want to know the number of rows returned use mysql_num_rows($t) not count($t)
$number_of_customers = count($t); while($r = mysql_fetch_array($t))Note: you'll loop through this section $number_of_customer times, pulling one table row into $r each time through.
{ extract($r);Why are you using extract here?
for ($i = 0; $i<$number_of_customers; $i++)You're looping through $number_of_customers columns on each row in the table. Is this what you want? Is your table really $number_of_customers wide?
{echo $r[1].", ";Do you mean $r[$i] ?
} } Now you've dropped out of both loops. $r will be holding the last row you retrieved from the database table.
$mail = ' '; foreach($r[1] as $mailline)$r[1] is not an array here. What are you trying to do?
{ $mail.=$mailline; } }