I have multiple themes in my database and my query is to fetch the common info of these themes by selecting check boxes in php?
suppose there are four themes 'a', 'b', 'c' and 'd' I have separate tables too containing there common data i.e. a table of a intersect b, a intersect c and a intersect d and so on.
now what i have tried is first user have to select the theme form a drop box , then will select the multiple comparing themes using check box. When i check two themes it displays the data of last theme only.
<form method="GET" action="abc.php" name="form">
<font size = "4px", color = "#008C9A", align = "left"><b> Select Theme >> </b></font>
<select name ="table[]">
<option value="ab">a</option>
<option value="bc">b</option>
<option value="cd">c</option>
<br/>
<font size="4px" color="#008C9A" align="centre">
<b> Show Common Genes of Selected Theme with </b>
</font> <br/> <br/>
<input type="checkbox" name="search" value = "a"/>
<font color = "#2F4F4F"><b>a </b></font>
<input type="checkbox" name="search" value = "a"/>
<font color = "#2F4F4F"><b>b</b></font>
<input type="checkbox" name="search"/ value = "c">
<font color = "#2F4F4F"><b>c</b></font>
<input type= "submit" value= "Search" name="sub" />
</form>
can any one suggest me what should be my action.php?
i am trying this but it is giving no results:
<?php
require("config.php");
$table=$_POST['table'];
$search=$_POST['search'];
echo"<table border='0', width='1200', align='center'>
<tr>
<th bgcolor = '#2F4F4F' align = center><font color = '#fff'>Theme</font></th>
<th bgcolor = '#2F4F4F' align = center><font color = '#fff'>Id</font></th>
<th bgcolor = '#2F4F4F' align = center><font color = '#fff'>Symbol</font></th>
<th bgcolor = '#2F4F4F' align = center><font color = '#fff'>Name</font></th>
<th bgcolor = '#2F4F4F' align = center><font color = '#fff'>Synonyms</font></th>
<th bgcolor = '#2F4F4F' align = center><font color = '#fff'>Chromosome</font></th>
<th bgcolor = '#2F4F4F' align = center><font color = '#fff'>New_Id</font></th>
</tr>";
foreach($search as $key)
{
switch($key)
{
case"cancer":
$sql = mysql_query("select * from $table where theme = 'cancer'", $con);
$num_row=mysql_num_rows($sql);
for($i=0;$i<$num_row;$i++)
{
$result=mysql_fetch_assoc($sql);
echo"<tr bgcolor = '#EBDDE2'>";
echo"<td align=center><font color = 'purple'><b>" . $result['theme'] ."</b></font></td>";
$strName2 = $result["Locus_id"];
echo"<td align=center><font color = 'purple'><b>" . $result['id'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['symbol'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['name'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['Synonyms'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['Chromosome'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['new_id'] ."</b></font></td>";
echo"</tr>";
}
break;
case"diabetes":
$sql = mysql_query("select * from $table where theme = 'diabetes'", $con);
$num_row=mysql_num_rows($sql);
for($i=0;$i<$num_row;$i++)
{
$result=mysql_fetch_assoc($sql);
echo"<tr bgcolor = '#EBDDE2'>";
echo"<td align=center><font color = 'purple'><b>" . $result['theme'] ."</b></font></td>";
$strName2 = $result["Locus_id"];
echo"<td align=center><font color = 'purple'><b>" . $result['id'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['symbol'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['name'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['Synonyms'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['Chromosome'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['new_id'] ."</b></font></td>";
echo"</tr>";
}
}
break;
case"tubersulosis":
$sql = mysql_query("select * from $table where theme = 'tuberculosis'", $con);
$num_row=mysql_num_rows($sql);
for($i=0;$i<$num_row;$i++)
{
$result=mysql_fetch_assoc($sql);
echo"<tr bgcolor = '#EBDDE2'>";
echo"<td align=center><font color = 'purple'><b>" . $result['theme'] ."</b></font></td>";
$strName2 = $result["Locus_id"];
echo"<td align=center><font color = 'purple'><b>" . $result['id'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['symbol'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['name'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['Synonyms'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['Chromosome'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['new_id'] ."</b></font></td>";
echo"</tr>";
}
}
break;
case"hiv":
$sql = mysql_query("select * from $table where theme = 'HIV'", $con);
$num_row=mysql_num_rows($sql);
for($i=0;$i<$num_row;$i++)
{
$result=mysql_fetch_assoc($sql);
echo"<tr bgcolor = '#EBDDE2'>";
echo"<td align=center><font color = 'purple'><b>" . $result['theme'] ."</b></font></td>";
$strName2 = $result["Locus_id"];
echo"<td align=center><font color = 'purple'><b>" . $result['id'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['symbol'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['name'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['Synonyms'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['Chromosome'] ."</b></font></td>";
echo"<td align=center><font color = 'purple'><b>" . $result['new_id'] ."</b></font></td>";
echo"</tr>";
}
}
break;
}
}
mysql_close($con);
?>
b. you are using same value in first two checkboxes.