Jump to content

Having Trouble Grabbing From Table, Please Help. :s


Stalingrad

Recommended Posts

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. =]

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.