Jump to content

I need HELP PLEASE! Tryign to grab from two different tables!


Stalingrad

Recommended Posts

THSI IS URGENT!! NEEDS TO BE DONE WITHIN NEXT FEW MINUTES! I HAVE BEEN WORKING ON IT FOR WEEKS NOW!!!

I have a url get variable from the "uitems" table. it is stored in the url and carries over to the next page. I have tables: "uitems" and "items" the "items" table stors all of the info about the items. the "uitems" table stores where the item is for each certain user. I want to be able to grab the item information from the "items" table with the variable from the "uitems" table. the "uitems" table has the id stored from the "items" table. here:

items - itemid > the id of the item i want to grab.\

uitems - item id (this is the unique id for the the USERSi tem

uitems - theitemid - this is the id of the itemid from the items table/

all i have is the get variable in the url telling what the ITEMID is from the uitems table. i want to grab the items table rows from it with that. PLEASE HELP!!

here is my code:

bag.php:

<?php
session_start();
include("config536.php");
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<?php
if(!isset($_SESSION['username'])) {
echo "<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><content><center><font size=6>Inventory</font><br><br></center></content>";
}

if(isset($_SESSION['username'])) {
echo "<nav>$shownavbar</nav><ubar><img src=/images/layout/player.gif><a href=status.php>$showusername</a>.......................<img src=/images/layout/coin.gif> $scredits</ubar><content><center><font size=6>Inventory</font><br><br>";

$action = $_GET['action'];
$gid = $_GET['usitemid'];
$col = "4";
echo "<table border=0>";
echo "<tr>";
if(!isset($action)) {
$irow = "SELECT * FROM uitems WHERE username='$showusername' AND location='1'";
$iquery = mysql_query($irow);
while($ir = mysql_fetch_array($iquery)) {
$uid = $ir['uitemid'];
$iid = $ir['theitemid'];
$iun = $r['username'];
$il = $ir['location'];


$tirow = "SELECT * FROM items WHERE itemid='$iid'";
$tiquery = mysql_query($tirow);
while($tir = mysql_fetch_array($tiquery)) {
$tiid = $tir['itemid'];
$tin = $tir['name'];
$tiim = $tir['image'];
$tid = $tir['description'];
$tirr = $tir['rarity'];
$tit = $tir['type'];
$tiu = $tir['uses'];
$tis = $tir['strength'];
$tide = $tir['defense'];
$tih = $tir['heals'];
echo "<td><center><a href=?action=view&usitemid=$uid><img src=/images/items/$tiim></a> ".$tir['name']."</center></td>";
$col--;
if(!$col) {
echo "</tr><tr>";
   $col=4; 
}
}
}
}
if(isset($action)) {
$iiwuery = "SELECT items.name, uitems.uitemid ".
"FROM items, uitems ".
"WHERE items.itemid = uitems.theitemid";

$tiresult = mysql_query($iiwuery) or die(mysql_error());


while($brow = mysql_fetch_array($tiresult)){
$cid = $brow['uitemid'];
$cin = $brow['name'];
}
echo "$cid and $cin";
$qer = "SELECT * FROM items WHERE itemid='$cid'";
$tqer = mysql_query($qer);
while($rune = mysql_fetch_array($tqer)) {
$dtin = $rune['name'];
$dtii = $rune['image'];
$dtid = $rune['description'];
$dtir = $rune['rarity'];
$dtty = $rune['type'];
echo "<b>$dtin</b><br><br><img src=/images/items/$dtii><br><i>$dtid</i><br><b>Rarity:</b> $dtir<br><b>Item Type:</b> $dtty<br><br><br>";
}

}
}
?>

</html>

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.