Embed php code in HTML
Posted: Tue Apr 10, 2012 8:27 am
Hi!
I am new to PHP. I am trying to store array values in HTML table. For that I have written following code. Everything worked before I embedded php code. After I added php code I got an error HTTP 500 Internal Server error. Please help me.
Below is the code:
thanks for the help in advance
I am new to PHP. I am trying to store array values in HTML table. For that I have written following code. Everything worked before I embedded php code. After I added php code I got an error HTTP 500 Internal Server error. Please help me.
Below is the code:
Code: Select all
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<body>
Please select your desired states:
<br><br>
<?php
$state_list = array("AL"=>"Alabama","AK"=>Alaska");
?>
<form id=form1 >
<table id=myTable border=1>
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<?php foreach ($state_list as $row) { ?>
<tr>
<td><?php echo $row[0]; ?></td>
<td ><?php echo $row[1]; ?></td>
<td ><?php echo $row[2]; ?></td>
</tr>
<?php } ?>
</table>
<br>
<input type='submit' value='Save' onclick=" " />
</form>
</body>
</head>
</html>