Need Urgent Help Me

Hi all Please help me solve
I want to do update data. I want to select data and then link to a php page that page will selected one data and then click update the data will be updated.
I put like this…
First page for web php page
<?php
$host=“localhost”; // Host name
$username=“root”; // Mysql username
$password=“mmt”; // Mysql password
$db_name=“project”; // Database name
$tbl_name=“member”; // Table name

// Connect to server and select database.
mysql_connect(“$host”, “$username”, “$password”)or die(“cannot connect”);
mysql_select_db(“$db_name”)or die(“cannot select DB”);

$sql=“SELECT * FROM $tbl_name”;
$result=mysql_query($sql);
?>
<table width=“400” border=“1” cellspacing=“1” cellpadding=“0”>
<tr>
<td>
<table width=“400” border=“1” cellspacing=“0” cellpadding=“3”>
<tr>
<th colspan=“8”><strong>Data from MySQL</strong> </th>
</tr>

<tr>
<td align=“center”><strong>Member ID</strong></td>
<td align=“center”><strong>Member Name</strong></td>
<td align=“center”><strong>Password</strong></td>
<td align=“center”><strong>Email</strong></td>
<td align=“center”><strong>Contact No.</strong></td>
<td align=“center”><strong>Address</strong></td>
<td align=“center”> </td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td><? echo $rows[‘MembID’]; ?></td>
<td><? echo $rows[‘MembName’]; ?></td>
<td><? echo $rows[‘MembPass’]; ?></td>
<td><? echo $rows[‘MembEmail’]; ?></td>
<td><? echo $rows[‘MembCNo’]; ?></td>
<td><? echo $rows[‘MembAdd’]; ?></td>
<td align=“center”><a href="home.php?id=<? echo $rows[‘MembID’]; ?> " style=“font-family: Arial; font-size: 14px; color: blue; text-decoration: underline”>update</a></td>
</tr>
<?php
}
?>
</table>
</td>
</tr>
</table>
<a href=‘login_success.php’>Back to Admin Page</a>
<?php
mysql_close();
?>

This is after click the link will go this page and process
<?php
$host=“localhost”; // Host name
$username=“root”; // Mysql username
$password=“mmt”; // Mysql password
$db_name=“project”; // Database name
$tbl_name=“member”; // Table name

// Connect to server and select database.
mysql_connect(“$host”, “$username”, “$password”)or die(“cannot connect”);
mysql_select_db(“$db_name”)or die(“cannot select DB”);

// get value of id that sent from address bar
$id=$_GET[‘id’];

// Retrieve data from database
$sql=“SELECT * FROM $tbl_name WHERE MembID=‘$id’”;
$result=mysql_query($sql);

$rows=mysql_fetch_array($result);
?>
<table width=“400” border=“0” cellspacing=“1” cellpadding=“0”>
<tr>
<form name=“form1” method=“post” action=“check_member_update.php”>
<td>
<table width=“100%” border=“0” cellspacing=“1” cellpadding=“0”>
<tr>
<td> </td>
<td colspan=“3”><strong>Update data in mysql</strong> </td>
</tr>

<tr>

<td align=“center”><strong>Member ID</strong></td>
<td align=“center”><strong>Member Name</strong></td>
<td align=“center”><strong>Password</strong></td>
<td align=“center”><strong>Email</strong></td>
<td align=“center”><strong>Contact no.</strong></td>
<td align=“center”><strong>Address</strong></td>
</tr>
<tr>

<td align=“center”><input name=“MembID” type=“text” id=“MembID” value=“<? echo $rows[‘MembID’]; ?>”></td>
<td><input name=“MembName” type=“text” id=“MembName” value=“<? echo $rows[‘MembName’]; ?>” size=“15”></td>
<td align=“center”><input name=“MembPass” type=“text” id=“MembPass” value=“<? echo $rows[‘MembPass’]; ?>” size=“15”></td>
<td align=“center”><input name=“MembEmail” type=“text” id=“MembEmail” value=“<? echo $rows[‘MembEmail’]; ?>” size=“15”></td>
<td align=“center”><input name=“MembCNo” type=“text” id=“MembCNo” value=“<? echo $rows[‘MembCNo’]; ?>” size=“15”></td>
<td align=“center”><input name=“MembAdd” type=“text” id=“MembAdd” value=“<? echo $rows[‘MembAdd’]; ?>” size=“15”></td>

</tr>
<tr>

<td align=“center”><input type=“submit” name=“Submit” value=“Submit”></td>
<td> </td>
</tr>
</table>
</td>
</form>
</tr>
</table>

<?

// close connection
mysql_close();

?>

This is last page for successful update
<?php
$host=“localhost”; // Host name
$username=“root”; // Mysql username
$password=“mmt”; // Mysql password
$db_name=“project”; // Database name
$tbl_name=“member”; // Table name

// Connect to server and select database.
mysql_connect(“$host”, “$username”, “$password”)or die(“cannot connect”);
mysql_select_db(“$db_name”)or die(“cannot select DB”);

$id=$_POST[“MembID”];
$name=$_POST[“MembName”];
$pword=$_POST[“MembPass”];
$email=$_POST[“MembEmail”];
$contact=$_POST[“MembCNo”];
$add=$_POST[“MembAdd”];

// update data in mysql database
$sql=“UPDATE $dbname.$tbl_name SET MembID=‘$id’,MembName=‘$name’, MembPass=‘$pword’, MembEmail=‘$email’, MembCNo=‘$contact’, MembAdd=‘$add’ WHERE MembID=‘$id’”;
$result=mysql_query($sql);

// if successfully updated.
if($result){
echo “Successfully updated to Database!”;
echo “<BR>”;
}

else {
echo “ERROR”;
}

?>

From the first page I got one problem… I don’t know why my data can’t view. And then I want to get data to my second page but the data can’t show there only show <? echo $rows[‘MembID’]; ?> … all why i can’t see my data… that two page give me headache for 3 days already. I’m just a student and trying to write PHP. If can help… please share me some experiences how to solve this please.

If have other way, give me some advice please

<?= echo $rows[‘MembID’]; ?> should be <?= $rows[‘MembID’]; ?>, no echo

Thank you. I just found out coz of you :slight_smile: thx a lot. :):cool:

<? echo $rows[‘MembID’]; ?> should be <?= echo $rows[‘MembID’]; ?> or <?php echo $rows[‘MembID’]; ?>