0

Hi all,

I am a beginner in using PHP. I have wrote a code that will retrieve the checkbox value after checking from database. Basically, it is a simple search where user has to check the value of checkbox in the form.It then will displaying the result after checking the checkbox that the user have check in database.

Another question, is there possible in php to do datagrid ? What are the steps that are require to do datagrid.


Hope anyone can help me with the problems.

Thank You

Attachments
<form name="form1" method="post" action="search_with_checkbox_proc.php"> <table width="100%" border="0" bgcolor="#D6E3F7">
<tr>
<td class="text">Your are Expertise field: </td>
</tr>
<tr>
<td class="examplelink">
<input type="checkbox" name="chkexpert[]" value="Java">
Java
<input type="checkbox" name="chkexpert[]" value="PHP">
PHP
<input type="checkbox" name="chkexpert[]" value="ASP">
ASP
<input type="checkbox" name="chkexpert[]" value=".NET">
.NET
<input type="checkbox" name="chkexpert[]" value="JavaScript">
JavaScript</td>


</tr>
<tr>
<td><p>
  <input type="submit" name="Submit" value="Submit">
</p>
  <p>
  
</p></td>
</tr>
<tr>

</tr>
<tr>
<td class="reditalic">&nbsp; </td>
</tr>
</table>
</form>
<?php

// 1. connect with mysql server
$conn = mysql_connect("localhost","root","");

// 2. select the database we will use
mysql_select_db("test_php",$conn);

$checkbox = $_POST['chkexpert'];





$result = mysql_query("select * from register where checkbox =('$checkbox')");

$resultArray = mysql_fetch_array($result, MYSQL_ASSOC);


if(isset($_POST['Submit']))
{
	echo "<h2> Result </h2>";
	
    for ($i=0; $i<count($_POST['chkexpert']);$i++) 
	{		
       //echo "<br />Result $i = ".$_POST['chkexpert'][$i];
	  
	  echo "<br /> ".$_POST['chkexpert'][$i];
    }

}


if($resultArray['chkexpert'] != $checkbox)
{
	echo "There is no record for your search selection";
}




?>
4
Contributors
4
Replies
5
Views
9 Years
Discussion Span
Last Post by R0bb0b
0

$checkbox = $_POST;
$result = mysql_query("select * from register where checkbox =('$checkbox')");

You can't do it this way. $checkbox is an array and your query will not return any rows.
You have to go through each element of the array (ie., $checkbox) and then use it in your query.
And I don't know what a datagrid is.

0

A datagrid is simply an html table, modified by css to look pretty and could have added functionality with javascript and ajax for autoupdates and what not. It just depends on what kind of functionality you would like to have in your datagrid.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.