Jump to content


Photo

Problem with array fetch


  • Please log in to reply
2 replies to this topic

#1 drums

drums
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 15 June 2006 - 08:38 PM

I have a script that was done for my client on one site and I want to add it to other sites as well. I am able to write to the dB but retrieving the data only brings in one column. Can anyone tell me what I am doing wrong?
<? 
$query=mysql_query("select * from xlsdata where date='6/13/2006'");
while($record=mysql_fetch_array($query))
    $headingname = $record['heading'];
    $titlename = $record['title'];
    $bodyname = $record['body'];
    $imagename = $record['image'];
    $footername = $record['footer'];
?>
<h1><?=$headingname?></h1>
<h2><?=$titlename?></h2>
<?=$bodyname?>
<br><img src="images/<?=$imagename?>" border="0" alt="<?=$imagename?>"><br><strong><?=$footername?>
The only thing that shows is the heading.
Thanks.

#2 drums

drums
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 15 June 2006 - 11:00 PM

Didn't have the squiggly brackets:
{    
$headingname = $record['heading'];
    $titlename = $record['title'];
    $bodyname = $record['body'];
    $imagename = $record['image'];
    $footername = $record['footer'];
}
Thanks go to Lycander at LittleBlackDog.com

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 16 June 2006 - 07:36 AM

Common mistake... I've always said that blocks without explicit curlies shouldn't even compile (cf. Perl).
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users