Jump to content

Recommended Posts

Hi all. I've created this simple dynamic dropdown box in PHP and MySQL. I jus twant it to update a row in my database. It is doing something very weird, and I can't figure out why... what it is doing is it will only update the newest row IF I ENTER A NEW ROW. If I try to update another row and it doesn't update, than it won't update the newer row, I'll have to create a new row. Then I can ONL update the newest row... it may sound cofusing but this is what it is doing... I've looked over the code for over 2 hours now.. I don't understand the problem here... here is my code:

 

$oracle = $_POST['iname'];
$swat = $_POST['sub'];
if(!$swat) {
?>
Your Items: <form action="<?php echo "$PHP_SELF"; ?>" method="POST">
<select name="iname">
<?php
$getiq = "SELECT * FROM uitems WHERE username='$showusername' AND location='1'";
$geti = mysql_query($getiq);
while($row = mysql_fetch_array($geti)) {
$thatid = $row['theitemid'];
$theid = $row['uitemid'];

$catiq = "SELECT * FROM items WHERE itemid='$thatid'";
$cati = mysql_query($catiq);
while($dog = mysql_fetch_array($cati)) {
$toyid  = $dog['itemid'];
$names = $dog['name'];
echo "<option value=$names>$names</option>";
}
}
?>
</option> <input type="submit" name="sub" value="Submit"></form>
<?php
}
if($swat) {
$fishq = "SELECT * FROM items WHERE name='$oracle'";
$fish = mysql_query($fishq);
while($run = mysql_fetch_array($fish)) {
$turtle = $run['itemid'];
}
mysql_query("UPDATE uitems SET location='2' WHERE theitemid='$turtle' AND username='$showusername' LIMIT 1") or die(mysql_error());
echo "Item has been added to your shop.";
}

}
?>

Please note: I HAVE NOT INCLUDED MY HEADERS, ETC.. SO PLEASE DON'T GO OFF SAYING THE PROBLEM IS BECAUSE MY DATABASE ISN'T CONNECTED... BECAUSE IT IS... I JUST DIDN'T WANT MY HEADER FILES SHOWING... THANK YOU in advance for the help. :)

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.