Dear,

I want to select 3 option for search,there are only 2 term

$term = $_POST['searchterm'];
$term = $_POST['searchterm'];
$term = $_POST['searchterm'];



$sql = mysql_query("SELECT * FROM entry WHERE wre LIKE '%".$_POST['searchterm']."%' && searchterm LIKE '%".$_POST['searchterm']."%' && searchterm LIKE '%".$_POST['searchterm']."%'");

Please help me

The SQL would look something like this:

"SELECT * FROM table WHERE wkno LIKE '%".$_POST['searchterm']."%' OR year LIKE '%".$_POST['searchterm']."%'"

try:

<!-- make sure you put the [] at the end of the name -->
<input name="searchterm[]" />
<input name="searchterm[]" />
<input name="searchterm[]" />

then try:

<?php
//connect to the db first
$conn=mysql_connect('...', '...', '...') or die(mysql_error());
mysql_select_db('...') or die(mysql_error());


foreach($_POST['searchterm'] as $i=>$v)
{
  if(preg_match('#\w#',$v))
  {
    $_POST['searchterm'][$i]=mysql_real_escape_string($v);
  }
  else
  {
    unset($_POST['searchterm'][$i]);
  }
}
$term = implode("%' OR `searchterm` LIKE %'", $_POST['searchterm']);



