Jump to content

how to update database by clicking link


berry05

Recommended Posts

sell.php code...

 

<?php session_start();

if(isset($_SESSION['otherusername'])){

$db=mysql_connect('localhost', 'root', '');

$res=mysql_select_db('textgame',$db) or die(mysql_error());

    
$otherusername = $_SESSION['otherusername']; //"SELECT item FROM users_items WHERE username='".$Username."'";
    
    $res=mysql_query($otherusername)or die(mysql_error());
    
  
    while($row = mysql_fetch_assoc($res)){


echo '<a href="sell.php?item="' . $row['item'] . '">' . $row['item'] . "<BR />";

if ( $row == "hoe" ) {
echo "Your name is someguy!<br />";
}


  }
}else{
   
   echo "Sorry your not a member please join us!";
}


?>

 

 

username='".$Username."'";

 

Where do you get $Username from?  and why are you storing queries in sessions...?

 

Also, look at your link (assuming they are id's):

 

echo '

 

So if $row['item'] is 65 then it would be:

www.yoursite.com/sell.php?item=65

 

In your script you should check to see if item isset and if it is delete it:

 

if(isset($_GET['item'])) {
$item = $_GET['item'];
$sql = "DELETE FROM table WHERE item = '$item'";
echo $sql;
mysql_query($sql) or die(mysql_error());
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.