Current location: Hot Scripts Forums » Programming Languages » PHP » Array problem

Array problem

Reply
  #1  
Old 05-27-05, 12:16 AM
alabaster_lynch alabaster_lynch is offline
Wannabe Coder
 
Join Date: Mar 2005
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
Array problem

Here is my problem.
1st, I have set up a server on my pc just for development purposes whenever I use the following script, It just shows the first row and nothing else. There are 69 records on that table. I know that it is not my query because it runs in phpMyAdmin.
Code:
$query = "SELECT images FROM gallery_images order by date desc";
$result = mysql_query($query);
$imageArray = mysql_fetch_array($result);

$numberOfImages = mysql_num_rows($result);
echo $numberOfImages;
for($i = 0; $i < $numberOfImages; $i++)
{
	echo $imageArray[$i].'<br>';
}
Please help me

thank you for your time....Jose
Reply With Quote
  #2  
Old 05-27-05, 01:04 AM
shroder shroder is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
Just doing a mysql_fetch_array($result) will pull the first row. 'fetch_array' refers to putting the differnt fields into an array format. What your looking for is:
Code:
while($imageArray = mysql_fetch_row($result) {
    echo $imageArray[0].'<br/>';
}
mysql_fetch_row will allow you to just pick the variable by number instead of the field name. Since this is just one field we are selecting I figured it would be more simple to just pick by number.
Reply With Quote
  #3  
Old 05-27-05, 01:32 AM
alabaster_lynch alabaster_lynch is offline
Wannabe Coder
 
Join Date: Mar 2005
Posts: 103
Thanks: 0
Thanked 0 Times in 0 Posts
I knew I was too tired to be working right now...thank you for your help..

Jose
Reply With Quote
  #4  
Old 05-27-05, 08:34 PM
shroder shroder is offline
Newbie Coder
 
Join Date: Dec 2003
Posts: 34
Thanks: 0
Thanked 0 Times in 0 Posts
No problem.

Just remember to keep an emergency supply of coffee by your side at all times. You never know when fatigue will sneek up on you.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Serializing a set of arrays dannyallen PHP 2 10-11-04 04:04 AM
array() problem nekeno12 PHP 1 05-24-04 06:55 PM
mysql fetch array problem darkcarnival PHP 1 03-31-04 07:49 PM
linking to iframe not working :( j0d JavaScript 5 01-19-04 09:14 PM
array problem bitesize PHP 2 09-10-03 09:08 AM


All times are GMT -5. The time now is 03:48 AM.
vBulletin® Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.2 (Unregistered)