Jump to content

Stalingrad

Members
  • Posts

    123
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

Stalingrad's Achievements

Member

Member (2/5)

0

Reputation

  1. Hi! I am still stuck on this problem, I can't give up on it... but there is no other way around it... What I am trying to do is this: Display the name/image of the row AND a text box underneath it... but there are multiple rows in most cases. I also want it so that the user can type in a number in each of the textboxes, and have them all update with the different inserted text with the same, one submit button... here is my code I am having trouble with: if($action == "stock") { $setprice = $_POST['prices']; $updateprice = $_POST['updateprice']; $_POST['prices'] = Array('$setprice'); echo "<a href=?action=edit>Edit Shop</a> | <a href=?action=view&user=$suserid>View Shop</a> | <a href=?action=stock>View Stock</a> | <a href=?action=quick>Quick Stock</a><br><br><font size=5>Stock Shop</font><br><br>"; ?> <form action="<?php echo "$PHP_SELF"; ?>" 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 "<br>$fname<br><img src=/images/items/$fimage><br><br>"; ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"><input type="text" name="prices[]" value="<?php echo "$eeprice"; ?>"><br> <?php } ?> <?php } Please note that this is NOT the whole code oft he page, but none of the other parts of the code have anything to do with this part... it is split into "pages" with PHP (same page, but $_GET is used for "multiple" pages. If anybody can help me do this, I would appreciate it SO much! Oh.. and by the way... right now (the code you see above), displays the text boxes and the image/name of it... with one submit button.... the form loads, but only the very last text box displayed gets "updated" and it says "Array". Thank you!
  2. And I did what you told me to, and now it brings to back to the page,and each item has a blank box, but the last item has 'Array" written in it...
  3. I don't understand what you mean by array... and setting it... the user sets their own price, I can't set the array price...
  4. Yes, multiple items (rows) they are in the same table.
  5. Okay I got it to work, but now it updates.. not what I want it to, but they are all blank except for the last one.. it says "Array"...
  6. I'm not understanding... I replaced the code with what you wrote, and it still is not updating... is there something I am missing here? Thank you for replying by the way.
  7. Hi there! I've been having some trouble for quite some time now with a form. I have a table that I'm grabbing data from. I want to update multiple rows with a form. However, I have multiple text boxes under each row I want to update with only one submit button. When I press the submit button nothing happens. I'm not sure why. I've been having trouble with this forever, like I said. I would really, really like to get this done as it's holding me back from doing other things on my site. I will post the part of the code where I'm having the trouble. I don't think I will need to post the whole code since there are other parts of it that don't involve this at all. Here is the code: if($action == "stock") { $setprice = $_POST['price']; $updateprice = $_POST['updateprice']; echo "<a href=?action=edit>Edit Shop</a> | <a href=?action=view&user=$showusername>View Shop</a> | <a href=?action=stock>View Stock</a> | <a href=?action=quick>Quick Stock</a><br><br><font size=5>Stock Shop</font><br><br>"; $eq = "SELECT * FROM uitems WHERE username='$showusername' 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='$showusername' 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 "<br>$fname<br><img src=/images/items/$fimage><br><br>"; ?> <input type="text" name="price" value="<?php echo "$eeprice"; ?>"><br></form> <?php } ?> <?php } ?> <br><br><input type="submit" name="updateprice" value="Update Prices"><br><br> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"></form> <?php if(isset($setprice)) { mysql_query("UPDATE uitems SET price='$setprice' WHERE username='$showusername' AND theitemid='$fid'"); echo "<font color=green>Success! Your prices have been set and updated!</font><br><br>"; } } Before anybody says anything about it, I know my variable names are ridiculous.. so you don't even need to say that, lol. I have trouble naming my variable because I use so many in my codes. I'll have to come up with a better way to name them. Basically what this code is doing is grabbing the data with the specific location, displaying it and displaying the form. However, the form is not updating. Any help would be appreciative! Also, there was a time when the form DID work, but it did not update.... it just reloaded the page and left the text fields blank. Thanks again guys!
  8. The query works fine for displaying as for the uitem thing, but thank you for the help. I will try what you said when I get back home from work. I appreciate the help, and will let you know how it goes. I will post later, thank you! I will also look into the JOIN. I've had trouble in the past with JOIN and just became discouraged. I take the long route with it by running 4930294 loops, lol. >_< I run so many loops with the while array,it's no even funny. But I will try the GROUP BY.
  9. Hi all! I've been workign a lot lately on this issue and have come accross it yet again. I will show you the example of the code that grabs the data and display it, then also two images. One image of what I am getting (No erros in this), and also an Image of what I am tryign to accomplish. I'm sorry I can't be more specific, but I have googled everything under the sun and am stumped as to what the function or even php/mysql code is called for this.. anyway, here it goes! I am displaying some images. They display great. Theo nly problem is, I wnat them to display in a more advanced way now that I have covered many nice things on my website. I can show a list of images, but let's say I have an image that is displayed twice (the same image. I want to, instead of displaying the image itself twice again, just display the image and underneath it put a x 2. Here is my code for grabbing and displaying the images... keep in mind, yes my variable names are rediculous and my coding seems unorginzed but I am 100% self-taught for 11 years now... $getid = $_GET['uitemid']; $action = $_GET['action']; if(!isset($getid)) { $col = "4"; echo "<table border=0>"; echo "<tr>"; $query = "SELECT * FROM uitems WHERE username='$showusername' AND location='1'"; $iquery = mysql_query($query); while($irow = mysql_fetch_array($iquery)) { $uitemid = $irow['uitemid']; $theitemid = $irow['theitemid']; $loc = $irow['location']; $price = $irow['price']; $uzer = $irow['username']; $squery = "SELECT * FROM items WHERE itemid='$theitemid'"; $querys = mysql_query($squery); while($row = mysql_fetch_array($querys)) { $name = $row['name']; $image = $row['image']; $desc = $row['desc']; $rare = $row['rarity']; $shop = $row['shop']; $type = $row['type']; $coins = $row['coins']; $uses = $row['uses']; echo "<td><center>$name<br><a href=?uitemid=$uitemid><img src=images/items/$image></a></center></td>"; $col--; if(!$col) { echo "</tr><tr>"; $col=4; } } } } Here are the images, The first one is what I am getting, and the second is what I want to accomplish... before and after I named them, basically. Before is what I am getting, and after is what I want... so yeah. Anyway, basically, what way should I go about with my code to make this happen? I don't use the JOIN MySQL because it never works for me, I just loop it, and it always works fine. Is there a way to do this with my code? Thanks guys!
  10. Variable NAMES have nothing to do with how well something runs
  11. 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.
  12. Would the javascript in that be considered "jquery" or just javascript? For coding the countdown?
  13. Hi. I have a question about PHP and times with MySQL I am trying to program something here that will have a time limit when you are doing something. Let's say I am giving the user 5 minutes to complete a task. When the user hits the submit button to start the task, the 5 minute timer will start. Then from there the 5 minutes will count down. I also would like to display a counter to the user in the format of minute and seconds. so, like 5:00. And if he/she comes back to the page and is out of time, I want it to display "sorry, you did not complete my task in time!" If they have more time left, then I want the time remaining, along with a submit button so they can complete the task. Also, if they have met the requirements when they hit the submit button,the timer will end, and it goes back to the original "do you want to start a new task?" form submit button. How would I go about doing the whole time thing? I know how to do the submit button, I am good with simple forms... not so much advance, because I'm having trouble with a few forms, but times I do have trouble with Basically, what is the function name, or what is this called in PHP? I'm not sure if I need actual codes form you guys, but maybe you can tell me what this is called... because I've googled so many different time things, and I'm not finding what I'm looking for. Thank you in advance!
×
×
  • 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.