Forum Moderators: coopster
now to incorporate this into a php site goes something like this:
$query = "UPDATE tablename SET columnname = 'something' WHERE columnname LIKE 'something'";
$db = "database name";
$link= mysql_connect("localhost", "yourID@localhost", "password") or die("Could not connect! Error: " . mysql_error());
mysql_select_db($db, $link) or die("Could not open database invetory! Error: " . mysql_error());
$result = mysql_query($query, $link) or die("Query error! Error: " . mysql_error());
mysql_close($link);
There you go...reply if you have any trouble!
<?
<form method='post' action='update_name.php'>
Name: <input type='text' size=10 name='name_field' />
</form>
?>
################################################
This would be the file update_name.php, which updates the database. Note that upon execution, this will present you with update_name.php in the browser; it should show up as just a blank page. You can certainly redirect to another page, or present links on this page -- just add some HTML or some echo " HTML code here... "; statements.
<?
# get variables from form -- you would refer to the variable 'name_field' as $vars['name_field']
while(list($key, $value) = each($_POST)){
$vars[$key] = $value;
}
$query = "UPDATE tablename SET columnname = '$vars[name_field]' WHERE columnname LIKE 'something'";
$db = "database name";
$link= mysql_connect("localhost", "yourID@localhost", "password") or die("Could not connect! Error: " . mysql_error());
mysql_select_db($db, $link) or die("Could not open database invetory! Error: " . mysql_error());
$result = mysql_query($query, $link) or die("Query error! Error: " . mysql_error());
mysql_close($link);
?>