Re: Is there a better way to do this?
| From: | Bas Jobsen | Date: | Fri, 15 Mar 2002 19:34:33 +0000 |
| Subject: | Re: Is there a better way to do this? | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-17702@lists.php.net to get a copy of this message | ||
Maybe you can built one big query?
$query="SELECT name FROM item_types WHERE ";
for ($x=0;$x<$Amount_of_seleted_items; $x++)
{
if($x>0) $query.=" OR "
$query.="id='selectedid$x'";
}
if your add a order by statement to this query and you order the selected
items in the same way. You will know which name in you result set is related
to which id.
Op vrijdag 15 maart 2002 19:41, schreef Leif K-Brooks:
> I operate a small game site for kids. On this site, the players can,
> among other things, buy virtual items. I have each item stored in a table
> called "items" in a mysql database. The type is one column in that table,
> but it is a number, not a name. When I want to display items with the item
> name, I have to send a query to the item_types table to get the type name.
> The problem is, if a user has 50 items, it takes 50 queries to get the
> types. Is there any better way?