
Stalingrad
Members-
Posts
123 -
Joined
-
Last visited
Everything posted by Stalingrad
-
Thank you.
-
Hello there. =] I have a simple question, which doesn't need any posting of code. I would like to use a PHP MySQL JOIN statement, or whatever it is called. I know it is called a JOIN, and would like to know something about it. My question is: Do two of the rows that you want to combine have to be the same exact name.. or can they have different row names? I actually have THREE tables, but will try to find a way to do this if JOIN can only involve two tables. Thank you. =]
-
Having Trouble Grabbing From Table, Please Help. :s
Stalingrad replied to Stalingrad's topic in MySQL Help
Okay, thank you. -
Having Trouble Grabbing From Table, Please Help. :s
Stalingrad replied to Stalingrad's topic in MySQL Help
I don't understand that... can you please give me an example with my code and explain? Thank you. -
Hey there. I will try my best not to confuse anybody here, lol! Okay, so.. I am trying to grab from multiple tables. I am involving 3 different tables here: trades, uitems, and items. Those are the three tables I am involving in the problem I am having. Keep those three tables in mind. I will post the code below. What I am trying to do is display all of the items from the trades table. I have 7 field names in the row (the names are: item1 - item7). I can onlyfigure out how to grab one of them, so I grabbed item1, which was the first one. There are other field names in the trades table, but I can grab those fine. The reason I am having trouble here, is because I need to get the data on what the item1 - item7 are from the other tables (uitems and items). Get my drift? Probably not. :s The items table has information on the item1 - item7. Since item1 - item7 are most likely all different, but they CAN be the same. All mixed. It depends, really. It doesn't matter. We;ll just assume item1 - item7 are all different. Here is my code: <?php session_start(); include("cofigfile.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'])) { $view = $_GET['view']; $offers = $_GET['offers']; $create = $_GET['create']; echo "<nav>$shownavbar</nav><ubar>$ubear</ubar><content><center><font size=6>Trade Center</font><br><br>Hello there, and welcome to the Trade Center! It is advised you be careful when trading, as other users may try to scam you.<br><br><a href=trades.php>Home</a> | <a href=?create>Create a Trade</a> | <a href=?view=1>View Trades</a> | <a href=?offers>My Offers</a><br><br>"; if(isset($view)) { $per = 1; $thequer = mysql_query("SELECT COUNT(`tradeid`) FROM `trades`"); $pages = ceil(mysql_result($thequer, 0) / $per); $page = (isset($_GET['view'])) ? (int)$_GET['view'] : 1; $start = ($page - 1) * $per; $query1 = mysql_query("SELECT * FROM trades LIMIT $start, $per"); while($query = mysql_fetch_assoc($query1)) { ==============$getuitemsquery = "SELECT * FROM uitems WHERE uitemid=$query[item1]"; $uitems = mysql_query($getuitemsquery); while($i1 = mysql_fetch_array($uitems)) { $itemt1 = $i1['theitemid']; } $nowitemq = "SELECT * FROM items WHERE itemid='$itemt1'"; $nowq = mysql_query($nowitemq); while($row = mysql_fetch_array($nowq)) { $image = $row['image']; $name = $row['name']; $desc = $row['description']; $rarity = $row['rarity']; } ==============echo "<table border=1 cellpadding=1 cellspacing=0 width=305px bordercolor=black><tr><td><p>Owner: <a href=lookup.php?username=$query[user]>$query[user]</a></p></td></tr><tr><td><center><img src=images/items/$image><br>$name</center></tr></td>"; } if($pages >=1) { for ($x-1; $x<=$pages; $x++) { echo "<a href=?view=$x>$x</a> "; } } } if(isset($offers)) { echo "View Offers."; } if(isset($create)) { echo "Create a Trade."; } } ?> </html I have marked inside my code by =====----'s where the code part is for the problem I am habing so you know where to look for it. I am hoping somebody can understand my problem. I am thinking I MIGHT have to use an array, or whatever it is called? Thank you for your help and time. =]
-
Hey guys. I have created a forum for my website from scratch. Everything is working great except the part where you create the actual TOPIC. (When you start a new topic). The problem is, I have a select box saying the name like, ie.. "General Chat" and "Help Chat" as two of the options in the dropdown. The topics have a TOPIC ID that also needs to be filled in. How do I go about filling in the topic ID? I don't want to have to go through having to code if statement for every board topic... I have like 8 topics... I know there must be a way around this. I will post the code that has the part where you create the topic. 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="topic"><option value="1">General Chat</option> <option value="2">Help Chat</option> </select><br><br>Body:<br><textarea name="tbody" cols="38" rows="8"></textarea><br><br><input type="submit" name="submit" value="Create Topic"></form> <?php } if(isset($nownow)) { mysql_query("INSERT INTO topics (name, username, body, countit, boardin, created) VALUES ('$name', '$showusername', '$tbody', '0', '$tcat', 'sitetime')"); echo "<font color=green>Success! Your Topic has been created.</font>"; } } } ?> I know there are a lot of curly brackets, but those are also for the other parts of my code... I didn't pos the whole thing. ANy help is greatly appreciated, thank you! =]
-
Hi! I have created a script which is not yet finished. I am just about done with it except for about three parts, and one of the parts of it is the part with the time. I want it be able to function, so when a user presses the "submit" button, the time starts at 59 minutes, and automatically updates. If the time runs out, then they are out of time and have to start over. If they can complete the task in under 59 minutes, then I would like the time to be displayed... like, how much time it took and how long they had left. How would I be able to do this? I know of cron jobs, but I would rather not use cron jobs for this.. I'm pretty sure there are other ways around doing this that are quite simple, but I'm just not understanding it. I'm not really good with PHP time and date yet. I have to use my php books to help me. If any body can help me with this I would very much appreciate it! I will post some code below explaining it as well. I am using this date function for the minutes: $left = date('i');[/code'] I will now post the entire code for the page I need this to work on. [code]<?php session_start(); include("FILE"); ?> <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>Train Your Pets</font><br><br><img src=/images/items/3.gif><img src=/images/items/1.gif><img src=/images/items/2.gif><br><br>Hello there! This is the place where you can train your pet! Each training session will cost you a magical <b>Gem</b>. There are a few different types of gems, and the gem you need will be picked randomly by me.<br><br>"; $traintr = date('i'); $traints = date('i'); $submit = $_POST['submit']; $course = $_POST['train']; $pet = $_POST['pet']; $haveyyu = $_POST['have']; $gem = rand(1, 3); if(!isset($submit)) { ?> <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>"> Please Select a pet to Train: <select name="pet"><?php $gtq = "SELECT * FROM userpets WHERE owner='$showusername'"; $tq = mysql_query("$gtq"); while($t = mysql_fetch_array($tq)) { $tpm = $t['userpetname']; $ts = $t['strength']; $td = $t['defence']; $th = $t['health']; $tl = $t['level']; echo "<option>$tpm</option>"; } ?> </select><br> <br>What would you like to train? <select name="train"><option>Strength</option><option>Defence</option><option>Health</option><option>Level</option></select><br><br><br><input type="submit" name="submit" value="Train Pet"> <?php } if(isset($submit)) { $cinqe = mysql_query("SELECT * FROM train WHERE pet='$pet'"); $cinq = mysql_num_rows($cinqe); if($cinq == 1) { $lgiq = "SELECT * FROM train WHERE owner='$showusername'"; $lqi = mysql_query($lgiq); while($lrow = mysql_fetch_array($lqi)) { $rgem = $lrow['gem']; } echo "<font color=red>Error! Your pet is already on a training course!</font><br><br>It will end in <b>59</b> minutes.<br><br>"; } if($cinq == 0) { $getthisq = "SELECT * FROM train WHERE owner='$showusername'"; $getthis = mysql_query("$getthisq"); while($prow = mysql_fetch_array($getthis)) { $kname = $prow['pet']; } mysql_query("INSERT INTO `train`(`owner`, `pet`, `left`, `stat`, `complete`, `gem`) VALUES ('$showusername','$pet','59','$train','No','$gem')"); mysql_query("UPDATE users SET credits=credits-150 WHERE username='$showusername'"); mysql_query("UPDATE userpets SET $thestat=$thestat+1 WHERE userpetname=$thepetname'"); echo "<font color=green>Success! Your pet is now on a training course!<br><br></font>The course will end in <b>59</b> minutes.<br><br>"; } } } ?> </html> Basically, I want the database to update the stats once they complete what they need to do, if they can do it under the 59 minutes. I haven't completed that parts yet, though. How would I go about doing that? Would I have to create a new table for the time, or can I just extend the "train" table and add new columns to it for the time part? Thank you in advance!
-
Hi! This is probably simple, and I know it is, I just need my memory refreshed at this point. I will show you the data I want to grab in a minute. I want to display the data like this: NAME NAME NAME NAME IMAGE IMAGE IMAGE IMAGE NAME NAME NAME NAME IMAGE IMAGE IMAGE IMAGE etc...(it will ocntinue on with whatever is in the table, and stop when the data stops). I know there will be a simple table involved in this too. Here is the table information and query: $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 "$myname<br><img src=/images/items/$myimage>"; } I am wanting to display the "myname" as the name, and the "my image" as the image, underneath the name. Thank you for your help in advance!
-
Thank you! I knew it it had to be really simple! <3
-
Hey everybody! This is probably a simple fix, but it has been a big issue for me. I have actually in the past changed the whole table to fix this. I want to be professional this time. Basically, I have created a forum. It is a basic forum. There are three separate tables for it, the posts, and topics. I want to be able to let them pick the NAME of the topic they want to create the topic in from a drop down box, but have the query insert it as an id. So, lets say, this: General Chat is id 1 Help Chat is id 2 The drop down I select is Help chat, it will enter 2 instead of help chat. How do I do this the SIMPLE way? thanks! Here is my code fro the forums: <?php session_start(); include("config536.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>Boards</font><br><br>"; $getboardid = $_GET['boardid']; $gettopicid = $_GET['topicid']; $getpostid = $_GET['postid']; $view = $_GET['view']; $newtopic = $_GET['action']; if(isset($view)) { echo "<center>Welcoem to the Boards! Please read the <a href=tos.php>Rules</a> before posting anything. Feel free to browse whenever you'de like. <br><br><table border=1 bordercolor=black cellspacing=0 cellpadding=10><tr><td><center><b>Board Name</b></center></td><td><center><b>Description</b></center></td><td><center><b>Topics</b></center></td><td><center><b>Posts</b></center></td></tr>"; $gettq = "SELECT * FROM category WHERE catid!= '0'"; $gett = mysql_query($gettq); while($rowy = mysql_fetch_array($gett)) { $tid = $rowy['catid']; $tname = $rowy['name']; $tposts = $rowy['posts']; $ttopics = $rowy['topics']; $tdesc = $rowy['body']; echo "<tr><td><center><a href=?boardid=$tid>$tname</a></center></td><td><center>$tdesc</center></td><td><center>$ttopics</center></td><td><center>$tposts</center></td></tr>"; } echo "</table><br><br><a href=?action=create>Create a New Topic</a><br><br><br></center>"; } if(isset($getboardid)) { echo "<table border=1 bordercolor=black cellpadding=10 cellspacing=0><tr><td><center><b>Topic Name</b></center></td><td><center><b>Created By</b></center></td><td><center><b>Date</b></center></td></tr>"; $getbq = "SELECT * FROM topics WHERE boardin='$getboardid'"; $getb = mysql_query($getbq); while($crow = mysql_fetch_array($getb)) { $uname = $crow['username']; $unm = $crow['name']; $ubodu = $crow['body']; $ucount = $crow['countit']; $ucreate = $crow['created']; $utid = $crow['topicid']; echo "<tr><td><center><a href=?topicid=$utid>$unm</a></center></td><td><center>$uname</center></td><td>$ucreate</center></td></tr>"; } echo "</table>"; } if(isset($gettopicid)) { $nowtq = "SELECT * FROM posts WHERE topicon='$gettopicid'"; $nowt = mysql_query($nowtq); while($now = mysql_fetch_array($nowt)) { $postidis = $now['postid']; $poster = $now['poster']; $thisb = $now['body']; $getdate = $now['date']; $gettopic = $now['topicon']; $uq = "SELECT * FROM users WHERE username='$poster'"; $uset = mysql_query($uq); while($row = mysql_fetch_array($uset)) { $did = $row['userid']; $dun = $row['username']; $dpo = $row['posts']; $dmp = $row['mainpet']; $dac = $row['avatarcount']; $dua = $row['useravatar']; $djs = $row['jobs']; $aq = "SELECT * FROM avatars WHERE name='$dua'"; $aaa = mysql_query($aq); while($arow = mysql_fetch_array($aaa)) { $theimage = $arow['image']; } echo "<tr><td><table border=0 cellspacing==1 cellpaddign=3 bgcolor=#F58B8E><tr><td bg color=#FFFFFF align=center valign=top width=100><font face=verdana size=3 color=#000000><br><br><a href=lookup.php?username=$dum>$dun</a><br><br><img src=/images/avatars/$theimage><br><br><br>Posts: $dpo<br><br></font></td><td bgcolor=#FFFFFF align=center valign=top width=300><font face=verdana size=3 color=black><i>Posted on: $getdate</i><br><br>$thisb</font></td></tr></table><br><br><br>"; } } $submitpost = $_POST['post']; $reply = $_POST['reply']; ?> <br><br><br><br><form action="<?php echo "$PHP_SELF"; ?>" method="POST"><center><font size=5>Post a Reply</font><br> <textarea name="reply" rows="5" cols"32"></textarea><br><br><input type="submit" name="post" action="Post Reply"><br><br><br></form></center><?php if(isset($submitpost)) { if($reply == "") { echo "<font color=red>Error! Please enter a reply!</font>"; } if($reply != "") { mysql_query("INSERT INTO posts (poster, body, date, topicon) VALUES ('$showusername', '$reply', '$sitetime', '$gettopicid')"); echo "<font color=green>Success! Your reply has been posted!</font>"; } } } 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="topic"><option>General Chat</option> <option>Help Chat</option> </select><br><br>Body:<br><textarea name="tbody" cols="38" rows="8"></textarea><br><br><input type="submit" name="submit" value="Create Topic"></form> <?php } if(isset($nownow)) { mysql_query("INSERT INTO topics (name, username, body, countit, boardin, created) VALUES ('$name', '$showusername', '$tbody', '0', '$tcat', 'sitetime')"); echo "<font color=green>Success! Your Topic has been created.</font>"; } echo "meeba."; } } ?> </html> The part I'm talking about can be found down by one oft he last if statements. The one that says "if(isset($newtopic)) {" I appreciate any help in advance, thank you!
-
Cam you please re wrote what you just said? I'm not understanding it? ... I use them ALL if the time I'm not seeing how it's not working? Can you please show me how to use it in my code, thanks.
-
Hey guys! I've looked through this code over and over today, and I still haven;t found where my error is. Here is my entire code: <?php session_start(); include("config536.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>Quest Agency</font><br><br>"; $startjob = $_POST['submit']; $jobq = "SELECT * FROM jobs WHERE username='$showusername'"; $job = mysql_query($jobq); $jobnr = mysql_num_rows($job); if($jobnr == "0") { ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <input type="submit" name="submit" value="Start Job"></form> <?php } if(isset($startjob)) { $initemidq = "SELECT * FROM items ORDER BY RAND() LIMIT 1"; $initemid = mysql_query($initemidq); while($ir = mysql_fetch_array($initemid)) { $ids = $ir['itemid']; } mysql_query("INSERT INTO jobs (username, item, time, completed) VALUES ('$showusername', '$ids', 'None', 'No')"); $wegq = "SELECT * FROM items WHERE itemid='$ids'"; $weg = mysql_query($wegq); while($wg = mysql_fetch_array($weg)) { $im = $wg['image']; $nm = $wg['name']; $id = $wg['itemid']; } $_SESSION['theid'] = $id; $yeshere = $_SESSION['theid']; echo "<font color=green>Success! You have started this Job!</font><br><br>Please bring me this item: <b>$nm</b><br><br><img src=/images/items/$im><br><br><br>"; } if($jobnr == "1") { $yeshere = $_SESSION['theid']; $finish = $_POST['finish']; $quit = $_POST['quit']; $okgq = "SELECT * FROM items WHERE itemid='$yeshere'"; $ok = mysql_query($okgq); while($ya = mysql_fetch_array($ok)) { $okname = $ya['name']; $okid = $ya['itemid']; $okimage = $ya['image']; } $yeshere = $_SESSION['theid']; echo "Where is my <b>$okname</b>?<br><br><img src=/images/items/$okimage><br><br><br>"; ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <input type="submit" name="finish" value="I have the Item"><br><br> <input type="submit" name="quit" value="Quit"></form> <?php } } if(isset($finish)) { $yeshere = $_SESSION['theid']; $cinq = "SELECT * FROM uitems WHERE theitemid='$_SESSION[theid]'"; $cin = mysql_query($cinq); $connr = mysql_num_rows($cin); if($connr != "0") { mysql_query("DELETE FROM uitems WHERE username='$showusername' AND theitemid='$yeshere' LIMIT 1"); mysql_query("UPDATE users SET jobs=jobs+1 WHERE username='$showusername'"); mysql_query("UPDATE users SET credits=credits+320 WHERE username='$showusername'"); mysql_query("DELETE FROM jobs WHERE username='$showusername'"); echo "<font color=green>Success! You have completed this job! You have been given <b>320</b> credits as an award. Thank You!</font>"; } else { echo "<font color=red>Error! You do not have my item!</font>"; } if(isset($quit)) { mysql_query("DELETE FROM jobs WHERE username='$showusername'"); echo "<font color=green>Success! You have quit this quest.</font>"; } $yeshere = $_SESSION['theid']; } ?> The variable for the button is: $quit = $_post and I want the quit button to work. Does anybody know why it will not work? Thank you in advance!
-
Hey. Third question today. Very stuck on this one. I am displaying a ton of while loops to display a bunch of data from two different tables. there is NO possible way i can combine the two tables. I mean, I can, but I'm not going to because they are two totally different thins. Anyway. Here is what I'm trying to do: Lets say I have 3 items, a grape, an orange and an apple. - 3 apples - 2 oranges - 1 grape I'm displaying an update price box for each different fruit. (so 3 different boxes), and one submit button. I update it, and it does update the price but it only updates the very first row. I want to be able to update every row I types the price in for. Here is my code: (it is quite long): <?php session_start(); include("config536.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>User Shops</font><br><br>"; $action = $_GET['action']; if(!isset($action)) { 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>"; } if(isset($action)) { $getshopq = "SELECT * FROM usershops WHERE owner='$showusername'"; $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']; } $countq = "SELECT * FROM usershops WHERE owner='$showusername'"; $countit = mysql_query($countq); if($action == "edit") { 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>Edit Shop</font><br><br>"; if(mysql_num_rows($countit)) { ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <?php } if(!mysql_num_rows($countit)) { $create = $_POST['create']; $thename = $_POST['thename']; $thedesc = $_POST['thedesc']; $thestatus = $_POST['thestatus']; $theimage = $_POST['theimage']; if(!isset($create)) { ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> Shop Name: <input type="text" name="thename"><br>Description<br><textarea name="thedesc" rows="5" cols="25"></textarea><br> Status: <select name="thestatus"> <option>Open</option> <option>Closed</option> <option>Gallery</option> </select><br><br> <input type="submit" name="create" value="Create Shop"></form> <?php } if(isset($create)) { if($thename == "" || $thedesc == "") { echo "<font color=red>Error! Please fill out the entire form!</font><br><br>"; ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> Shop Name: <input type="text" name="thename"><br>Description<br><textarea name="thedesc" rows="5" cols="25"></textarea><br> Status: <select name="thestatus"> <option>Open</option> <option>Closed</option> <option>Gallery</option> </select><br><br> <input type="submit" name="create" value="Create Shop"></form> <?php } if($thename != "" && $thedesc != "") { mysql_query("INSERT INTO usershops (owner, name, description, image, status, discount) VALUES ('$showusername', '$thename', '$thedesc', 'image.gif', '$thestatus', 'None')"); echo "<font color=green>Success! You have created your shop! Click <a href=?action=view>here</a> to view it.</font><br><br>"; } } } } if($action == "view") { 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>Shop Name Here</font><br><br>"; $wowq = "SELECT * FROM uitems WHERE username='$showusername' 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 "$myname"; } } } 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 "$fname<br><img src=/images/items/$fimage>"; ?> <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <input type="text" name="price" maxlength="5"><br><br> <?php } } if(isset($updateprice)) { 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>"; } ?> <input type="submit" name="updateprice" value="Update Prices"> <br> <?php } 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>"; } } } ?> </html> To help you find it, I'm asking about the "stock" $_GET part, about three quarters down. Thanks in advance for anybody who can help me, I've been stuck on this script all day! Thanks again!
-
PHP MySQL Forms - Only allow numbers in a textfield
Stalingrad replied to Stalingrad's topic in PHP Coding Help
thanks! -
PHP MySQL Forms - Only allow numbers in a textfield
Stalingrad replied to Stalingrad's topic in PHP Coding Help
Thanks! I'll check and see if that works. The other thing, um.. A while back I let this guy try out my site. He made his name in his profile scroll. XD I want to avoid attacks AND also stop people from running scripts and stuff in places they shouldn't. thanks again! -
Hey again guys! I'm back already today. XD Okay, so... I'm building a script, right. I have a form that is a simple text field. I do NOT want to use javascript. I want to be able to use PHP to be able to do this. Here is the form exactly as it is now: <form action="<?php echo "$PHP_SELF"; ?>" method="POST"> <input type="text" name="price"> How would I only allow a number, and up to 5 digits long, like, for example, a zip code. I know I can always limit the char space, but they might be able to "inject" it? On another note for forms, what would I have to do to get rid of people being able to run a script through a form; is it the strip_tags(); function? Thanks for your help in advance guys!
-
PHP MySQL How to grab one of each row and not duplicates?
Stalingrad replied to Stalingrad's topic in PHP Coding Help
Thanks guys. :_ I am reading about GROUP BY. Yes, it is a reference to the Russian town from a long time ago. -
PHP MySQL How to grab one of each row and not duplicates?
Stalingrad replied to Stalingrad's topic in PHP Coding Help
Thank you for your reply, but what you wrote is a little confusing. What is the , count(id) as c part of it? -
Hey guys! I haven't really coded teh exact query for this yet. But what I want to do is I want to grab multiple results that are the same and only display one BUT also grab DIFFERENT results from the SAME table the same way. Let me give an example here... Lets say this is my table: id - name - image 1 - apple - apple.gif 2 - grape - grape.gif 3 - orange - orange.gif 4 - apple - apple.gif 5 - apple - apple.gif 6 - orange - orange.gif I want it to diaply like this: Apple -apple.gif- Quantity: 3 Orange -orange.gif- Quantity: 2 Grape -grape.gif- Quantity: 1 My query for LIMIT 1 would look like this, but it only grabs one result toal.. i think.. I would also be grabbing stuff from two different tables, which wouldn't be an issue. in this case, i want to grab the QUANTITY form one table, )the uitems table) and the image and name from the items table) the uitems query is also grabbing theitemid to use with the items table.. \\ this would be getting the quantity \\ $query = "SELECT * FROM uitems WHERE username='$showusername' AND location='2'"; $thisthat = mysql_query($query); while($row = mysql_fetch_array($thisthat)) { $quantity = $row['quantity']; $getid = $ow['theitemid']; } \\ now getting the item info \\ $itemquery = "SELECT * FROM items WHERE itemid='$getid'"; $item = mysql_query($itemquery); while($thisrow = mysql_fetch_array($item)) { $name = $thisrow['name']; $image = $thisrow['image']; $actualid = $thisrow['itemid']; } So basically, I want to be able to be able to grab one row of every kind that is there. How can I do that? Thanks so much in advance!! =D
-
How to Simply remove characters and spaces from a form text box.
Stalingrad replied to Stalingrad's topic in PHP Coding Help
ok im usign the following if statement, and it isn't working: if( !ctype_alnum(str_replace('_', '', $field)) || $grabnum >= "4" || $petname == "" | $checkit == "1") { echo "<font color=red>Error! Pet names must only have letters, numbers, or underscores.</font>"; } look above to see my old code for what teh other statements are. how do I throw it all into one?