I have a script below which use foreach to output value from database to textfield and textarea.However,the textfield and textarea all missing, what went wrong on it?Thanks...
<?php
include ('dbconn.cfg');// database configuration file
$connection = @mysql_connect("localhost", "root", "") or die("Cannot connect to server!");
?>
<html>
<title></title>
<head>
<body>
<h2><center>Member Profile</center></h2>
<table border = '1' cellpadding = '3' cellspacing = '2' style = 'background-color: #ADD8E6'>
<tr>
<th>Full Name</th>
<th>Telephone</th>
<th>Address</th>
</tr>
<tr>
<?
if (isset($_SESSION['gmembername']))
{
$tbl_name = "member";
$sql = "SELECT name,telephone,address FROM $tbl_name";
$result = @mysql_query($sql, $connection) or die("Cannot execute query.");
$numrow = mysql_num_rows($result);
if ($numrow != 0)
{// fetch each record in result set
for ($counter = 0; $row = mysql_fetch_row($result); $counter++)
{
foreach ($row as $key => $value)
{
if ($key == 0 && $key == 1)
{
?>
<td><input type ="text" size = "30" value = "<?php
echo $value; ?>" readonly = "readonly"></td>
<?php
}
else
{
if ($row == 2)
{
?>
<td><textarea rows = "3"><?php
echo $value; ?></textarea></td>
<?php
}
}
}
}
}
}
?>
</tr>
</table>
<table>
<tr>
<td> </td>
<td width='4%'> </td>
<td></tr>
<tr>
<td> </td>
<td width='4%'> </td>
<td><input type='submit' name='submit' value='Upgrade'></td>
</table>
</body>
</head>
</html>