I have a table which is session, and has a session_id, another tables which are namespmember1, namespmember2, namespmember3
Everytime i save the form which has the session table, namespmember1, namespmember2, namespmember3. They are all save also. which there ID's are equal becuase they are save as batch.
my question is. i want to edit those tables or view... heres my code which is redundant and i guess there is a solution for it.
Im getting the ID for the session table.
$id = $_GET['id'];
$id = mysql_real_escape_string($id);
$q = mysql_query("SELECT * FROM session WHERE session_id='$id'");
$row = mysql_fetch_object($q);
And now i will display the tables namespmember1, namespmember2, namespmember3
<?php
$sql = mysql_query("SELECT * FROM namespmember1 WHERE hon1_id='$id'");
while ($row = mysql_fetch_object($sql))
{
echo "<tr>";
echo "<td>$row->spmember_name</td>";
echo "<td>$row->present</td>";
echo "<td>$row->absent</td>";
echo "<td>$row->leave_sick</td>";
echo "<td>$row->business</td>";
echo "</tr>";
}
$sql = mysql_query("SELECT * FROM namespmember2 WHERE hon2_id='$id'");
while ($row = mysql_fetch_object($sql))
{
echo "<tr>";
echo "<td>$row->spmember_name</td>";
echo "<td>$row->present</td>";
echo "<td>$row->absent</td>";
echo "<td>$row->leave_sick</td>";
echo "<td>$row->business</td>";
echo "</tr>";
}
$sql = mysql_query("SELECT * FROM namespmember3 WHERE hon3_id='$id'");
while ($row = mysql_fetch_object($sql))
{
echo "<tr>";
echo "<td>$row->spmember_name</td>";
echo "<td>$row->present</td>";
echo "<td>$row->absent</td>";
echo "<td>$row->leave_sick</td>";
echo "<td>$row->business</td>";
echo "</tr>";
}
?>
session_id is equal to all the ids in differnt tables namespmember1, namespmember2, namespmember3
Thank you for the help.