Link to home
Start Free TrialLog in
Avatar of wantabe2
wantabe2Flag for United States of America

asked on

Edit MySQL Data from Browser with PHP

Is it possible for me to edit mysql data from a browser with php? In the attached code, it will display the data from the mysql database in a browser. Notice line:

echo '<td><a href="edit_g.php"><center>EDIT</center></a></td>';

If I have a file named edit_g.php, could I add some type of code to it so I could edit the mysql data for that particular record?
<p> To go back <a href="http://mysite/flow/index.html">click here</a>.</p>
<?php
$con = mysql_connect("localhost","uname","password");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("psrflow", $con);

$result = mysql_query("SELECT * FROM orderinfo WHERE status = 'office a'");


echo "<table border='7'>
<tr>
<th>Cust No</th>
<th>First Name</th>
<th>Last Name</th>
<th>Status</th>

<th></th>
</tr>";

while($row = mysql_fetch_array($result))
  {
  echo "<tr>";
  echo "<td align='center'>" . $row['custno'] . "</td>";
  echo "<td align='center'>" . $row['fname'] . "</td>";
  echo "<td align='center'>" . $row['lname'] . "</td>";
  echo "<td align='center'>" . $row['status'] . "</td>";
  echo '<td><a href="edit_g.php"><center>EDIT</center></a></td>'; 
  
  echo "</tr>";
  }
echo "</table>";

mysql_close($con);
?>

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Lukasz Chmielewski
Lukasz Chmielewski
Flag of Poland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial