Jump to content

how to chech if data already exists


FinnKim

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/262182-how-to-chech-if-data-already-exists/
Share on other sites

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>";

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.