Update MUltiple Rows in Same Column with Same Submit Button?

Hi! This may sound confusing, and I hope that I worded the title right, but I have a very complex form that I’ve been asking around on many different forum for, and trying for for several years now… I’ve basically been trying to update multiple rows with one submit button. I have several items displayed, and you type in the amount you want to display, and press “Submit”. It will not update the amount you put it in for, it shows up blank. I will copy and paste my code below. I know it is confusing, but I am at wits end with this coding… it is stopping me from a wonderful website. :frowning: Also, if anybody can also help me out and show me how to do it and/or tell me the style/example I need to follow so I can look the function/example up please tell me! I have looked in every PHP book and SQL book I own! Nothing comes up. :frowning: I have re-written it at least 10 times, and still a dead end. Here is my code:
[php]<?php
session_start();
include(“FILE.php”);
?>

<?php if(!isset($_SESSION['username'])) { echo "$shownavbarLogin or RegisterError!

You are not Logged In! Please Login or Register to Continue!"; } if(isset($_SESSION['username'])) { echo "$shownavbar$ubearUser Shops

"; $action = $_GET['action']; $tusery = $_GET['user']; if(!isset($action)) { echo "Edit Shop | View Shop | View Stock | Quick Stock

"; } if(isset($action)) { $getshopq = "SELECT * FROM usershops WHERE owner='$suserid'"; $getshop = mysql_query($getshopq); while($tri = mysql_fetch_array($getshop)) { $theid = $tri['ushopid']; $owner = $tri ['owner']; $desc = $tri['description']; $image = $tri['image']; $name = $tri['name']; $status = $tri['status']; $discount = $tri['discount']; } if($action == "edit") { echo "Edit Shop | View Shop | View Stock | Quick Stock

Edit Shop

"; ?> " method="POST"> <?php $create = $_POST['create']; $thename = $_POST['thename']; $thedesc = $_POST['thedesc']; $thestatus = $_POST['thestatus']; $theimage = $_POST['theimage'];

?>

" method="POST"> Shop Name:
Description

Status: Open Closed Gallery

<?php if(isset($create)) { if($thename == "" || $thedesc == "") { echo "Error! Please fill out the entire form!

"; ?> " method="POST"> Shop Name:
Description

Status: Open Closed Gallery

<?php }

if($thename != “” && $thedesc != “”) {
$citsq = mysql_query(“SELECT * FROM usershops WHERE owner=’$suserid’”);
$cits = mysql_num_rows($citsq);
if($cits != “0”) {
mysql_query(“UPDATE usershops SET description=’$thedesc’ WHERE owner=’$suserid’”);
mysql_query(“UPDATE usershops SET name=’$thename’ WHERE owner=’$suserid’”);
mysql_query(“UPDATE usershops SET status=’$thestatus’ WHERE owner=’$suserid’”);
echo “Success! You have created your shop! Click <a href=?action=view>here to view it.

”;
}

}
if($cits == “0”) {
mysql_query(“INSERT INTO usershops (owner, name, description, image, status, discount) VALUES (’$suserid’, ‘$thename’, ‘$thedesc’, ‘pinkapple.gif’, ‘$thestatus’, ‘None’)”);
echo “Success! You have created your shop!

”;
}

}
}

