Jump to content

Recommended Posts

<?php require("styles/top.php"); ?>

<?php
if(isLoggedin($valid)){
?>
<center><h1>Your Items</h1></center>
<?php
$query = mysql_query("SELECT * FROM farcry_crime_town.user_items WHERE userid='$userid'");
$numrows = mysql_num_rows($query);
if($numrows > 0){
while($row = mysql_fetch_assoc($query)){

  } else {
echo"An error has occured, please refresh this page.";
  }
} else {
echo"You have no items.";
}

?>


<?php
} else {
?>


<?php
}
?>

So I have a user_items table that has:

userid (So it keeps track of who has the item)

the item_id

and the item_name

 

However, I also have an items table that has:

item_id

item_name

item_description

item_type

item_desc

item_cost

item_sell_value

 

I want to grab the item_type row from the item table by comparing the item_name from the two tables and have them be in one result set. How can I acheive this? Thanks.

You need to use a join if you want to select from multiple tables in a single query.  Just compare the item ID's from both tables.

 

http://phpweby.com/tutorials/mysql/32

 

Also, no need to put the item_name column in user_items because it is already in the items table.  You can grab the name from the items table when you write your query.

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.