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
Share on other sites

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.

Link to comment
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>";

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.