priory Posted March 11, 2009 Share Posted March 11, 2009 Hi, I think this should be fairly simple but I'm a noob. I am trying to post back a list of item names that match a query. The tables look like [itemName, ItemKey] [basketKey, ItemKey] When given a particular basket key I tried selecting all ItemKeys that matched and then adding them to an array, I then tried using that array to search for the ItemName and return it as an array to echo: $itemselect = mysql_query("SELECT ItemKey FROM temp_basket WHERE BasketKey = '$sessionid'"); while ($itemresult = mysql_fetch_array($itemselect)) { $itemvariable = $itemresult['ItemKey']; $itemlookupquery = mysql_query("SELECT ItemName FROM item_lookup WHERE ItemKey = '$itemvariable'"); $itemnamearray = mysql_fetch_array($itemlookupquery); $itemname = $itemnamearray[0]; echo $itemname; } The problem is it seems to be returning all the results in one index position so the results come out as one long unformatted string. Do I manually have to increase the index position using a loop or is there a better way? Quote Link to comment https://forums.phpfreaks.com/topic/148956-working-with-arrays-and-queries-index-problem/ Share on other sites More sharing options...
MadnessRed Posted March 11, 2009 Share Posted March 11, 2009 perhaps if you used a line break? echo $itemname."<br />"; edit: | \/ thanks - sorted now Quote Link to comment https://forums.phpfreaks.com/topic/148956-working-with-arrays-and-queries-index-problem/#findComment-782224 Share on other sites More sharing options...
Maq Posted March 11, 2009 Share Posted March 11, 2009 perhaps if you used a line break? echo $itemname." ; Missing a quote echo $itemname . " "; Quote Link to comment https://forums.phpfreaks.com/topic/148956-working-with-arrays-and-queries-index-problem/#findComment-782228 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.