Jump to content

[SOLVED] auto checked unchecked boxes and change the values of the auto checked boxes


hamzatki

Recommended Posts

I have a query that populate the result of a quick search, I have added a checkbox to allow the user to select most suitable options out of the list of the result.

<?php
// displaying properties 

include "connect.php";

// $sql1 = "select * from property where area='$area' && price_range='$price' &&
// property_type='$property_type' && no_bedrms='$bedrooms' && no_bathrms='$bathrooms'";

$sql1 = "select * from property where area='$area' && price_range='$price' &&  property_type='$property_type'";

$result1 = mysql_query($sql1);
if (!$result1)
    {
echo "<center><font color='red'>Query Error</font><br><br> Error Selecting Entries !</center>";
    }
else

{

while ($row=mysql_fetch_array($result1))
{
$id = $row["id"]; $area1 = $row["area"]; $price_range = $row["price_range"]; $property_type = $row["property_type"]; $no_bedrms = $row["no_bedrms"]; $no_bathrms = $row["no_bathrms"]; $comments = $row["comments"]; $email = $row["email"];  $prop_id = $row["prop_id"]; $mode = $row["mode"]; $bus_name = $row["bus_name"]; 




if (!$area1 == "") 

{
echo "

<tr>
      <td width='100%' height='' bgcolor='ffffff' align=''>

<table border='0' width='100%'>
<form action='search_prop1.php' method='post'>
<tr bgcolor='e6e6e6'>
<td valign='top' class='txt_cont_gris' width='20%'>Property Type : <img src='uploads/news_img.jpg' width='38' height='36' alt='' border='1'></td><td valign='top' class='txt_cont_gris'><font color='Maroon'><b>$property_type</b></font>     for <font color='Maroon'><b>$mode 
<div align='right'>
$bus_name         
<input type='checkbox' name='prop_id[]' size='4' value='$prop_id' class='text'>Contact Agents</div></b></font></td>
</tr>

<tr bgcolor='e6e6e6'>
<td valign='top' class='txt_cont_gris' width='20%'>No. of Bedrooms : </td><td valign='top' class='txt_cont_gris'><b>$no_bedrms</b></td>
</tr>

<tr bgcolor='e6e6e6'>
<td valign='top' class='txt_cont_gris' width='20%'>No. of Bathrooms : </td><td valign='top' class='txt_cont_gris'><b><b></b>$no_bathrms</b></td>
</tr>

<tr bgcolor='e6e6e6'>
<td valign='top' class='txt_cont_gris' width='20%'>Area Located : </td><td valign='top' class='txt_cont_gris'><b>$area1</b></td>
</tr>

<tr bgcolor='e6e6e6'>
<td valign='top' class='txt_cont_gris' width='20%'>Price Range : </td><td valign='top' class='txt_cont_gris'><font color='Maroon'><b>$price_range</b></font></td>
</tr>

<tr bgcolor='e6e6e6'>
<td valign='top' class='txt_cont_gris' width='20%'>More Details : </td><td valign='top' class='txt_cont_gris'>
$comments</td>
</tr>

<tr bgcolor=''>
<td valign='top' height='5' class='txt_cont_gris' width='20%'></td><td valign='top' class='text' align='center'>
<!-- <hr color='8d977e'  width='250'> -->
</td>
</tr>

</table>
      </td>

   </tr>

<input type='hidden' name='property_type[]' value='$property_type'>
<input type='hidden' name=' value='$mode'>
<input type='hidden' name='price_range[]' value='$price_range'>
<input type='hidden' name='email[]' value='$email'>
<input type='hidden' name='area1[]' value='$area1'>


 

 

My main problem here is that if six records are displayed and my user selected 3, it will pass 6 set of 'property_type', 'mode', 'price_range', 'email' and area1 with 3 set of checked 'prop_id' this make it difficult for me to know which prop_id belong to which other fields.

 

This is what i am getting for now:

 

property_type----> Flat, Flat, Flat, Flat, Flat, Flat

 

mode---> sell, rent, rent, sell, sell, sell

 

price_range---> N2000000 or more, N2000000 or more, N2000000 or more, N2000000 or more, N2000000 or more, N2000000 or more

 

emai---> gunmi@ayedun.com, bunmi@ayedun.com, sam@yahoo.com, funmi@ayedun.com, sam@yahoo.com, sam@yahoo.com

 

area1---> Apapa, Apapa, Apapa, Apapa, Apapa, Apapa

 

prop_id---> funmi@ayedun.com1170175019, sam@yahoo.com1170174365, sam@yahoo.com1170174329

 

And this is what I want :-

 

property_type----> Flat, Flat, Flat, Flat, Flat, Flat

 

mode---> sell, rent, rent, sell, sell, sell

 

price_range---> N2000000 or more, N2000000 or more, N2000000 or more, N2000000 or more, N2000000 or more, N2000000 or more

 

emai---> gunmi@ayedun.com, bunmi@ayedun.com, sam@yahoo.com, funmi@ayedun.com, sam@yahoo.com, sam@yahoo.com

 

area1---> Apapa, Apapa, Apapa, Apapa, Apapa, Apapa

 

prop_id--->funmi@ayedun.com1170175019,' none', sam@yahoo.com1170174365, ' none',sam@yahoo.com1170174329, 'none '

 

 

Link to comment
Share on other sites

The only input you need from your form are the checkbox id values to show which properties the user is interested in. The other items are "display only".

 

When the form is submitted

<?php
$id_list = join ("','", $_POST['prop_id']);
?>

 

You then query your db for the info on those properties

 

SELECT * FROM property

WHERE prop_id IN ('$id_list');

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.