$sql = mysql_query("SELECT * FROM entry WHERE `wre` LIKE '%" . $term ."%'" or die(mysql_error());
...
?>

There was some problem on the result page,


I give you all details on below:


1. search.php

<html>
    <head>
        <title>Search the Database</title>
    </head>
	
 
    <body>
	
 <center>
    <form action="searching+.php" method="post"><br />
	<table width="200%" border="0" cellspacing="4" cellpadding="10">
	<tr>
     <td><label>Enter Name:</label> <select name="name[]" style="border:1px solid #999999"><option value="">Select Names</option><option>Pink</option><option>Jhon</option><option>Foysal</option><option>Aparna</option></select></label><br /></td>
     </tr>
	 <tr>
	   <td><label>Enter Year</label><label><select name="year[]" style="border:1px solid #999999"><option value="">Select Year</option><option>2000</option><option>2001</option><option>2002</option><option>2003</option><option>2004</option><option>2005</option><option>2006</option><option>2007</option><option>2008</option><option>2009</option><option>2010</option><option>2011</option><option>2012</option></select></label><br />  </td>
     </tr>
	 <tr>
	   <td><label>Enter Month</label><label><select name="month[]" style="border:1px solid #999999"><option value="">Select Mounth</option><option>January</option><option>February</option><option>March</option><option>April</option><option>May</option><option>June</option><option>July</option><option>August</option><option>September</option><option>Octobar</option><option>November</option><option>December</option></select></label><br />  </td>
     </tr>
	 <tr>
     <td><input type="submit" name="submit" value="SEARCH" /></td>
     </tr>
    </table>
	</form>
	</center>
	
   
 
    </body>
</html>

When I select those option for serch and press submit button, I want to show all
field

3. searching+.php

<?php
   
      //connect to the db first
   
        mysql_connect ("localhost","root","") or die (mysql_error());
		mysql_select_db ("birth");
   
       
   
       
   
      foreach($_POST['name'] as $i=>$v)
   
  
      {
   
      if(preg_match('#\w#',$v))
  
      {
  
      $_POST['year'][$i]=mysql_real_escape_string($v);
  
      }
  
      else
  
      {
  
      unset($_POST['month'][$i]);
  
      }
  
      }
  
      $term = implode("%' OR `species` LIKE %'", $_POST['species']);
  
       
  
       
  
       
  
      $sql = mysql_query("SELECT * FROM entry WHERE `wre` LIKE '%" . $term ."%'" or die(mysql_error());
  
      
echo "<table border='.1' width = '100%'>
<tr>

<th>Day</th>
<th>Month</th>
<th>Year</th>
<th>Name</th>
<th>Birthing Piriod</th>
<th>CR</th>
<th>WT</th>
<th>CSECG</th>
<th>Hightide</th>
<th>BHTAHT</th>
<th>Weather</th>

</tr>
</center>";

while ($row = mysql_fetch_array($sql))
  {
    echo"<center>";
    echo "<td>" .$row['id'] 	."</td>";
	echo "<td>" .$row['day']."</td>";
	echo "<td>" .$row['month']."</td>";
	echo "<td>" .$row['year']."</td>";
        echo "<td>" .$row['name']."</td>";
	echo "<td>" .$row['birthing']."</td>";
	echo "<td>" .$row['cr']."</td>";
	echo "<td>" .$row['wt']."</td>";
	echo "<td>" .$row['csecg']."</td>";
	echo "<td>" .$row['hightide']."</td>";
	echo "<td>" .$row['bhtaht']."</td>";
	echo "<td>" .$row['weather']."</td>";
	    echo "</tr>";
    echo"</center>";
    }
echo "</table>";
  
      ?>

I want to show all field on with this design


Please help me immediately

try:

<!-- make sure you put the [] at the end of the name -->
<input name="searchterm[]" />
<input name="searchterm[]" />
<input name="searchterm[]" />

then try:

<?php
//connect to the db first
$conn=mysql_connect('...', '...', '...') or die(mysql_error());
mysql_select_db('...') or die(mysql_error());


foreach($_POST['searchterm'] as $i=>$v)
{
  if(preg_match('#\w#',$v))
  {
    $_POST['searchterm'][$i]=mysql_real_escape_string($v);
  }
  else
  {
    unset($_POST['searchterm'][$i]);
  }
}
$term = implode("%' OR `searchterm` LIKE %'", $_POST['searchterm']);



$sql = mysql_query("SELECT * FROM entry WHERE `wre` LIKE '%" . $term ."%'" or die(mysql_error());
...
?>
Member Avatar for diafol

Urgh - use code tags - difficult to follow

There was some problem on the result page,


I give you all details on below:


1. search.php

<html>
<head>
<title>Search the Database</title>
</head>


<body>

<center>
<form action="searching+.php" method="post"><br />
<table width="200%" border="0" cellspacing="4" cellpadding="10">
<tr>
<td><label>Enter Name:</label> <select name="name[]" style="border:1px solid #999999"><option value="">Select Names</option><option>Pink</option><option>Jhon</option><option>Foysal</option><option>Aparna</option></select></label><br /></td>
</tr>
<tr>
<td><label>Enter Year</label><label><select name="year[]" style="border:1px solid #999999"><option value="">Select Year</option><option>2000</option><option>2001</option><option>2002</option><option>2003</option><option>2004</option><option>2005</option><option>2006</option><option>2007</option><option>2008</option><option>2009</option><option>2010</option><option>2011</option><option>2012</option></select></label><br /> </td>
</tr>
<tr>
<td><label>Enter Month</label><label><select name="month[]" style="border:1px solid #999999"><option value="">Select Mounth</option><option>January</option><option>February</option><option>March</option><option>April</option><option>May</option><option>June</option><option>July</option><option>August</option><option>September</option><option>Octobar</option><option>November</option><option>December</option></select></label><br /> </td>
</tr>
<tr>
<td><input type="submit" name="submit" value="SEARCH" /></td>
</tr>
</table>
</form>
</center>



</body>
</html>

When I select those option for serch and press submit button, I want to show all
field

3. searching+.php

<?php

//connect to the db first

mysql_connect ("localhost","root","") or die (mysql_error());
mysql_select_db ("birth");





foreach($_POST['name'] as $i=>$v)


{

if(preg_match('#\w#',$v))

{

$_POST['year'][$i]=mysql_real_escape_string($v);

}

else

{

unset($_POST['month'][$i]);

}

}

$term = implode("%' OR `name` LIKE %'", $_POST['name']);







$sql = mysql_query("SELECT * FROM entry WHERE `wre` LIKE '%" . $term ."%'" or die(mysql_error());


echo "<table border='.1' width = '100%'>
<tr>

<th>Day</th>
<th>Month</th>
<th>Year</th>
<th>Name</th>
<th>Birthing Piriod</th>
<th>CR</th>
<th>WT</th>
<th>CSECG</th>
<th>Hightide</th>
<th>BHTAHT</th>
<th>Weather</th>

</tr>
</center>";

while ($row = mysql_fetch_array($sql))
{
echo"<center>";
echo "<td>" .$row['id'] ."</td>";
echo "<td>" .$row['day']."</td>";
echo "<td>" .$row['month']."</td>";
echo "<td>" .$row['year']."</td>";
echo "<td>" .$row['name']."</td>";
echo "<td>" .$row['birthing']."</td>";
echo "<td>" .$row['cr']."</td>";
echo "<td>" .$row['wt']."</td>";
echo "<td>" .$row['csecg']."</td>";
echo "<td>" .$row['hightide']."</td>";
echo "<td>" .$row['bhtaht']."</td>";
echo "<td>" .$row['weather']."</td>";
echo "</tr>";
echo"</center>";
}
echo "</table>";

?>

I want to show all field on with this design


Please help me immediately


Urgh - use code tags - difficult to follow

Member Avatar for diafol

Please help me immediately

Yes sir!
I take it this is a problem with language, rather that an imperative.

USE [ CODE ] tags!

There was some problem on the result page,...

You mean syntax problem? I noticed that you have <select name="name[]"...>. What field on the db should be searched when this list is selected? On your posts I keep seeing SELECT * FROM entry WHERE 'wre' LIKE. Do you really have a field name wre?

Also, change ALL your:
<option>XXX</option> to <option value="XXX">XXX</option>

I take it this is a problem with language, rather that an imperative.

Assuming you are correct about that, all I have to say is "LOL".

save the code below as a single file named hielo.php and try it:

<?php
$SELF=basename(__FILE__);
?>
<html>
<head>
<title>Search the Database</title>
<style type="text/css">
form{display:block; text-align:center;}
table#dbSearch{border:3px double black;width:50%;margin:0 auto;text-align:left;}
table#dbSearch tbody tr td{padding:.5em 0px;border-bottom:3px double black;}
label{display:block;width:45%;text-align:right;float:left;font-weight:bold;}
select{border:1px solid #999999;}
option{min-width:10em;}
td.buttonContainer{text-align:center;border-bottom:0px solid black !important;}

table#dbResult{border:3px double black;width:90%;margin:0 auto;text-align:left;}
</style>
</head>
<body>
<form action="<?php echo $SELF; ?>" method="post">
<table id="dbSearch">
	<tbody>
		<tr>
			<td>
				<label for="name">Enter Name:</label>
				<select id="name" name="searchterm[0]">
                    <option value="">Select Names</option>
                    <option value="Pink">Pink</option>
                    <option value="Jhon">Jhon</option>
                    <option value="Foysal">Foysal</option>
                    <option value="Aparna">Aparna</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>
				<label for="year">Enter Year:</label>
				<select id="year" name="searchterm[1]">
                    <option value="">Select Year</option>
                    <option value="2000">2000</option>
                    <option value="2001">2001</option>
                    <option value="2002">2002</option>
                    <option value="2003">2003</option>
                    <option value="2004">2004</option>
                    <option value="2005">2005</option>
                    <option value="2006">2006</option>
                    <option value="2007">2007</option>
                    <option value="2008">2008</option>
                    <option value="2009">2009</option>
                    <option value="2010">2010</option>
                    <option value="2011">2011</option>
                    <option value="2012">2012</option>
               </select>
			</td>
		</tr>
		<tr>
			<td>
				<label for="month">Enter Month:</label>
				<select id="month" name="searchterm[2]">
					<option value="">Select Month</option>
                    <option value="January">January</option>
                    <option value="February">February</option>
                    <option value="March">March</option>
                    <option value="April">April</option>
                    <option value="May">May</option>
                    <option value="June">June</option>
                    <option value="July">July</option>
                    <option value="August">August</option>
                    <option value="September">September</option>
                    <option value="Octobar">Octobar</option>
                    <option value="November">November</option>
                    <option value="December">December</option>					
				</select>
			</td>
		</tr>
		<tr>
			<td class="buttonContainer"><input type="submit" name="Submit" value="SEARCH" /></td>
		</tr>
	</tbody>
</table>
<?php
if(isset($_POST['Submit']) && 'SEARCH'==$_POST['Submit'])
{
	$searchOptions=array('0'=>'name','1'=>'year','2'=>'month');
	mysql_connect('localhost','root','...') or die(mysql_error());
	mysql_select_db('birth') or die(mysql_error());
	foreach($_POST['searchterm'] as $index=>$value)
	{
		if(empty($value))
		{
			unset($_POST['searchterm'][$index]);
		}
		else
		{
			// LIKE search
			$_POST['searchterm'][$index]=sprintf("(`%s` LIKE '%%%s%%')",$searchOptions[$index], mysql_real_escape_string($value) );

			// EQUAL search
			//$_POST['searchterm'][$index]=sprintf("(`%s`='%s')",$searchOptions[$index], mysql_real_escape_string($value) );

		}
	}
	
	//OR search
	$sql='SELECT * FROM `entry` WHERE '.implode(' OR ',$_POST['searchterm']);
	
	//AND search
	//$sql='SELECT * FROM `entry` WHERE '.implode(' AND ',$_POST['searchterm']);

	$result=mysql_query($sql) or die(mysql_error());
	$total=mysql_num_rows($result);
	if(0==$total)
	{
		echo '<p>No results found.</p>';
	}
	else
	{
		$row=mysql_fetch_assoc($result);
		echo '<p>Total items found:',$total,'</p>';
		echo '<table id="dbResult"><thead><tr><th>',implode( '</th><th>',array_keys($row) ),'</th></tr></thead><tbody>';
		do{
			echo '<tr><td>',implode('</td><td>',$row),'</td></tr>';
		}while($row=mysql_fetch_assoc($result));
		echo '</tbody></table>';
	}
}
?>
</form>
</body>
</html>

Its not gonna work, make another sollution


save the code below as a single file named hielo.php and try it:

<?php
$SELF=basename(__FILE__);
?>
<html>
<head>
<title>Search the Database</title>
<style type="text/css">
form{display:block; text-align:center;}
table#dbSearch{border:3px double black;width:50%;margin:0 auto;text-align:left;}
table#dbSearch tbody tr td{padding:.5em 0px;border-bottom:3px double black;}
label{display:block;width:45%;text-align:right;float:left;font-weight:bold;}
select{border:1px solid #999999;}
option{min-width:10em;}
td.buttonContainer{text-align:center;border-bottom:0px solid black !important;}

table#dbResult{border:3px double black;width:90%;margin:0 auto;text-align:left;}
</style>
</head>
<body>
<form action="<?php echo $SELF; ?>" method="post">
<table id="dbSearch">
	<tbody>
		<tr>
			<td>
				<label for="name">Enter Name:</label>
				<select id="name" name="searchterm[0]">
                    <option value="">Select Names</option>
                    <option value="Pink">Pink</option>
                    <option value="Jhon">Jhon</option>
                    <option value="Foysal">Foysal</option>
                    <option value="Aparna">Aparna</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>
				<label for="year">Enter Year:</label>
				<select id="year" name="searchterm[1]">
                    <option value="">Select Year</option>
                    <option value="2000">2000</option>
                    <option value="2001">2001</option>
                    <option value="2002">2002</option>
                    <option value="2003">2003</option>
                    <option value="2004">2004</option>
                    <option value="2005">2005</option>
                    <option value="2006">2006</option>
                    <option value="2007">2007</option>
                    <option value="2008">2008</option>
                    <option value="2009">2009</option>
                    <option value="2010">2010</option>
                    <option value="2011">2011</option>
                    <option value="2012">2012</option>
               </select>
			</td>
		</tr>
		<tr>
			<td>
				<label for="month">Enter Month:</label>
				<select id="month" name="searchterm[2]">
					<option value="">Select Month</option>
                    <option value="January">January</option>
                    <option value="February">February</option>
                    <option value="March">March</option>
                    <option value="April">April</option>
                    <option value="May">May</option>
                    <option value="June">June</option>
                    <option value="July">July</option>
                    <option value="August">August</option>
                    <option value="September">September</option>
                    <option value="Octobar">Octobar</option>
                    <option value="November">November</option>
                    <option value="December">December</option>					
				</select>
			</td>
		</tr>
		<tr>
			<td class="buttonContainer"><input type="submit" name="Submit" value="SEARCH" /></td>
		</tr>
	</tbody>
</table>
<?php
if(isset($_POST['Submit']) && 'SEARCH'==$_POST['Submit'])
{
	$searchOptions=array('0'=>'name','1'=>'year','2'=>'month');
	mysql_connect('localhost','root','...') or die(mysql_error());
	mysql_select_db('birth') or die(mysql_error());
	foreach($_POST['searchterm'] as $index=>$value)
	{
		if(empty($value))
		{
			unset($_POST['searchterm'][$index]);
		}
		else
		{
			// LIKE search
			$_POST['searchterm'][$index]=sprintf("(`%s` LIKE '%%%s%%')",$searchOptions[$index], mysql_real_escape_string($value) );

			// EQUAL search
			//$_POST['searchterm'][$index]=sprintf("(`%s`='%s')",$searchOptions[$index], mysql_real_escape_string($value) );

		}
	}
	
	//OR search
	$sql='SELECT * FROM `entry` WHERE '.implode(' OR ',$_POST['searchterm']);
	
	//AND search
	//$sql='SELECT * FROM `entry` WHERE '.implode(' AND ',$_POST['searchterm']);

	$result=mysql_query($sql) or die(mysql_error());
	$total=mysql_num_rows($result);
	if(0==$total)
	{
		echo '<p>No results found.</p>';
	}
	else
	{
		$row=mysql_fetch_assoc($result);
		echo '<p>Total items found:',$total,'</p>';
		echo '<table id="dbResult"><thead><tr><th>',implode( '</th><th>',array_keys($row) ),'</th></tr></thead><tbody>';
		do{
			echo '<tr><td>',implode('</td><td>',$row),'</td></tr>';
		}while($row=mysql_fetch_assoc($result));
		echo '</tbody></table>';
	}
}
?>
</form>
</body>
</html>

Its not gonna work, It was showing all information on the database , I want only search criteria related information and want to show the field that is related to search term.

Please make it quickly.

save the code below as a single file named hielo.php and try it:

<?php
$SELF=basename(__FILE__);
?>
<html>
<head>
<title>Search the Database</title>
<style type="text/css">
form{display:block; text-align:center;}
table#dbSearch{border:3px double black;width:50%;margin:0 auto;text-align:left;}
table#dbSearch tbody tr td{padding:.5em 0px;border-bottom:3px double black;}
label{display:block;width:45%;text-align:right;float:left;font-weight:bold;}
select{border:1px solid #999999;}
option{min-width:10em;}
td.buttonContainer{text-align:center;border-bottom:0px solid black !important;}

table#dbResult{border:3px double black;width:90%;margin:0 auto;text-align:left;}
</style>
</head>
<body>
<form action="<?php echo $SELF; ?>" method="post">
<table id="dbSearch">
	<tbody>
		<tr>
			<td>
				<label for="name">Enter Name:</label>
				<select id="name" name="searchterm[0]">
                    <option value="">Select Names</option>
                    <option value="Pink">Pink</option>
                    <option value="Jhon">Jhon</option>
                    <option value="Foysal">Foysal</option>
                    <option value="Aparna">Aparna</option>
				</select>
			</td>
		</tr>
		<tr>
			<td>
				<label for="year">Enter Year:</label>
				<select id="year" name="searchterm[1]">
                    <option value="">Select Year</option>
                    <option value="2000">2000</option>
                    <option value="2001">2001</option>
                    <option value="2002">2002</option>
                    <option value="2003">2003</option>
                    <option value="2004">2004</option>
                    <option value="2005">2005</option>
                    <option value="2006">2006</option>
                    <option value="2007">2007</option>
                    <option value="2008">2008</option>
                    <option value="2009">2009</option>
                    <option value="2010">2010</option>
                    <option value="2011">2011</option>
                    <option value="2012">2012</option>
               </select>
			</td>
		</tr>
		<tr>
			<td>
				<label for="month">Enter Month:</label>
				<select id="month" name="searchterm[2]">
					<option value="">Select Month</option>
                    <option value="January">January</option>
                    <option value="February">February</option>
                    <option value="March">March</option>
                    <option value="April">April</option>
                    <option value="May">May</option>
                    <option value="June">June</option>
                    <option value="July">July</option>
                    <option value="August">August</option>
                    <option value="September">September</option>
                    <option value="Octobar">Octobar</option>
                    <option value="November">November</option>
                    <option value="December">December</option>					
				</select>
			</td>
		</tr>
		<tr>
			<td class="buttonContainer"><input type="submit" name="Submit" value="SEARCH" /></td>
		</tr>
	</tbody>
</table>
<?php
if(isset($_POST['Submit']) && 'SEARCH'==$_POST['Submit'])
{
	$searchOptions=array('0'=>'name','1'=>'year','2'=>'month');
	mysql_connect('localhost','root','...') or die(mysql_error());
	mysql_select_db('birth') or die(mysql_error());
	foreach($_POST['searchterm'] as $index=>$value)
	{
		if(empty($value))
		{
			unset($_POST['searchterm'][$index]);
		}
		else
		{
			// LIKE search
			$_POST['searchterm'][$index]=sprintf("(`%s` LIKE '%%%s%%')",$searchOptions[$index], mysql_real_escape_string($value) );

			// EQUAL search
			//$_POST['searchterm'][$index]=sprintf("(`%s`='%s')",$searchOptions[$index], mysql_real_escape_string($value) );

		}
	}
	
	//OR search
	$sql='SELECT * FROM `entry` WHERE '.implode(' OR ',$_POST['searchterm']);
	
	//AND search
	//$sql='SELECT * FROM `entry` WHERE '.implode(' AND ',$_POST['searchterm']);

	$result=mysql_query($sql) or die(mysql_error());
	$total=mysql_num_rows($result);
	if(0==$total)
	{
		echo '<p>No results found.</p>';
	}
	else
	{
		$row=mysql_fetch_assoc($result);
		echo '<p>Total items found:',$total,'</p>';
		echo '<table id="dbResult"><thead><tr><th>',implode( '</th><th>',array_keys($row) ),'</th></tr></thead><tbody>';
		do{
			echo '<tr><td>',implode('</td><td>',$row),'</td></tr>';
		}while($row=mysql_fetch_assoc($result));
		echo '</tbody></table>';
	}
}
?>
</form>
</body>
</html>

make another sollution

Please make it quickly.

sorry no time maybe next week

Please make another solution

commented: Show some effort. -3
commented: What he said... :( -3
<?php
    $SELF=basename(__FILE__);
    ?>
    <html>
    <head>
    <title>Search the Database</title>
    <style type="text/css">
    form{display:block; text-align:center;}
    table#dbSearch{border:3px double black;width:50%;margin:0 auto;text-align:left;}
    table#dbSearch tbody tr td{padding:.5em 0px;border-bottom:3px double black;}
    label{display:block;width:45%;text-align:right;float:left;font-weight:bold;}
    select{border:1px solid #999999;}
    option{min-width:10em;}
    td.buttonContainer{text-align:center;border-bottom:0px solid black !important;}
     
    table#dbResult{border:3px double black;width:90%;margin:0 auto;text-align:left;}
    </style>
    </head>
    <body>
    <form action="<?php echo $SELF; ?>" method="post">
    <table id="dbSearch">
    <tbody>
    <tr>
    <td>
    <label for="name">Enter Name:</label>
    <select id="name" name="searchterm[0]">
    <option value="">Select Names</option>
    <option value="Pink">Pink</option>
    <option value="Jhon">Jhon</option>
    <option value="Foysal">Foysal</option>
    <option value="Aparna">Aparna</option>
    </select>
    </td>
    </tr>
    <tr>
    <td>
    <label for="year">Enter Year:</label>
    <select id="year" name="searchterm[1]">
    <option value="">Select Year</option>
    <option value="2000">2000</option>
    <option value="2001">2001</option>
    <option value="2002">2002</option>
    <option value="2003">2003</option>
    <option value="2004">2004</option>
    <option value="2005">2005</option>
    <option value="2006">2006</option>
    <option value="2007">2007</option>
    <option value="2008">2008</option>
    <option value="2009">2009</option>
    <option value="2010">2010</option>
    <option value="2011">2011</option>
    <option value="2012">2012</option>
    </select>
    </td>
    </tr>
    <tr>
    <td>
    <label for="month">Enter Month:</label>
    <select id="month" name="searchterm[2]">
    <option value="">Select Month</option>
    <option value="January">January</option>
    <option value="February">February</option>
    <option value="March">March</option>
    <option value="April">April</option>
    <option value="May">May</option>
    <option value="June">June</option>
    <option value="July">July</option>
    <option value="August">August</option>
    <option value="September">September</option>
    <option value="Octobar">Octobar</option>
    <option value="November">November</option>
    <option value="December">December</option>
    </select>
    </td>
    </tr>
    <tr>
    <td class="buttonContainer"><input type="submit" name="Submit" value="SEARCH" /></td>
    </tr>
    </tbody>
    </table>
    <?php
    if(isset($_POST['Submit']) && 'SEARCH'==$_POST['Submit'])
    {
    $searchOptions=array('0'=>'name','1'=>'year','2'=>'month');
    mysql_connect('localhost','root','...') or die(mysql_error());
    mysql_select_db('birth') or die(mysql_error());
    foreach($_POST['searchterm'] as $index=>$value)
    {
    if(empty($value))
    {
    unset($_POST['searchterm'][$index]);
    }
    else
    {
    // LIKE search
    $_POST['searchterm'][$index]=sprintf("(`%s` LIKE '%%%s%%')",$searchOptions[$index], mysql_real_escape_string($value) );
     
    // EQUAL search
    //$_POST['searchterm'][$index]=sprintf("(`%s`='%s')",$searchOptions[$index], mysql_real_escape_string($value) );
     
    }
    }
     
    //OR search
    $sql='SELECT * FROM `entry` WHERE '.implode(' OR ',$_POST['searchterm']);
     
    //AND search
    //$sql='SELECT * FROM `entry` WHERE '.implode(' AND ',$_POST['searchterm']);
     
    $result=mysql_query($sql) or die(mysql_error());
    $total=mysql_num_rows($result);
    if(0==$total)
    {
    echo '<p>No results found.</p>';
    }
    else
    {
    $row=mysql_fetch_assoc($result);
    echo '<p>Total items found:',$total,'</p>';
    echo '<table id="dbResult"><thead><tr><th>',implode( '</th><th>',array_keys($row) ),'</th></tr></thead><tbody>';
    do{
    echo '<tr><td>',implode('</td><td>',$row),'</td></tr>';
    }while($row=mysql_fetch_assoc($result));
    echo '</tbody></table>';
    }
    }
    ?>
    </form>
    </body>
    </html>

In this code the output is all information on the database.


But I need only what I search That suppose  first: select PINK Second: 2008 Third: Select Month. then I want to view only pink releted information, not another name, and have to view all the row that is releted that name pink or aparna or foysal. I want individual search

Please make another solution

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.