PDA

Click to See Complete Forum and Search --> : PHP checkbox : check the checkbox and select data from database


mizz_aurora
Oct 24th, 2009, 07:47 PM
hello everyone...
i'm php beginner and have a very low programming skills. :(:(

i have some problem with the php checkbox function.
how to select data from database where the data is from checkbox and display the data.
for example: i select penang and beach from the checkbox, then data must be selected from database. lastly display the data.

here is my php code and i dont know how to write the php code to select checkbox


<form name="menu" target="">
<div id="booking1">
<table width="258">
<tr>
<th align="left" bgcolor="#299ad4" scope="row">State</th>
</tr>
<tr>
<th width="250" align="left" scope="row" bgcolor="#eff6ff"b><table width="250">
<tr>
<td width="80" class="style6" bgcolor="#eff6ff"><span class="style5" >Perlis</span></td>
<td width="22" class="style6" bgcolor="#eff6ff"><strong>
<label>
<input name="c1" type="checkbox" id="c1" value="checkbox" />
</label>
</strong></td>
<td width="93" bgcolor="#eff6ff" class="style6"><span class="style5">Negeri Sembilan </span></td>
<td width="22" bgcolor="#eff6ff" class="style6"><input name="c7" type="checkbox" id="c7" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Kedah</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c2" type="checkbox" id="c2" value="checkbox" /></td>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Melaka</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c8" type="checkbox" id="c8" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Penang</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c3" type="checkbox" id="c3" value="checkbox" /></td>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Kelantan</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c9" type="checkbox" id="c9" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Perak</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c4" type="checkbox" id="c4" value="checkbox" /></td>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Terengganu</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c10" type="checkbox" id="c10" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Selangor</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c5" type="checkbox" id="c5" value="checkbox" /></td>
<td bgcolor="#eff6ff" class="style5">Pahang</td>
<td bgcolor="#eff6ff" class="style6"><input name="c11" type="checkbox" id="c11" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Kuala Lumpur </span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c6" type="checkbox" id="c6" value="checkbox" /></td>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Melaka</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c12" type="checkbox" id="c12" value="checkbox" /></td>
</tr>
</table></th>
</tr>
<tr>
<th align="left" scope="row">&nbsp;</th>
</tr>
<tr>
<th align="left" bgcolor="#299ad4" scope="row">Place of Interest</th>
</tr>
<tr>
<th align="left" scope="row"><table width="250">
<tr>
<td width="119" bgcolor="#eff6ff" class="style6"><span class="style5">Beach</span></td>
<td width="29" bgcolor="#eff6ff" class="style6"><strong>
<label>
<input name="c13" type="checkbox" id="c13" value="checkbox" />
</label>
</strong></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Island</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c14" type="checkbox" id="c14" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Lakeside</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c15" type="checkbox" id="c15" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6">Riverside</td>
<td bgcolor="#eff6ff" class="style6"><input name="c16" type="checkbox" id="c16" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Town/City</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c17" type="checkbox" id="c17" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Outskirt</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c18" type="checkbox" id="c18" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Highland/Hillside</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c19" type="checkbox" id="c19" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6">Theme Park</td>
<td bgcolor="#eff6ff" class="style6"><input name="c20" type="checkbox" id="c20" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">National Park</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c21" type="checkbox" id="c21" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Golf Club </span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c22" type="checkbox" id="c22" value="checkbox" /></td>
</tr>
</table></th>
</tr>
<tr>
<th align="left" scope="row">&nbsp;</th>
</tr>
<tr>
<th align="left" bgcolor="#299ad4" scope="row">Facilities</th>
</tr>
<tr>
<th align="left" scope="row"><table width="250">
<tr>
<td width="119" bgcolor="#eff6ff" class="style6"><span class="style5">Hotel</span></td>
<td width="29" bgcolor="#eff6ff" class="style6"><strong>
<label>
<input name="c23" type="checkbox" id="c23" value="checkbox" />
</label>
</strong></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Resort</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c24" type="checkbox" id="c24" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Chalet</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c25" type="checkbox" id="c25" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Budget Hotel</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c26" type="checkbox" id="c26" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6"><span class="style5">Apartment</span></td>
<td bgcolor="#eff6ff" class="style6"><input name="c27" type="checkbox" id="c27" value="checkbox" /></td>
</tr>
<tr>
<td bgcolor="#eff6ff" class="style6">Hotel &amp; Spa </td>
<td bgcolor="#eff6ff" class="style6"><input name="cc28" type="checkbox" id="cc28" value="checkbox" /></td>
</tr>

</table></th>
</tr>
<tr>
<th align="left" scope="row"><input type="submit" name="Submit" value="Submit" id="Submit" /></th>
</tr>
<tr>
<th height="16" align="left" bgcolor="#299ad4" scope="row"><label for="Submit"></label></th>
</tr>
</table>
</div>

</form>

Nightwalker83
Oct 24th, 2009, 08:09 PM
Does this help?
http://www.vbforums.com/showthread.php?t=588734

Edit:

Please use code tags for your code!

Example:


Code here


To use the tags to wrap the code:

Click the "Post Reply" button.

In edit view you will see a toolbar with several icon such as http://www.vbforums.com/images/editor/php.gif
to use them on you link or code just select the code or link and press one of those icons

kows
Oct 24th, 2009, 11:56 PM
you could just type and around your code instead. however, everything he posted was HTML, so I'd suggest and tags instead.

anyway, you've only posted HTML. post your PHP attempts if you'd like some help.

mizz_aurora
Oct 25th, 2009, 06:48 PM
sorry to everyone
i forgot to type the tags
now, it has been edited

mizz_aurora
Oct 25th, 2009, 06:50 PM
kows, i am beginner in php.
i do not know how to code for this section
are you willing to help me?

Nightwalker83
Oct 25th, 2009, 07:04 PM
kows, i am beginner in php.
i do not know how to code for this section
are you willing to help me?

Check the link in the first post I posted.

kows
Oct 25th, 2009, 08:10 PM
if he doesn't know any PHP, linking him to a script that doesn't do what he wants isn't going to help ;)

anyway, if you don't know any PHP, I suggest you look for a tutorial on Google or from W3Schools that can teach you a little about handling forms and interacting with a database. there are plenty out there, I just won't do all of it for you if you haven't put any effort into it.