A real newbie would be grateful for some help.
I have a sports club membership database (Mysql) with first and last names,
address  and paid or not paid.
In edit.php I would like to be able to pre-fill a list box with whether the
person has paid or not, change if necessary, update the database
and view the resultant changes in members.php
I have tried the following in edit.php but can't get it to work.

<html>
<head>
<title>Update</title>
<link rel="stylesheet" type="text/css" href="Style.css">
</head>
<body>
<table border=0 cellpadding=4 cellspacing=0  align=center>
<tr><td class=PageTitle>Update a members record</td></tr>
<? echo "<form method='post' action='$PHP_SELF'>";
include("mydb1.inc");
mysql_connect(localhost,$user,$password);
$query1 = "select * from contact where id = '$id'";
$result1 = mysql_db_query('mydb',$query1);
while($row = mysql_fetch_object($result1)) {
print "<tr><td class=LabelColumn >First Name:</td><td
class=TextColumn><input type=text name='first'
value='$row->first'></td></tr>";
print "<tr><td class=LabelColumn>Last Name:</td><td class=TextColumn><input
type=text name='last' value='$row->last'></td></tr>";
print "<tr><td class=LabelColumn>Address:</td><td class=TextColumn><input
type=text name='address' value='$row->address'></td></tr>";

print "<tr><td class=LabelColumn>Paid:</td><td class=TextColumn><select
name='paid' value='$row->paid'>
        <option value='if ($paid == paid)'>paid</option>
        <option value='if ($paid == no)'>not paid</option>
        </select></td></tr>";

$id = $row->id;
}
echo "</table><p>";
echo "<br><input type=hidden name='id' value='$id'>";
?>
<table border=0 cellpadding=4 cellspacing=0  align=center>
<input type=submit name="update" class="Button" value="Update record">
</form>
<?
if ($update) {
        if($first == "" || $last == "" || $address == ""  || $paid == "") {
        die("<b>You left one or more fields blank.</b>");
    }

    $query2 = "update contact set first='$first', last='$last',
            address='$address', paid='$paid'
            where id='$id'";
    mysql_db_query('mydb',$query2);
    echo "<b>Your record has been updated</b></p>";
 }
mysql_close();
?>

Thank you for any help
Gee



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to