|
Posted by Norman Peelman on 07/31/07 22:18
Jerim79 wrote:
> I have a SQL query that returns all company names containing a user
> defined keyword. I store all this information using: $listings =
> mysql_fetch_array($result);
>
> That query works fine, as I am able to see the first company. What I
> need to do, is loop through the array, displaying each company name. I
> have the code to write the company name to the screen. I am just
> trying to figure out how to do the loop. My beta attempt:
>
> (Not shown is that I have used $NumRows to catch the number of rows
> contained in $result)
>
> for (x=0, x<=$NumRows, x++){
> echo $listings['company_name'];
> }
>
> Any ideas will be greatly appreciated.
>
while ($data = mysql_fetch_array($result.MYSQL_ASSOC))
{
$listings[] = $data['company_name'];
}
will put them all in the numerically indexed array $listings. So you'll
have:
$listings[0]['company_name']... $listings[n]['company_name']
Norm
Navigation:
[Reply to this message]
|