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 ( $grey , MYSQL_ASSOC )) {
echo '' . $row [ 'date' ]. ',' ;
}
?>
Any ideas would be amazing
not so clear
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
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.
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!
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).
"Please give us a simple answer, so that we don't have to think, because if we think, we might find answers that don't fit the way we want the world to be."
~ Terry Pratchett in
Nation
eBookworm.us
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
Forum Rules
Bookmarks