Results 1 to 6 of 6

Thread: Select rows & print out

  1. #1
    Join Date
    Mar 2008

    Select rows & print out

    Hey Guys,

    Basically im trying to compare 2 cells. Im using datepicker and need to grey out dates that have been booked

    Database rows are date and place

    It works when I have one 'place' in the cell but when I have 2 or more it doesn't work.

    Both cells have several dates and places

    for example

    date = '15/11/2012','16/11/2012' place = crow (that works but anymore places does not)

    PHP Code:

    $out = array(); 
    foreach($_POST['place'] as $place){ 
        $out[] = ("'".mysql_real_escape_string($place)."'"); 

    $imploded = implode(', ', $out); 
    echo $imploded;

    $date = "SELECT date FROM activities WHERE place IN ($imploded)"; 

    echo $date;

    $grey = mysql_query($date)or die(mysql_error());


    /* create an array of days which need to be disabled */
    var disabledDays = [

    <?php while ($row mysql_fetch_array($greyMYSQL_ASSOC)) {
    '' .$row['date']. ','

    Any ideas would be amazing

  2. #2
    Join Date
    Mar 2009
    not so clear

  3. #3
    Join Date
    Mar 2008
    Thanks for taking the time to look.

    Im trying to select all dates from the table which are equal the submitted form

    the form uses checkboxes so they can select multiple destinations (in my table there called place)

    the code does work but when more than one place is checked the code outputs the cells with only one place.

    so for example in the database (this works)

    date = '15/11/2012','16/11/2012'
    place = England

    This doesn't

    date = '15/11/2012','16/11/2012'
    place = England France Spain

    hope this is more clear thank you

  4. #4
    Join Date
    Mar 2009
    from the 2nd example you have given; three places are not separated by comma so when you pass it in query they act like a single value.

  5. #5
    Join Date
    Mar 2008
    hello again,

    Yeah i've tried that with no luck.

    Ive also tried it with quote marks and comas

    would I need another array for the 'place' column, like I have for 'date' and how would I combine them to work together?

    Or something like explode?

    thanks for your time!

  6. #6
    Join Date
    Aug 2004
    Yeah, you probably need to explode the place entry into an array (perhaps using preg_split() so that you can use a regexp for the field separator). You'll probably also want to make the text all upper case or all lower case to match however you have those names in the DB, or make sure you are using a case-insensitive collation type (if you DBMS supports it).
    "Well done....Consciousness to sarcasm in five seconds!" ~ Terry Pratchett, Night Watch

    How to Ask Questions the Smart Way (not affiliated with this site, but well worth reading)

    My Blog
    cwrBlog: simple, no-database PHP blogging framework

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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