FinnKim Posted May 7, 2012 Share Posted May 7, 2012 Hi, I want to make a query and check if data exists already on my is_availble table on calendar db tomake it unavailble . I have 16 checkboxs. I have this code for first one. And I did it for second one alse, although data dosen't exist on db, but it makes it also unvailble! Here you can see my php code: PHP Code: <?php mysql_select_db("calendar", $con); $result2 = mysql_query("SELECT * FROM is_availble WHERE datetime=$v_datetime "); //---------------------------------- choeckbox 1(bookable time 1)------------------------\\ echo"<div class='box'> <div class='boxbut'>"; if($result2) { echo" Booked "; } else{ echo" <input type='radio' name='datetime' value='". $row['day1']." ".$row['time1']."'> <d>". $row['day1'] ,"</d><br/><t>". $row['time1'] ."</t>"; } echo"</div></div>"; //---------------------------------- choeckbox 2(bookable time 2)------------------------\\ echo"<div class='box'> <div class='boxbut'>"; if ($result2) { echo" Booked "; } else{ echo" <input type='radio' name='datetime' value='". $row['day1']." ".$row['time2']."'> <d>". $row['day1'] ,"</d><br/><t>". $row['time2'] ."</t>"; } echo"</div></div>"; Regards Quote Link to comment https://forums.phpfreaks.com/topic/262182-how-to-chech-if-data-already-exists/ Share on other sites More sharing options...
WatsonN Posted May 7, 2012 Share Posted May 7, 2012 What exactly are you trying to achieve, I'm lost? I also noticed you said the second box doesn't work, it is most likely because it's the exact same thing as the first one and using the exact same MySQL query. Quote Link to comment https://forums.phpfreaks.com/topic/262182-how-to-chech-if-data-already-exists/#findComment-1343623 Share on other sites More sharing options...
FinnKim Posted May 7, 2012 Author Share Posted May 7, 2012 I want if checkbox's value already exist in db, it becomes unavailble and for this I have changed the code like below, but still, when I select whatever checkbox, becoming unavailble starts from the first checkbox, and after whatever checkbox's selection on the form sencond checkbox becomes unavailble and so on! $squery = mysql_query("SELECT * FROM is_availble WHERE datetime=$v_datetime "); echo"<div class='box'> <div class='boxbut'>"; if(mysql_fetch_array($squery)) { echo" Booked "; } else{ echo" <input type='radio' name='datetime' value='". $row['day1']." ".$row['time1']."'> <d>". $row['day1'] ,"</d><br/><t>". $row['time1'] ."</t>"; } echo"</div></div>"; //---------------------------------- choeckbox 2(bookable time 2)------------------------\\ echo"<div class='box'> <div class='boxbut'>"; if(mysql_fetch_array($squery)) { echo" Booked "; } else{ echo" <input type='radio' name='datetime' value='". $row['day1']." ".$row['time2']."'> <d>". $row['day1'] ,"</d><br/><t>". $row['time2'] ."</t>"; } echo"</div></div>"; Quote Link to comment https://forums.phpfreaks.com/topic/262182-how-to-chech-if-data-already-exists/#findComment-1343637 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.