update edit database script help

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

speedamp
New php-forum User
New php-forum User
Posts: 19
Joined: Sun Nov 16, 2003 9:12 am

update edit database script help

Postby speedamp » Mon Dec 01, 2003 11:58 am

hello everybody,

I am attempting to create an edit/delete script, and here is what i have so far:


----------------------------------------------------------------------------------

<?php

$db=mysql_connect();
mysql_select_db();

if($id){
if($submit){
$sql="UPDATE directory SET club='$club',first='$first',last='$last',age='$age',sex='$sex',race='$race' WHERE run_id=$id";
$result=mysql_query($sql);
echo"Thank you! Information updated.\n";
}else{
$sql="SELECT * FROM runner WHERE run_id = $id";
$result=mysql_query($sql);
$myrow=mysql_fetch_array($result);
?>
<form method="post" action="<?php echo $PHP_SELF?>">
<input type=hidden name="run_id" value="<?php echo $myrow["run_id"]?>">
Club:<input type="text" name="club" value="<?php echo $myrow["club"]?>"><br>
First:<input type="text" name="first" value="<?php echo $myrow["first"]?>"><br>
Last:<input type="text" name="last" value="<?php echo $myrow["last"]?>"><br>
Age:<input type="text" name="age" value="<?php echo $myrow["age"]?>"><br>
Sex:<input type="text" name="sex" value="<?php echo $myrow["sex"]?>"><br>
Race:<input type="text" name="race" value="<?php echo $myrow["race"]?>"><br>
<input type="Submit" name="submit" value="Enter Information">
</form>
<?php
}
}else{
$query = "SELECT * FROM runner";
$result = mysql_query($query);
while ($myrow = mysql_fetch_array($result)){
printf("<a href=\"%s?id=%s\">%s</a><br>\n", $PHP_SELF, $myrow["run_id"], $myrow["first"], $myrow["last"]);
}
}
?>

--------------------------------------------------------------------------------

Right now it's not updating properly....what am i doing wrong?

1) how do i get this to update all fields pertaining to $email (verification field)?

2) How could i add a delete option next to the name to fully delete?


Thanks,

-Michael

User avatar
ruturajv
php-forum Super User
php-forum Super User
Posts: 1280
Joined: Sat Mar 22, 2003 9:42 am
Location: Mumbai, India
Contact:

global variables...

Postby ruturajv » Mon Dec 01, 2003 11:57 pm

Can you please check that you are using $_POST['varname'] or $_GET['varname']

when you are actually searching...


if($id){
if($submit){


Return to “PHP coding => General”

Who is online

Users browsing this forum: Google [Bot] and 1 guest

cron