Jump to content

Stalingrad

Members
  • Posts

    123
  • Joined

  • Last visited

Everything posted by Stalingrad

  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!
  14. Yes. thank you guys. I did contact my web host and they changed the php version back to php 3 and it worked fine. Thanks again.
  15. Hi! My forum was working fine a few days ago, I made absolutely NO changes to it what-so-ever, the only thing I did was change the hosting company I am with. The huge problem I am having with, with a few different scripts that I have programmed is when I hit the submit button on a GET, it goes back to the original .php. Like, for example, my original page is: page.php. The GET would be page.pgp?action=reply.. when I hit the submit on the reply GET, it goes back to page.php With an almost blank page, just the basic page... on whatever is on the page.php. Here is my code for the first page I am having problems with (just the part I am having the problem with)... if you request it, I can post the entire thing)... if(isset($newtopic)) { $name = $_POST['tname']; $tbody = $_POST['tbody']; $tcat = $_POST['tcat']; $nownow = $_POST['submit']; if(!isset($nownow)) { ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> Topic Title: <input type="text" name="tname"><br> <select name="tcat"><option value="1">General Chat</option> <option value="2">Help Chat</option> <option value="3">Roleplaying</option> <option value="4">Avatars</option> <option value="5">Art</option> <option value="6">Buying, Trading, Selling</option> </select><br><br>Body:<br><textarea name="tbody" cols="38" rows="8"></textarea><br><br><input type="submit" name="submit" value="CreateTopic"></form> <?php } if(isset($nownow)) { mysql_query("INSERT INTO topics (name, username, body, countit, boardin, created) VALUES ('$name', '$showusername', '$tbody', '0', '$tcat', '$sitetime')"); mysql_query("UPDATE category SET topics=topics+1 WHERE catid='$tcat'"); mysql_query("UPDATE users SET posts=posts+1 WHERE username='$showusername'"); echo "<font color=green>Success! Your Topic has been created.</font>"; } echo "meeba."; } And the other page I am having trouble with, is a a code I have just recently coded. It worked fine on my old hosting company, however, upon switching to my new host, the same problem has happened: <?php session_start(); include("file.php"); ?> <html> <head> <link rel="stylesheet" type="text/css" href="style.css" /> </head> <?php if(!isset($_SESSION['username'])) { echo "<banner></banner><nav>$shownavbar</nav><ubar><a href=login.php>Login</a> or <a href=register.php>Register</a></ubar><content><center><font size=6>Error!</font><br><br>You are not Logged In! Please <a href=login.php>Login</a> or <a href=register.php>Register</a> to Continue!</center></content>"; } if(isset($_SESSION['username'])) { echo "<nav>$shownavbar</nav><ubar>$ubear</ubar><content><center><font size=6>Messages</font><br><br><br><br>"; $action = $_GET['action']; if($action=="not") { "not"; } elseif ($action=="out") { echo "Outbox."; } elseif ($action=="delete") { echo "Delete."; } elseif($action=="compose") { $body = $_POST['body']; $ruply = $_POST['ruply']; $tetle = $_POST['tetle']; $towho = $_POST['towho']; echo "<font size=5>Compose Message</font><br><br>"; if(!isset($ruply)) { ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> Title: <input type="text" name="tetle"><br> To: <input type="text" name="towho"><br><br> <textarea name="body" rows="8" cols="32"></textarea><br><br><input type="submit" name="ruply" value="Send Message"><br><br></form> <?php } if(isset($ruply)) { $chekq = "SELECT * FROM users WHERE username='$towho'"; $cheky = mysql_query($chekq); $chek = mysql_num_rows($cheky); if($chek < "1") { echo "<font color=red>Error! That user doesn't Exist!</font><br><br>"; ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> Title: <input type="text" name="tetle"><br> To: <input type="text" name="towho"><br><br> <textarea name="body" rows="8" cols="32"></textarea><br><br><input type="submit" name="ruply" value="Send Message"><br><br></form> <?php } if($towho == "") { echo "<font color=red>Error! Please fill out the entire form!</font><br><br>"; ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> Title: <input type="text" name="tetle"><br> To: <input type="text" name="towho"><br><br> <textarea name="body" rows="8" cols="32"></textarea><br><br><input type="submit" name="ruply" value="Send Message"><br><br></form> <?php } if($towho != "" && $chek >= "1") { mysql_query("INSERT INTO `umessages`(`userto`, `userfrom`, `title`, `body`, `date`, `read`) VALUES ('$towho', '$showusername', '$tetle', '$body', '$sitetime', 'No')"); echo "<font color=green>Success! Your message has been Sent!</font><br><br><a href=?action=inbox>Back to Inbox</a><br><br>"; } } } elseif ($action=="inbox") { echo "<a href=?action=compose>Compose Message</a><br><br>"; echo "<table border=1 bordercolor=black cellpadding=6 cellspacing=0><tr><td><center>From</center></td><td><center>Title</center></td><td><center>Date</center></td><td><center>Read?</center></td></tr>"; $getmq = "SELECT * FROM umessages WHERE userto='$showusername'"; $getm = mysql_query($getmq); while($mrow = mysql_fetch_array($getm)) { $mid = $mrow['mid']; $mtit = $mrow['title']; $mfrom = $mrow['userfrom']; $mto = $mrow['userto']; $mbody = $mrow['body']; $mre = $mrow['read']; $mdate = $mrow['date']; echo "<tr><td><center><a href=lookup.php?username=$mfrom>$mfrom</a></center></td><td><center><a href=?action=view&mid=$mid>$mtit</a></center></td><td><center>$mdate</center></td><td><center>$mre</center></td></td></tr>"; } echo "</table>"; echo "<br><br>"; } elseif($action=="send") { echo "Send."; } elseif($action=="view" ) { $thisid = $_GET['mid']; $goreply = $_POST['reply']; $myreply = $_POST['replys']; $vq = "SELECT * FROM umessages WHERE mid=$thisid"; $vit = mysql_query($vq); while($yrow = mysql_fetch_array($vit)) { $tid = $yrow['mid']; $tfrom = $yrow['userfrom']; $tto = $yrow['userto']; $tbody = $yrow['body']; $tread = $yrow['read']; $tdate = $yrow['date']; $ttit = $yrow['title']; } echo "<table border=1 bordercolor=black cellpadding=6 cellspacing=0 width=398px><tr><td><center><font size=5>$ttit</font><br>From: <a href=lookup.php?username=$tfrom>$tfrom</a> $tdate</center></td></tr><tr><td><center><br>$tbody<br><br></center></td></tr></table><br><br><br>"; ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <textarea rows="6" cols="20" name="replys">Write a reply...</textarea><br><br> <input type="submit" name="reply" value="Submit Reply"></form><br><br> <?php } if(isset($goreply)) { mysql_query("INSERT INTO `umessages`(`userto`, `userfrom`, `title`, `body`, `date`, `read`) VALUES ('$tfrom', '$showusername', '$ttit', '$myreply', '$sitetime', 'No')"); echo "<font color=green>Success! Your Reply has been sent!</font><br><br><a href=?action=inbox>Back to Inbox</a><br><br>"; } } ?> </html> Please... if anybody could guide me with some help, it would be so much appreciated, thank you!
  16. Hi all. I have shared hosting for my website. I was wondering how the WAMP server works? Or how a server works in general? Can somebody pelase explain this to me in basic terms please? I don't really understand this. Like I see localhost used in peoples' browser's, but when I update my website,I have to use my website's cpanel and everything by the website name. Thank you in advance.
  17. Oh wait, it's ordering them by the first number, not the whole number... I'm getting this: 99 84 3455 How do I fix this one? Thanks. :s Ah, I got it. It seems I didn't have the row set as "INT" in my database, it was set as "VARCHAR". Thank you for the help. It works fine now. ^^
  18. Hi! I have some PHP and MySQL code here. I am trying to set up this table displaying users scores. I want to grab from a table in a sepecific row and order the row by the top to bottom, but only the TOP 10. Like for example, lets say I wanted only 3 for this example to keep it simple. (even though I wnat 10, thisexample will keep things simple and not waste any time)... I have a table called "user". Row Name: id name score 1 julie 100 2 sam 80 3 james 35 I want to grab both the username AND the score, and order by the score, larger score to bottom. Just like I showed. Here is my code: if($table == "Avatar") { $avq = "SELECT avatarcount FROM users"; echo "Top Scores<br><br>"; } I appreciate any help! Thank you!
  19. Hi. I am trying to create a form, well I already have and it isn't working. What I am trying to do is update multiple rows of the SAME field name with a text box displayed for each row that exists. Everything is displayed okay, but the submit button doesn't even load the page or anything.. it doesn't do anything for one thing. Even if it did, I know it wouldn't work. So my question is this... how can I update all of the displayed boxes at once with only ONE submit button? I'm thinking maybe I have something missing or something else is wrong... or maybe both! Here is my code for this piece: 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>"; } } Please, somebody help with this. I have been stuck on this page for so long now. I gave up a looong time ago, now I am going back trying to solve the issues. Thank you. Also, please keep it simple and not confusing, thanks!
  20. Hi! I am trying to create this form, it might be dynamic? I want to allow my users to be able to select the images they want, and then click submit. They don't have to select all of them, either. It will be up to them. I have the code showing the images being grabbed from the database, then being displayed; however I have no idea how to create this form. I'm pretty sure, again, it is a dynamic form. How should I do this? I want a check box under each image, and just one submit button at the end. I'm kind of confused here as of how this would work... and help is appreciated, thank you! Here is the part of the code I am using for this: if($action == "quick") { 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>Quick Stock</font><br><br>"; $sen = "4"; echo "<table border=0>"; echo "<tr>"; $qsq = "SELECT * FROM uitems WHERE username='$showusername'"; $qs = mysql_query($qsq); while($qwe = mysql_fetch_array($qs)) { $oid = $qwe['uitemid']; $otid = $qwe['theitemid']; $oloc = $qwe['location']; $opri = $qwe['price']; $iqwe = "SELECT * FROM items WHERE itemid='$otid'"; $rwe = mysql_query($iqwe); while($yop = mysql_fetch_array($rwe)) { $irma = $yop['image']; $nima = $yop['name']; $ida = $yop['itemid']; $disa = $yop['description']; $rira = $yop['rarity']; echo "<td><center><img src=images/items/$irma><br>$nima</center></td>"; $sen--; if(!$sen) { echo "</tr><tr>"; $sen=4; } } } Thanks again for nay help 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.