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. I want to be able to automatically checked the unchecked boxes by the user and change the values that are on the auto checked boxes to something else before passing the form to the next page
<input type="checkbox" name="foo" value="1"<?php if ($row['foo']) echo ' checked="checked"'; ?> /> Code (markup):
Thanks but if you have not address my problems. One how do I know if the checkbox has been checked by the user. Two how do I changed the value="1" to somewthing else. Thanks
The problem is that I don't have your code, so I have to take a wild guess. And why would you want to change the value of a checkbox? It should always have the same value. You know that the checkbox has been checked if it has a key in the $_POST array. if (isset($_POST['your-form-field'])) { // Box has been checked } PHP: You could try something like this: <input type="checkbox" name="foo" value="1"<?php if (isset($_POST['foo'])) echo ' checked="checked"; ?> /> PHP: This is slightly different. If it doesn't work either, then post your code.
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---> , , , , , area1---> Apapa, Apapa, Apapa, Apapa, Apapa, Apapa prop_id---> 1170175019, 1170174365, 1170174329 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---> , , , , , area1---> Apapa, Apapa, Apapa, Apapa, Apapa, Apapa prop_id--->funmi@ayedun.com1170175019,' none', 1170174365, 'none ',sam@yahoo.com1170174329, ' none'