Hi ALL
I have entered some array values using checkboxes into mysql database through a form. Next iam creating a searchpage where all those cateogories inserted through checkboxes has to be retrieved using list/menu box.
When i check only a single checkbox to insert the checked category ,selecting that category through list box gives out the entire data of the user corresponding to that category.
However when i check multiple checkboxes and in the category select all those checked values to find if any user fits in all those category and hence prompt the entire data corresponding to it,the column shows only 'array' and not array values. So please anyone guide me as how should i fetch all the checked categories through the list/menu box.
Here goes the edited code:
[PHP]
<?
$state=$_POST['state'];
$state = implode(",", $state);
$query="insert into consult (state)VALUES(' $state')";
mysql_query($qu ery);
?>
<form name="form" action="abc.php " method ="post">
<input name=state[0] type="checkbox" value="Air Conditioning Consultants & Contractors">Ai r Conditioning Consultants & Contractors
<input name=state[1] type="checkbox" value="Arbitrat ors" >Arbitrators
<input name=state[2] type="checkbox" value=Builders, Contractors & Developers>Buil ders,Contractor s & Developers
<input name=state[3] type="checkbox" value=Civil Engineers and Contactors>
Civil Engineers and Contactors
</form>
<input name="submit" type="submit" class="style40" value="Submit">
[/PHP]
[PHP]
<?php
if (isset($_POST['submit']))
{
$state=$_POST['state'];
$state=explode( ",",$state) ;
}
?>
<form name="form1" action="cons_sh ow.php" method="post" >
<select name="state">
<option selected >Select</option>
<option value="Air Conditioning Consultants & Contractors">Ai r Conditioning Consultants & Contractors</option>
<option value="Arbitrat ors">Arbitrator s</option>
<option value="Builders ,Contractors & Developers">Bui lders,Contracto rs & Developers</option>
<option value="Civil Engineers and Contractors">Ci vil Engineers and Contractors</option>
</form>
if(!isset($cmd) ) {
$state=$_POST['state'];
$query = @mysql_query("S ELECT * FROM consult where state='$state'" );
if (!$query)
{
exit('<p>Error retrieving entries from database!<br/>'.'Error: ' . mysql_error() . '</p>');
}
$sql = mysql_fetch_arr ay($query);
if($sql){
echo '<table width="90%" cellspacing="2" cellpadding="4" border="1"><tr> <td valign="top">
<table><tr><t d ><h4 ><u> Customer Information</u> </h4></td></tr></table>';
echo '<table cellpadding="4" ><tr><td ><b>Firm Name</b></td><td ><b>State</b></td><td><b>City</b></td>
<td><b>Contac t</b></td><td><b>Email Address</b></td></tr>';
$firm = $sql['firmname'];
$address = $sql['adress'];
$city= $sql['city'];
$pin=$sql['pin'];
$tel=$sql['tel'];
$fax=$sql['fax'];
$email=$sql['email'];
$state=$sql['state'];
echo "<tr><td><a href='cons_deta ils.php?cmd=edi t&STATE=$state' >$firm</a></td><td>$state</td><td>$city</td><td>$tel</td><td>$email</td>";
echo "<td>";
echo "</tr></table>";
}
else {
echo '<table ><tr><td>';
[/PHP]
This is how i have worked.but it is only useful for only a single checked data and cease to work on multiple checked data.
So if anyone ca help please do it.
Thanks and Regards
TechnoAtif
I have entered some array values using checkboxes into mysql database through a form. Next iam creating a searchpage where all those cateogories inserted through checkboxes has to be retrieved using list/menu box.
When i check only a single checkbox to insert the checked category ,selecting that category through list box gives out the entire data of the user corresponding to that category.
However when i check multiple checkboxes and in the category select all those checked values to find if any user fits in all those category and hence prompt the entire data corresponding to it,the column shows only 'array' and not array values. So please anyone guide me as how should i fetch all the checked categories through the list/menu box.
Here goes the edited code:
Code to insert the array values in mysql database using checkboxes
<?
$state=$_POST['state'];
$state = implode(",", $state);
$query="insert into consult (state)VALUES(' $state')";
mysql_query($qu ery);
?>
<form name="form" action="abc.php " method ="post">
<input name=state[0] type="checkbox" value="Air Conditioning Consultants & Contractors">Ai r Conditioning Consultants & Contractors
<input name=state[1] type="checkbox" value="Arbitrat ors" >Arbitrators
<input name=state[2] type="checkbox" value=Builders, Contractors & Developers>Buil ders,Contractor s & Developers
<input name=state[3] type="checkbox" value=Civil Engineers and Contactors>
Civil Engineers and Contactors
</form>
<input name="submit" type="submit" class="style40" value="Submit">
[/PHP]
Code to fetch those checked array values using list/menu box.
<?php
if (isset($_POST['submit']))
{
$state=$_POST['state'];
$state=explode( ",",$state) ;
}
?>
<form name="form1" action="cons_sh ow.php" method="post" >
<select name="state">
<option selected >Select</option>
<option value="Air Conditioning Consultants & Contractors">Ai r Conditioning Consultants & Contractors</option>
<option value="Arbitrat ors">Arbitrator s</option>
<option value="Builders ,Contractors & Developers">Bui lders,Contracto rs & Developers</option>
<option value="Civil Engineers and Contractors">Ci vil Engineers and Contractors</option>
</form>
if(!isset($cmd) ) {
$state=$_POST['state'];
$query = @mysql_query("S ELECT * FROM consult where state='$state'" );
if (!$query)
{
exit('<p>Error retrieving entries from database!<br/>'.'Error: ' . mysql_error() . '</p>');
}
$sql = mysql_fetch_arr ay($query);
if($sql){
echo '<table width="90%" cellspacing="2" cellpadding="4" border="1"><tr> <td valign="top">
<table><tr><t d ><h4 ><u> Customer Information</u> </h4></td></tr></table>';
echo '<table cellpadding="4" ><tr><td ><b>Firm Name</b></td><td ><b>State</b></td><td><b>City</b></td>
<td><b>Contac t</b></td><td><b>Email Address</b></td></tr>';
$firm = $sql['firmname'];
$address = $sql['adress'];
$city= $sql['city'];
$pin=$sql['pin'];
$tel=$sql['tel'];
$fax=$sql['fax'];
$email=$sql['email'];
$state=$sql['state'];
echo "<tr><td><a href='cons_deta ils.php?cmd=edi t&STATE=$state' >$firm</a></td><td>$state</td><td>$city</td><td>$tel</td><td>$email</td>";
echo "<td>";
echo "</tr></table>";
}
else {
echo '<table ><tr><td>';
[/PHP]
This is how i have worked.but it is only useful for only a single checked data and cease to work on multiple checked data.
So if anyone ca help please do it.
Thanks and Regards
TechnoAtif
Comment