SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Oct 2008
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting values in database into an array

    This is really embarrasing having to ask for help on something so basic.

    I am retreiving values from my database - in this case the day element of dates and want to put them into an array for processing as the 'needle' by the in_array function.

    I can echo the days like this

    Code PHP:
    while ($fetcharray = mysql_fetch_array($sql))	{	
     
    	$datebooked= strtotime($fetcharray['datebooked']);
     
    		$bookedday = date('d', $datebooked);
     
    	echo '<p>day is ' . $bookedday . '</p>';

    From this point I would have expected this to have given me the required aray
    Code PHP:
    $d = array(date('d', $datebooked));	
     
    }

    This and anything else I've tried clearly does not work and I am stuck!! Can somebody help please?

  2. #2
    Non-Member
    Join Date
    Oct 2009
    Posts
    1,852
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    $sql="select day(datebooked) as bookedday from table";
    $res=mysql_query($sql);
    while (
    $fetcharray mysql_fetch_array($res))   { 
      
    $d[]=$fetcharray['bookedday'];


  3. #3
    SitePoint Zealot
    Join Date
    Oct 2008
    Posts
    114
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for that. Knew it would be something really simple!

  4. #4


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •