Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <html>
- <head>
- <title>Update a Record in MySQL Database</title>
- </head>
- <body>
- <?php
- $username = "username";
- $password = "password";
- $hostname = "localhost";
- //connection to the database
- $dbhandle = mysql_connect($hostname, $username, $password)
- or die("Unable to connect to MySQL");
- echo "Connected to MySQL<br>";
- //select a database to work with
- $selected = mysql_select_db("database_dealers",$dbhandle)
- or die("Could not select dealers");
- $ID = $_POST['ID'];
- $CName = $_POST['CName'];
- $sql = "UPDATE `database_dealers`.`dealers` SET `CName` = 'newname' WHERE `dealers`.`ID` = 347;
- " ;
- mysql_select_db('database_dealers');
- $retval = mysql_query( $sql, $conn );
- if(! $retval ) {
- die('Could not update data: ' . mysql_error());
- }
- echo "Updated data successfullyn";
- mysql_close($conn);
- ?>
- <form method = "post" action = "<?php $_PHP_SELF ?>">
- <table width = "400" border =" 0" cellspacing = "1"
- cellpadding = "2">
- <tr>
- <td width = "100">Employee ID</td>
- <td><input name = "ID" type = "text"
- ID = "ID"></td>
- </tr>
- <tr>
- <td width = "100">Employee Salary</td>
- <td><input name = "CName" type = "text"
- ID = "CName"></td>
- </tr>
- <tr>
- <td width = "100"> </td>
- <td> </td>
- </tr>
- <tr>
- <td width = "100"> </td>
- <td>
- <input name = "update" type = "submit"
- ID = "update" value = "Update">
- </td>
- </tr>
- </table>
- </form>
- <?php
- ?>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement