here html code , php script, unable query data selected checkbox:
<code> search database using multiple options:<br /><br /> <form id="advanced_form" action="checkbox.php" enctype="multipart/form-data" method="post"> <input type="checkbox" name="checkbox1[]" value="1" /> location: projectid <input type="text" name="projectid" size="10" /> basesq30 <input type="text" name="start" size="10" /> <input type="text" name="end" size="10" /> <br /><br /> <input type="checkbox" name="checkbox1[]" value="2" /> platform: <select name="key4" onchange="settext(key4,word4)"> <option selected="selected" value="all">select</option> <option value="miseq">miseq</option> <option value="hiseq">hiseq</option> </select>.<br /><br /> <input type="checkbox" name="genotype" value="3" /> run no: <select multiple="multiple" name="checkbox1[]" size="5"> <option selected="selected" value= "2">2</option> <option value= "3">3</option> <option value= "4">4</option> <option value= "5">5</option> <option value= "6">6</option> </select> <center> <input type="reset" value="reset"> <input style="align: center;" type="submit" name="submit" value="search" /></center> </form> <?php /* attempt mysql server connection. assuming running mysql server default setting (user 'root' no password) */ $link = mysqli_connect("localhost", "root", "root123", "newdb"); // check connection if($link === false) { die("error: not connect. " . mysqli_connect_error()); } //code if(isset($_post['submit'])) { foreach($_post['checkbox1'] $checkbox1) //printf("%s<br>",$checkbox1); if($checkbox1==1) $text=$_post['projectid']; $a=$_post['start']; $b=$_post['end']; { $sql="select * qcdata project_id='$text' , bases_q30>='$a' , bases_q30<='$b'"; } if($checkbox1==2) { $value=$_post['key4']; $sql1="select * qcdata platform='$value'"; } } echo "$sql"; if($result = mysqli_query($link, $sql)) { if(mysqli_num_rows($result) > 0) { echo "<table align='left'>"; echo "<tr>"; echo "<th>sno</th>"; echo "<th>project_id</th>"; echo "<th>file_name</th>"; echo "<th>read_pair</th>"; echo "<th>total_bases</th>"; echo "<th>total_reads</th>"; echo "<th>bases_q20</th>"; echo "<th>bases_q30</th>"; echo "<th>average_read_length</th>"; echo "<th>readlength_range_min</th>"; echo "<th>readlength_range_max</th>"; echo "<th>quality_range_min</th>"; echo "<th>quality_range_max</th>"; echo "<th>phread_range_min</th>"; echo "<th>phread_range_max</th>"; echo "<th>gc_percentage</th>"; echo "<th>a</th>"; echo "<th>t</th>"; echo "<th>g</th>"; echo "<th>c</th>"; echo "<th>n</th>"; echo "<th>platform</th>"; echo "<th>run_no</th>"; echo "<th>creation_by</th>"; echo "<th>creation_date</th>"; echo "<th>last_modified</th>"; echo "</tr>"; while($row = mysqli_fetch_array($result)) { echo "<tr>"; echo "<td>" .$row['sno']. "</td>"; echo "<td>" .$row['project_id'] . "</td>"; echo "<td>" .$row['file_name']. "</td>"; echo "<td>" .$row['read_pair'] . "</td>"; echo "<td>" .$row['total_bases'] . "</td>"; echo "<td>" .$row['total_reads'] . "</td>"; echo "<td>" .$row['bases_q20'] . "</td>"; echo "<td>" .$row['bases_q30'] . "</td>"; echo "<td>" .$row['average_read_length'] . "</td>"; echo "<td>" .$row['readlength_range_min'] . "</td>"; echo "<td>" .$row['readlength_range_max'] . "</td>"; echo "<td>" .$row['quality_range_min'] . "</td>"; echo "<td>" .$row['quality_range_max'] . "</td>"; echo "<td>" .$row['phread_range_min'] . "</td>"; echo "<td>" .$row['phread_range_max'] . "</td>"; echo "<td>" .$row['gc_percentage'] . "</td>"; echo "<td>" .$row['a'] . "</td>"; echo "<td>" .$row['t'] . "</td>"; echo "<td>" .$row['g'] . "</td>"; echo "<td>" .$row['c'] . "</td>"; echo "<td>" .$row['n'] . "</td>"; echo "<td>" .$row['platform'] . "</td>"; echo "<td>" .$row['run_no'] . "</td>"; echo "<td>" .$row['creation_by'] . "</td>"; echo "<td>" .$row['creation_date'] . "</td>"; echo "<td>" .$row['last_modified'] . "</td>"; echo "</tr>"; } echo "</table>"; // close result set mysqli_free_result($result); } else{ echo "no records matching query found."; } } else { echo "error: not able execute $sql. " . mysqli_error($link); } // close connection mysqli_close($link); ?> </code>
i remove []'s name of checkbox.
Comments
Post a Comment