I create a table to display on a web page, and this table is populated with data from a MySQL database. I'm trying to do a couple of things that make it difficult for me.
First I try to call the PHP code that exists in a separate file in HTML via JavaScript. I think that it works for me correctly, but I'm not 100% sure (because the table will not be displayed). I think it works correctly, because some code of the table (which is in the PHP file) is displayed in FireBug .
Secondly, I'm trying to make the rows alternate colors for easy viewing. So far, my PHP code is below. The table is not displayed at all in any browser.
$query = "SELECT * FROM employees";
$result = mysql_query($query);
$num = mysql_num_rows($result);
echo '<table>';
for ($i = 0; $i < $num; $i++){
$row = mysql_fetch_array($result);
$id = $row['id'];
$l_name = $row['l_name'];
$f_name = $row['f_name'];
$ssn = $row['ssn'];
$class = (($i % 2) == 0) ? "table_odd_row" : "table_even_row";
echo "<tr>";
echo "<td class=" . $class . ">$wrap_id</td>";
echo "<td class=" . $class . ">$wrap_l_name</td>";
echo "<td class=" . $class . ">$wrap_f_name</td>";
echo "<td class=" . $class . ">$wrap_ssn</td>";
echo "</tr>";
}
echo '</table>';
mysql_close($link);
}
EDIT
To answer a few questions:
@controlfreak123, , "include ('filename_with_php_in_it')". , , . , , , FireBug , PHP, HTML PHP . PHP HTML , :
<script language="javascript" type="text/javascript" src="/Management/Employee_Management.php?action=Edit_Employee"></script>
@Matt S, , , - , FireBug , PHP ( ) HTML. , MySQL HTML- PHP. , employees , , . JavaScript, , , , HTML PHP , , , PHP- , JavaScript .
@, , (). HTML-.