Jump to content


Photo

multiple records


  • Please log in to reply
6 replies to this topic

#1 lional

lional
  • Members
  • PipPipPip
  • Advanced Member
  • 266 posts

Posted 10 July 2006 - 06:37 PM

Hi All
I am trying to runa query where I have multiple records each containing a date.
I want to use these dates to change the background of my table using php at a later stage.
My problem is that each date that is pulled overwrites the previous date, whch means that the end of the queryonly the last date is shown.
Is there a way to run a query so that all the dates are stored and that they can all be referenced.

Thanks
Lional

#2 SQL_F1

SQL_F1
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 11 July 2006 - 01:16 AM

???
Give us your query.

Also execute the MySQL statement
describe [i]<table name>[/i]
so that we can see what the table looks like.





#3 lional

lional
  • Members
  • PipPipPip
  • Advanced Member
  • 266 posts

Posted 11 July 2006 - 04:21 AM

$query = "SELECT * from availability";
$result = mysql_query($query, $conn);
while ($row = mysql_fetch_array($result)){
$booking_date_out = $row[booking_date];
}

#4 fenway

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

Posted 11 July 2006 - 08:25 AM

Well, quotes around the bareword "booking_date" would probably be a good start; however, sound like you want to be pushing each date onto an array.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#5 lional

lional
  • Members
  • PipPipPip
  • Advanced Member
  • 266 posts

Posted 11 July 2006 - 09:03 AM

I fel the same ay, but I am nt sre how t pul a aray fom mysql. Cold you be so king to pint me in the right direction.

thanks a lot
Lional



#6 fenway

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

Posted 11 July 2006 - 04:51 PM

Has nothing to do with MySQL... instead of setting each date to the same scalar variable, since create an array, and push onto it... this is entirely contained within PHP.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#7 SQL_F1

SQL_F1
  • Members
  • PipPip
  • Member
  • 10 posts

Posted 13 July 2006 - 07:47 AM

What else are you doing within the while loop?

If it is only to collect the dates, then look at php.net for php's extensive array_ functions including array_push






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users