I'm a beginner in both PHP & MySql and I 've been working with the multiple checkboxes function for days. At first nothing seem to to work but nonetheless, it has finally given the result but I can't seem to create a table out of it
And here is the php page:
<?php
if(isset($_REQUEST['submit']))
{
$str = ' 1=1 ';
if( count($_POST['field']) > 0 )
{
$field = implode(',',$_POST['field']);
$str.= ' AND company_field LIKE '.$field.'';
}
if( count($_POST['size']) > 0 )
{
$size = implode(',',$_POST['size']);
$str.= ' AND company_size LIKE '.$size.'';
}
$run = "SELECT * FROM company WHERE 1=1 AND company_field LIKE '$field' AND company_size LIKE '$size'";
echo $run;
$result = mysql_query($run);
while ($row = mysql_fetch_array($result)){
$company_name = $row[0];
$company_field = $row[1];
$company_size = $row[2];
?>
<tr align = 'center'>
<th><?php echo $company_name; ?></th>
<td><?php echo $company_field; ?></td>
<td><?php echo $company_size; ?></td>
</tr>
<?php }?>
<?php } ?>
But I can't create a table and I don't know why.
msql_
functions, use the improved onemysqli_
and use prepared statements. link – user1978142 Jun 27 at 12:35