if($action == “view”) {
$vcount = 0;
$yuko = 4;

echo “<a href=?action=edit>Edit Shop | <a href=?action=view&user=$suserid>View Shop | <a href=?action=stock>View Stock | <a href=?action=quick>Quick Stock

”;

$gaq = “SELECT * FROM usershops WHERE owner=’$tusery’”;
$sq = mysql_query($gaq);
while($pon = mysql_fetch_array($sq)) {
$hn = $pon[‘name’];
$hi = $pon[‘image’];
$hg = $pon[‘description’];
$ho = $pon[‘owner’];
$hs = $pon[‘status’];
$hdi = $pon[‘discount’];
$hid = $pon[‘ushopid’];

echo “$hn



$hg


”;
}
echo “

”;
echo “”;
$buyitya = $_GET[‘buy’];

$wowq = “SELECT * FROM uitems WHERE username=’$suserid’ AND location=‘2’”;
$wow = mysql_query($wowq);
while($wrow = mysql_fetch_array($wow)) {
$umid = $wrow[‘uitemid’];
$umiid = $wrow[‘theitemid’];
$umloc = $wrow[‘location’];
$umprice = $wrow[‘price’];

$infoq = “SELECT * FROM items WHERE itemid=’$umiid’”;
$info = mysql_query($infoq);
while($row = mysql_fetch_array($info)) {
$myname = $row[‘name’];
$myid = $row[‘itemid’];
$myimage = $row[‘image’];
$mydesc = $ow[‘description’];
$myrarity = $row[‘rarity’];

echo “

”;
$yuko–;
if(!$yuko) {
echo “”;
$yuko=4;
}
if(isset($buyitya)) {
mysql_query(“UPDATE uitems SET username=’$suserid’ AND location=‘1’ WHERE uitemid=’$umid’”);
mysql_query(“UPDATE users SET credits=credits-$umprice WHERE username=’$suserid’”);
}
}
}
echo “

”;
}

if($action == “stock”) {

$setprice = $_POST[‘prices’];
$updateprice = $_POST[‘updateprice’];

$_POST[‘prices’] = Array(’$setprice’);

echo “<a href=?action=edit>Edit Shop | <a href=?action=view&user=$suserid>View Shop | <a href=?action=stock>View Stock | <a href=?action=quick>Quick Stock

Stock Shop

”;
?>

" method="POST"> <?php $eq = "SELECT * FROM uitems WHERE username='$suserid' AND location='2' GROUP BY theitemid"; $ee = mysql_query($eq); while($erow = mysql_fetch_array($ee)) {

$eeloc = $erow[‘location’];
$eeid = $erow[‘theitemid’];
$eenowid = $erow[‘uitemid’];
$eeprice = $erow[‘price’];

$wq = “SELECT * FROM items WHERE itemid=’$eeid’”;
$ww = mysql_query($wq);
while($wrow = mysql_fetch_array($ww)) {

$cq = mysql_query(“SELECT * FROM uitems WHERE username=’$suserid’ AND location=‘2’ AND theitemid=’$eeid’”);
$lcq = mysql_num_rows($cq);
$fid = $wrow[‘itemid’];
$fname = $wrow[‘name’];
$fimage = $wrow[‘image’];
$frarity = $wrow[‘rarity’];
$fdesc = $wrow[‘description’];

echo “
$fname


”;
?>

" method="POST">">
<?php

}
?>

<?php } ?>





<?php if(isset($updateprice)) { mysql_query("UPDATE uitems SET price='$setprice' WHERE username='$suserid' AND theitemid='$fid'"); echo "Success! Your prices have been set and updated!

"; } } if($action == "quick") { echo "Edit Shop | View Shop | View Stock | Quick Stock

Quick Stock

"; } } } ?> [/php]

I am looking at the option “stock”. Thank you! :smiley:

<a href=usershops.php?action=view&buy=$umid>
$myname
Price: $umprice

without creating the database tables it’s hard for me to see exactly what is going on. I placed your code into my editor and using tab spaces i made it more human friendly which meant i could spot a few things wrong with your code.

You have a few variable inside single quotes echo ‘$setprice’ This will in fact print the string $setprice to the screen, to get the value of set price, use double quotes (or none at all)
[php]echo $setprice
echo “$setprice”[/php]
will both work fine.

Next,
What is this variable? $PHP_SELF ?? Should this be [php]$_SERVER[‘PHP_SELF’][/php]

Then you have if statements but allow the script to continue regardless if they’re true or false - not good!

As i said earlier, with creating the database i can’t really be much more help, sorry :frowning:

Red :wink:

Sponsor our Newsletter | Privacy Policy | Terms of Service