Forum Moderators: coopster

Message Too Old, No Replies

Extracing Values From An Array

seriously stuck here folks

         

imtrypin

8:51 am on Nov 29, 2007 (gmt 0)

10+ Year Member



Code Snippet:
$query = "SELECT fname, day, wlist FROM birthdays WHERE fbranch = '$famname' AND month like 'Mar' " ;

$result = mysql_query($query) or die("Can't execute query: " . mysql_error());
while($row = mysql_fetch_array($result))
{
$name .= $row['fname']."";
$date .= $row['day']."";
$wishl .= $row['wlist']."";
}

$name = rtrim($name,",");
$date = rtrim($date,",");
$wishl = rtrim($wishl,",");
-------------
Ok, here is my problem. While everything above works great, all the fields that I am assigning variables to have more than one entry. I would like to assign individual variables to them so I can use each one independantly. Currently if I echo $name what I end up with is this: name1name2. I would like to be able to echo let's say $name and get name. then echo $name1 and get name1 as output.

Can anybody give me a hand with this please?

Thanx in advance. :)

Habtom

8:55 am on Nov 29, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



$x = 0;
while($row = mysql_fetch_array($result))
{
$name[$x] = $row['fname'];
$date[$x] = $row['day'];
$wishl[$x] = $row['wlist'];
$x++;
}

Now you have an array.

$name[0] is first record
$name[1] is second record
. . . .

imtrypin

9:05 am on Nov 29, 2007 (gmt 0)

10+ Year Member



LOL...dang...glad I didn't tax you too hard on that one!

Thank you very much...worked like a charm. I had seen that example earlier but I couldn't remember where I had seen it and I kept putting a 1 at the end of it.

Thank you again :)