Hi all, I was wondering if I can get some help or be pointed in the right direction for my code.
I have a form that creates a query with the values from the checkboxes and the header/id of the cells from the checkbox name.
Although my coding works well, while trying get the fields sortable I can't seem to find a way to get the actual header/id into the proper cell. How would I go about using the array of header/id tag during the while and foreach to display the query and table information? I will list the code below for a better idea.
<?php
require_once('connections.php');
if (isset($_POST["chk_IsActive"]))
{
$completed="(IsActive='true' OR IsActive='false')";
}
else
{
$completed="(IsActive='true')";
}
$orderby=$_REQUEST['orderby'];
$insert_data="";
$insert_columns="";
$value="";
$column_name="";
foreach ($_POST as $varName => $value)
{
if (substr($varName, 0, 4) == "chk_")
{
if (substr($varName, strlen($value) -2, strlen($value)) == "_s")
{
$insert_data = "'" . $value . "'";
}
else
{
$insert_data .= $value.", ";
$newdata=substr($insert_data,0,-2);
$insert_columns .= '<th id='.substr($varName, 4, strlen($varName) -2).'><span>'.substr($varName, 4, strlen($varName) -2).'</span></th>';
$column_name=substr($varName, 4, strlen($varName) -2);
}
}
}
?>
<?php
$employeeinfo=mysql_query("SELECT $newdata FROM employee WHERE $completed ORDER BY $orderby");
$num_rows=mysql_num_rows($employeeinfo);
while ($rows=mysql_fetch_assoc($employeeinfo))
{
echo '<tr id="rows1">';
foreach ($rows as $display) //Create and Display Information from Checkboxes
{
echo '<th axis="string" [B][COLOR=DarkOrange]header="'.$column_name.'[/COLOR][/B]"><span>';
echo $display;
echo '</span></th>';
}
echo '</tr>';
}
echo '</th></tr>';
echo '</tbody></table>';
?>