Jump to content

Recommended Posts

Well I am retrieving database properties from two tables(items and inventory), but I do not know how to do this easily so I tried the method below, in which I use mysql_fetch_array($result) for properties of table prefix_inventory and mysql_fetch_array($result2) for properties of table prefix_items. It does not work at all though, only the first mysql_fetch_array works, the second one will not retrieve any database information for me. What have I done wrong, is there a way to fix this?

 

$result = mysql_query("SELECT * FROM {$prefix}inventory WHERE owner ='{$loggedinname}'");
    
while($row = mysql_fetch_array($result)){
// First we need to retrieve item properties.
$result2 = mysql_query("SELECT * FROM {$prefix}items WHERE itemname ='{$row['itemname']}'");
$items = mysql_fetch_array($result2);
$article_content .= "<tr>
                      <td><img src='{$items['imageurl']}'></td>
					  <td>{$row['category']}</td>
					  <td>{$row['itemname']}</td>
					  <td>{$items['description']}</td>
					  <td>{$row['quantity']}</td>";
                                                  // There are still lines below, but wont make a difference even if I post them

 

Link to comment
https://forums.phpfreaks.com/topic/243451-mysql_fetch_array-problem/
Share on other sites

The {} are needed around associative array variables inside of strings so that you can keep the quotes around the associative key name without breaking the string syntax. You can also use them around any php variable inside of a string for those cases where you need to tell php where variables start and end. See the Complex (curly) syntax section at this link - http://cn.php.net/manual/en/language.types.string.php

 

 

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.