Jump to content

Stalingrad

Members
  • Posts

    123
  • Joined

  • Last visited

Everything posted by Stalingrad

  1. I think you would use JavaScript in this case. I'm not really good with JavaScript. Try Googling... "JavaScript Dropdown Menu". Sorry I couldn't help you much. ='^[
  2. Ahh, it's still not working. I have no clue why. o: Thank you VERY much for all of your help. =D
  3. Ahh, that's grabbing the items from the items table. I want to grab the items from the user items table (uitems), but have the properties that the items table has for the id of the items in the uitems table.
  4. Thanks! I'll try that... but, what would the statement be?
  5. Nothing yet. It's just grabbing the user's item information.
  6. Try setting the session as a variable first... that's the first thing I can think of.
  7. Yes, the $uid is set. It is set in my config file.
  8. Hi! I'm coding something, but I can't grab the data from my database. I'm wanting to select all of the items from a table where they belong to a certain user. At the same time, I'm trying to grab the image, name, description, etc. of the item that the user has. Like... for example; I have a user with two different items named "Apple" and "Banana". In the user items table, it stores the primary keyed id, the id of the user, the itemid from the items table. In the "items" table, it has all of the basic information from the item: name, description, images, etc. Here is my code: I'm doing it wrong...: <?php session_start(); include("config.php"); if(isset($_SESSION["user"])) { echo "<div id=ban>My Pet Game</div><div id=nav>$lshownav<br></div><div id=content>"; $query = "SELECT * FROM uitems WHERE userid='$uid' AND location='1'"; $result = mysql_query($query); while($row = mysql_fetch_array($result)) { $itemid = $row['theitemid']; $uitemid = $row['uitemid']; $loc = $row['location']; } $itemquery = "SELECT * FROM items"; $itemresult = mysql_query($itemquery); while($itemrow = @mysql_fetch_array($itemresult)) { $theiid = $itemrow['itemid']; $iname = $itemrow['name']; $iimage = $itemrow['image']; $idesc = $itemrow['description']; $itype = $itemrow['type']; $irarity = $itemrow['rarity']; } echo "<a href=?act=view&uitemid=$uitemid><img src=items/$iimage></a><br>$iname"; } if(!isset($_SESSION["user"])) { echo "<div id=ban>My Pet Game</div><div id=nav>$nlshownav<br></div><div id=content>Please <a href=login.php>Login</a> or <a href=register.php>Register</a> to Continue.</div>"; } ?> Can somebody please help me get the correct code? Thanks in advance.
  9. How do I set a session variable? Also... is there any other way to do it if the rand() code is bad? Thanks!
  10. Hi! I'm having a problem with setting a random variable after I select a random row from a table. I have no problem with selecting the random row. I just can't get the variable to stay as it was selected. Each time I re-visit the page, it changes to the newly randomly selected variable. I want the variable to stay the same until I press the submit button. Here is my code: <?php require("global.php"); loggedin(); echo "<font size=6>Quests</font><br><br>"; $action = $_GET[act]; $reward = rand(100, 500); $gettheitem = mysql_query("SELECT id FROM items ORDER BY RAND() LIMIT 1"); $qnquery = "SELECT * FROM quests WHERE userid='$id'"; $qnresult = mysql_query($qnquery); while($qnrow = mysql_fetch_array($qnresult)) { $checkstatus1 = $qnrow['qon']; } $squery = "SELECT * FROM user WHERE id='$id'"; $sresult = mysql_query($squery); while($srow = mysql_fetch_array($sresult)) { $cquests = $srow['questscore']; $fquests = $srow['questsfailed']; } $randitemq = mysql_query("SELECT * FROM items WHERE id!='0'"); $crandit = mysql_num_rows($randitemq); $randit = rand(1, $crandit); $getitem = mysql_fetch_row(mysql_query("SELECT * FROM items WHERE id='$randit '")); $randomitem1 = "SELECT * FROM items ORDER BY rand() LIMIT 1"; $resultt = mysql_query($randomitem1); while($iroww = mysql_fetch_array($resultt)) { $itemimagee = $iroww['image']; $itemname1 = $iroww['name']; $grabitem1 = $iroww['id']; } $grabq = "SELECT * FROM items WHERE id!=0"; $grabresult = mysql_query($grabq); while($grow = mysql_fetch_array($grabresult)){ $itemimage = $grow['image']; $itemname = $grow['name']; $grabitem = $grow['id']; } if($checkstatus1 == "No") { echo "Hey There! Welcome to the Quest page! Here you can complete jobs for the workers of SadHazel. You have unlimited time per-quest. The reward will be in coins, and it's a random amount. You never know how much you'll get until you complete the quest!<br><br>"; ?> <html><form action="<?php echo "$PHP_SELF"; ?>" method="get"> <input type="submit" name="act" value="start"><br><br></html> <?php echo "You have currently completed <b>$cquests</a> Quests!<br>However... you have failed <b>$fquests</b> Quests"; if($action == "start") { mysql_query("UPDATE quests SET itemid = '$grabitem1', `qon` = 'Yes' where userid = '$id' "); echo "Hey there again! I'd like you to bring me this item, please: <br><br><img src=/items/$itemimagee><br><b>$itemname1</b><br><br>"; } } if($checkstatus1 == "Yes") { echo "Hey there yet again! I'll remind you what item I need: <br><br><img src=items/$itemimagee><br><b>$itemname1</b><br><br>"; ?> <html><form action="<?php echo "$PHP_SELF"; ?>" method="get"> <input type="submit" name="act" value="have"><br><br></form></html> <html><form action="<?php echo "$PHP_SELF"; ?>" method="get"> <input type="submit" name="act" value="quit"><br><br></form></html> <? if($action == "quit") { mysql_query("UPDATE quests SET itemid = '0', `qon` = 'No' where userid = '$id' "); mysql_query("UPDATE user SET questsfailed=$fquests +1 WHERE id='$id'"); echo "Oh no! It looks like you've given up!"; } if($action == "have") { $hiquery = "SELECT * FROM user_items WHERE owner='$YourName' AND itemid='$grabitem1'"; $haveit = mysql_query($hiquery) or die(mysql_error()); $haveitornot = mysql_num_rows($haveit); $theitem = mysql_query("SELECT itemid FROM user_items WHERE owner='$YourName'"); if($haveitornot != "0") { mysql_query("UPDATE user SET questscore=$cquests +1 WHERE id= '$id'"); mysql_query ("UPDATE user SET point=$points +$reward WHERE id='$id'"); mysql_query("UPDATE quests SET itemid = '0', `qon` = 'No' where userid = '$id' "); mysql_query("DELETE FROM user_items WHERE itemid='$grabitem1' AND owner='$YourName' LIMIT 1"); echo "<font color=green>Success! You have completed this quest.</font><br><br>To thank you, I'll give you <b>$reward</b> Coins!<br><br>"; } if($haveitornot == "0") { echo "<font color=red>Error! You don't have the item!</font><br><br>"; } } } ?> Please Note: I have some variables there taht aren't being used. They are simply there just in case I mess up... I don't want to lose variables that previously worked. Any help is appreciated... thank you in advance! =]
  11. It shows 3 quantity for each row because I can't merge the row into one. Like, I want it to show that I have 3 of the item. In the database, I have 3 different item id's. Each item has a unique item id. I want to show that I have three of the same item name, but three different item ids.
  12. Oh, okay. Thank You. I though LIMIT 1 limited everything to 1. Does it only limit 1 for the certain item?
  13. It would only be 3, because I only have 3 pineapples. It shows it 3 times because it's showing a row in the table for each pineapple plus the amout I have altogether.
  14. $showitemsquery = mysql_query("SELECT * FROM useritems WHERE location='Shop' AND username='$username'")
  15. Hello. I'm building a shops script for my website. I want to be able to show all of the items somebody has in their shop, and how many of that item they have. I've run into a little problem. I know how to show how many of the item they have, but how do I make it so that it shows only one row for that item, instead of one row for each item they have? Here's an example: Let's say I have three pineapples. It shows this in the stock table: Item Quantity Price Delete? Pineapple 3 300 X Pineapple 3 300 X Pineapple 3 300 X My question is, how do I get it to show like this: Item Quantity Price Delete? Pineapple 3 300 X I want it to show only once. If anybody could help me out, and show me how to do this with simple PHP, I would really appreciate it, thank you! =]
  16. Blade - I wasn't asking you to write it for me. I was just confused, as the strip_tags() function is new to me. Sorry for the double-post.
  17. Thank You. One more question: what is the $tobestripped variable supposed to be, and what is the $stripped variable supposed to be, and what do I put to echo the $ui_lookup with the strip_tags and stuff?
  18. Thanks. I'm not understanding that though.
  19. Oh, okay. Thanks. So if I have the following variable $ui_lookup, how would I put the strip_tags and the $allowable_tags?
  20. Thank you. But what do you mean the second arguement? May you please show me what the second arguement is and how to use it? Thanks. =]
  21. Hello! I'm working on the profile page for my website, and I m having a little trouble. I want to be able to allow users to use HTML on their user lookups, and only HTML. (Well, and normal text, if they don't use HTML). How do I allow them to do so? Right now I'm using the strip_tags() function, but It strips the HTML tags too, which I don't want. Is there any wya to allow this? Any help is greatly appreciated. Thanks in advance. =]
  22. Hello. I'm trying to program a simple Forum for my website, but I've run into a bit of a problem. The form is using two GET statements 9the action and the topic ID), and when I fill out the form and press submit, it doesn't do anything. Does anybody know what my problem might be? Here's the code: <?php include("config.php"); if($_SESSION['username'] == "" || $_SESSION['password'] == "") { notloggedin(); } if($_SESSION['username'] != "" && $_SESSION['password'] != "") { start(); $action = $_GET['action']; $postreply = $_POST['reply']; $postthread = $_POST['thread']; $thread_title = $_POST['threadtitle']; $thread_body = $_POST['threadbody']; $thread_board = $_POST['threadboard']; $reply_body = $_POST['replybody']; echo "<font size=6>Boards</font><br><br><a href=boards.php?action=create>New Topic</a><br><br>"; if(!isset($action)) { echo "<table border=\"1\" bordercolor=\"black\" cellpadding=\"5\" cellspacing=\"0\"><tr><td><center>Category</center></td><td><center>Description</center></td><td><center>Topics</center></td></tr>"; $boardsquery = mysql_query("SELECT * FROM boards"); while($brow = mysql_fetch_array($boardsquery)) { echo "<tr><td><center><a href=boards.php?action=view&boardid=$brow[id]>$brow[name]</a></center></td><td><center>$brow[description]</center></td><td><center>$brow[topics]</center></td></tr>"; } echo "</table>"; } if($action == "view") { $boardquery = mysql_query("SELECT * FROM boards WHERE id='$_GET[boardid]'"); while($bsrow = mysql_fetch_array($boardquery)) { $boardcategory = $bsrow['name']; } echo "<font size=5>$boardcategory</font><br><br><table border=\"1\" bordercolor=\"black\" cellpadding=\"5\" cellspacing=\"0\"><tr><td><center>Title</center></td><td><center>Author</center></td><td><center>Date</center></td><td><center>Replies</center></td></tr>"; $showquery = mysql_query("SELECT * FROM boardtopics WHERE category='$_GET[boardid]'"); while($srow = mysql_fetch_array($showquery)) { echo "<tr><td><center><a href=boards.php?action=topic&topicid=$srow[topicid]>$srow[title]</a></center></td><td><center><a href=search.php?username=$srow[author]>$srow[author]</center></td><td><center>$srow[date]</center></td><td><center>$srow[replies]</center></td></tr>"; } } if($action == "topic") { $showtopicq = mysql_query("SELECT * FROM boardtopics WHERE topicid='$_GET[topicid]'"); while($strow = mysql_fetch_array($showtopicq)) { $thetopictitle = $strow['title']; $theauthor = $strow['author']; $thetopicdate = $strow['date']; $thetopicbody = $strow['message']; } echo "<font size=4>$thetopictitle</font><table border=\"1\" bordercolor=\"black\" cellpadding=\"5\" cellspacing=\"0\"><tr><td>Posted by:<a href=search.php?username=$theauthor>$theauthor</a> on $thetopicdate<br></td></tr><tr><td>$thetopicbody</td></tr></table><br><br><br><br><table border=\"1\" bordercolor=\"black\" cellpadding=\"5\" cellspacing=\"0\">"; $rquery = mysql_query("SELECT * FROM boardposts WHERE topic='$_GET[topicid]'"); while($rrow = mysql_fetch_array($rquery)) { echo "<tr><td>Posted by: <a href=search.php?username=$rrow[username]>$rrow[username]</a> on $rrow[date]<br></td></tr><tr><td>$rrow[body]</td></tr>"; } echo "<br><br><br><a href=boards.php?action=reply&topicid=$_GET[topicid]>Post a Reply</a>"; } if($action == "reply") { // HERE IS WHERE THE REPLY THING STARTS if(!isset($postreply)) { ?> <html><form action="<?php echo "$PHP_SELF"; ?>" method="POST">Your Reply: <br><textarea name="replybody" rows="8" cols="30"></textarea><br><br><br><input type="submit" name="postreply" value="Reply"></form></html><?php } if(isset($postreply)) { if($reply_body == "") { echo "<font color=red>Error! Please type in a Reply."; ?> <html><form action="<?php echo "$PHP_SELF"; ?>" method="POST">Your Reply: <br><textarea name="replybody" rows="8" cols="30"></textarea><br><br><br><input type="submit" name="postreply" value="Reply"></form></html><?php } if($reply_body != "") { mysql_query("INSERT INTO boardposts (topic, username, date, body) VALUES ('$_GET[topicid]', '$username', '$thedate', '$reply_body')"); mysql_query("UPDATE boardtopics SET replies=replies+1 WHERE topicid='$_GET[topicid]'"); mysql_query("INSERT INTO posthistory (username, body) VALUES ('$username', '$reply_body')"); echo "<font color=green>Success! Your Reply has been Posted.</font>"; } } } // HERE IS WHERE THE REPLY THING ENDS if($action == "create") { if(!isset($postthread)) { ?> <html><form action="<?php echo "$PHP_SELF"; ?>" method="POST">Topic Title: <input type="text" name="threadtitle" maxlength="60"><br><br>Thread Body:<br><textarea name="threadbody" rows="8" cols="30"></textarea><br><br>Board Category: <select name="threadboard"><option>General Discussion Board</option><option>Help Board</option><option>Art Board</option><option>Avatar Board</option><option>Suggestion Board</option><option>Advertisement Board</option><option>Clubs Board</option><option>Restock Board</option></select><br><br><br><input type="submit" name="thread" value="Post Thread"></form></html><?php } if(isset($postthread)) { if($thread_title == "" || $thread_body == "") { echo "<font color=red>Error! Please fill in the Entire Form.</font><br><br>"; ?> <html><form action="<?php echo "$PHP_SELF"; ?>" method="POST">Topic Title: <input type="text" name="threadtitle" maxlength="60"><br><br>Thread Body:<br><textarea name="threadbody" rows="8" cols="30"></textarea><br><br>Board Category: <select name="threadboard"><option>General Discussion Board</option><option>Help Board</option><option>Art Board</option><option>Avatar Board</option><option>Suggestion Board</option><option>Advertisement Board</option><option>Clubs Board</option><option>Restock Board</option><option>Bug Board</option></select><br><br><br><input type="submit" name="thread" value="Post Thread"></form></html><?php } if($thread_body != "" && $thread_title != "") { if($thread_board == "General Discussion Board") { mysql_query("INSERT INTO boardtopics (category, author, title, date, message, status, replies, pinned) VALUES ('1', '$username', '$thread_title', '$thedate', '$thread_body', 'Open', '0', 'No')"); mysql_query("UPDATE boards SET topics=topics+1 WHERE id='1'"); echo "<font color=green>Success! Your Topic has been Posted."; } if($thread_board == "Help Board") { mysql_query("INSERT INTO boardtopics (category, author, title, date, message, status, replies, pinned) VALUES ('2', '$username', '$thread_title', '$thedate', '$thread_body', 'Open', '0', 'No')"); mysql_query("UPDATE boards SET topics=topics+1 WHERE id='2"); echo "<font color=green>Success! Your Topic has been Posted."; } if($thread_board == "Art Board") { mysql_query("INSERT INTO boardtopics (category, author, title, date, message, status, replies, pinned) VALUES ('3', '$username', '$thread_title', '$thedate', '$thread_body', 'Open', '0', 'No')"); mysql_query("UPDATE boards SET topics=topics+1 WHERE id='3'"); echo "<font color=green>Success! Your Topic has been Posted."; } if($thread_board == "Avatar Board") { mysql_query("INSERT INTO boardtopics (category, author, title, date, message, status, replies, pinned) VALUES ('4', '$username', '$thread_title', '$thedate', '$thread_body', 'Open', '0', 'No')"); mysql_query("UPDATE boards SET topics=topics+1 WHERE id='4'"); echo "<font color=green>Success! Your Topic has been Posted."; } if($thread_board == "Suggestion Board") { mysql_query("INSERT INTO boardtopics (category, author, title, date, message, status, replies, pinned) VALUES ('5', '$username', '$thread_title', '$thedate', '$thread_body', 'Open', '0', 'No')"); mysql_query("UPDATE boards SET topics=topics+1 WHERE id='5'"); echo "<font color=green>Success! Your Topic has been Posted."; } if($thread_board == "Advertisement Board") { mysql_query("INSERT INTO boardtopics (category, author, title, date, message, status, replies, pinned) VALUES ('6', '$username', '$thread_title', '$thedate', '$thread_body', 'Open', '0', 'No')"); mysql_query("UPDATE boards SET topics=topics+1 WHERE id='6'"); echo "<font color=green>Success! Your Topic has been Posted."; } if($thread_board == "Clubs Board") { mysql_query("INSERT INTO boardtopics (category, author, title, date, message, status, replies, pinned) VALUES ('7', '$username', '$thread_title', '$thedate', '$thread_body', 'Open', '0', 'No')"); echo "<font color=green>Success! Your Topic has been Posted."; } if($thread_board == "Restock Board") { mysql_query("INSERT INTO boardtopics (category, author, title, date, message, status, replies, pinned) VALUES ('8', '$username', '$thread_title', '$thedate', '$thread_body', 'Open', '0', 'No')"); mysql_query("UPDATE boards SET topics=topics+1 WHERE id='8'"); echo "<font color=green>Success! Your Topic has been Posted."; } if($thread_board == "Bug Board") { mysql_query("INSERT INTO boardtopics (category, author, title, date, message, status, replies, pinned) VALUES ('9', '$username', '$thread_title', '$thedate', '$thread_body', 'Open', '0', 'No')"); mysql_query("UPDATE boards SET topics=topics+1 WHERE id='9'"); echo "<font color=green>Success! Your Topic has been Posted."; } } } } stop(); } ?> Any help is eatly apprecitated, thank you! =]
×
×
  • 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.