Having trouble grabbing multiple fields from one row

Hey. :slight_smile: I’m new here and I have a big problem with a page I am coding for my website. I will try my best to explain what I am trying to do without confusing anybody too much. Okay. I have created this page with pagination. Which is working great, 100%. The only problem now is I want to grab some data form a table, and am having trouble displaying it/grabbing it really, even. I have a table with 7 rows that have "item1 - item7. I can only figure out how to display one of them, so I chose to display the first one, item one. These are all in the table “trades”. In this I am using 3 different tables: trades, uitems and items. I have to resort to inserting all of the item data into the trade table (the item1 - item7 date), because I’m not sure how to grab the ids… I’m no where near new at programming, I’ve been a programmer for 10 years now. But some things confuse me. Anyhow, here is my code:
[php]<?php
session_start();
include(“configfile.php”);
?>

<?php if(!isset($_SESSION['username'])) { echo "$shownavbarLogin or RegisterError!

You are not Logged In! Please Login or Register to Continue!"; } if(isset($_SESSION['username'])) { $view = $_GET['view']; $offers = $_GET['offers']; $create = $_GET['create']; echo "$shownavbar$ubearTrade Center

Hello there, and welcome to the Trade Center! It is advised you be careful when trading, as other users may try to scam you.

Home | Create a Trade | View Trades | My Offers

"; 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 "";============== } if($pages >=1) { for ($x-1; $x<=$pages; $x++) { echo "$x "; } } } if(isset($offers)) { echo "View Offers."; } if(isset($create)) { echo "Create a Trade."; } } ?> </html [/php]

I have added ========='s where the code I am having trouble with. I would like to display item1 = item7 all by one query. So it would be grabbing them by the getuitemsquery but there is also a lot involving the other queries as well… thank you for your time. Sorry if I have confused you. This is hopefully, and most likely something easily done, but I’m just completely lost. Thanks again. :slight_smile:

Owner: $query[user]


$name

Some join examples:

SELECT * FROM table1, table2;

SELECT * FROM table1 INNER JOIN table2 ON table1.id=table2.id;

SELECT * FROM table1 LEFT JOIN table2 ON table1.id=table2.id;

SELECT * FROM table1 LEFT JOIN table2 USING (id);

SELECT * FROM table1 LEFT JOIN table2 ON table1.id=table2.id
  LEFT JOIN table3 ON table2.id=table3.id;

and here is union for mysql
http://dev.mysql.com/doc/refman/5.0/en/union.html

Sponsor our Newsletter | Privacy Policy | Terms of Service