Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Software (http://www.velocityreviews.com/forums/f6-software.html)
-   -   PHP MySQL UPDATE (http://www.velocityreviews.com/forums/t955139-php-mysql-update.html)

patriic48@gmail.com 12-05-2012 09:41 AM

PHP MySQL UPDATE
 
Can anyone help me with correcting this page so it works?

Seems to have a problem with this line esp, $id=($_GET["id"]);

<?php
echo '<html>
<head>
<title>Edit a Record from MySQL Database</title>
</head>
<body>
<form method="post" action="update_ac.php">';

$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}

mysql_select_db("my_db", $con);

// get value of id that sent from address bar
$id=($_GET["id"]);


// Retrieve data from database
$sql="SELECT * FROM persons WHERE id='$id'";

$result=mysql_query($sql);

echo "<table border='1'>
<tr>
<th>ID</th>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>";

while ($row = mysql_fetch_array($result)){
$id = $row['id'];
$FirstName = $row['FirstName'];
$LastName = $row['LastName'];
$Age = $row['Age']; //we will echo these into the proper fields

echo '<tr><td><input type="text" value="<?php echo $id;?>" name="id" disabled/><br/> </td
<td>First Name:<br/><input type="text" value="<?php echo $FirstName;?>" name="FirstName"/> <br/> </td
<td>Last Name:<br/><input type="text" value="<?php echo $LastName;?>" name="LastName"/> <br/> </td
<td>Age:<br/><input type="text" value="<?php echo $Age;?>" name="Age"/> </br>
<input type="submit" value="submit changes"/></td</tr>';
}
echo "</table>";

// close connection
mysql_close($con);
?>

<?php
echo "</form>
</body>
</html>";
?>

heff 01-03-2013 05:43 PM

You've probably solved this by now, but here goes anyway.
Your GET request should be $id=$_GET['id'];


All times are GMT. The time now is 06:50 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.