Th3Boss Posted March 31, 2013 Share Posted March 31, 2013 (edited) Pretty sure im doing this completely wrong. while($row = mysql_fetch_array($result)){ if($row['slot'] == 'high') { $i=1; while($i<= { $name[$i] .= $row['name']."" ; $typeID[$i] .= $row['typeID']."" ; $i++; } } else { } } There will always be 0 to 8 items that are 'high' in the database $row['slot']. I want all of the 'name' and 'typeID' to be as: $name1$typeID1 $name2$typeID2 $name3$typeID3 and so on up to how ever many there is, but no more than 8 How do I do something like this? (Sorry if that is a terrible explanation) Edited March 31, 2013 by Th3Boss Quote Link to comment https://forums.phpfreaks.com/topic/276344-help-needed/ Share on other sites More sharing options...
Barand Posted March 31, 2013 Share Posted March 31, 2013 Why don't you select those where slot = 'high' in the query and set LIMIT 8? Quote Link to comment https://forums.phpfreaks.com/topic/276344-help-needed/#findComment-1422056 Share on other sites More sharing options...
Th3Boss Posted March 31, 2013 Author Share Posted March 31, 2013 Why don't you select those where slot = 'high' in the query and set LIMIT 8? Right now in the query it selects all of that data i need from the database and now I need to set all of that data as the correct variables. Quote Link to comment https://forums.phpfreaks.com/topic/276344-help-needed/#findComment-1422057 Share on other sites More sharing options...
Jessica Posted March 31, 2013 Share Posted March 31, 2013 Or make your code use arrays. That's what they're there for. Quote Link to comment https://forums.phpfreaks.com/topic/276344-help-needed/#findComment-1422068 Share on other sites More sharing options...
Th3Boss Posted March 31, 2013 Author Share Posted March 31, 2013 Or make your code use arrays. That's what they're there for. Can you do an example of how I can do this with arrays? Quote Link to comment https://forums.phpfreaks.com/topic/276344-help-needed/#findComment-1422070 Share on other sites More sharing options...
Jessica Posted March 31, 2013 Share Posted March 31, 2013 It already IS an array. Quote Link to comment https://forums.phpfreaks.com/topic/276344-help-needed/#findComment-1422089 Share on other sites More sharing options...
Th3Boss Posted March 31, 2013 Author Share Posted March 31, 2013 anyone able to help? Quote Link to comment https://forums.phpfreaks.com/topic/276344-help-needed/#findComment-1422136 Share on other sites More sharing options...
Solution Th3Boss Posted April 1, 2013 Author Solution Share Posted April 1, 2013 after lots or searching and reading I finally figured it out. http://stackoverflow.com/questions/10371502/storing-multiple-rows-from-mysql-in-separate-variables Quote Link to comment https://forums.phpfreaks.com/topic/276344-help-needed/#findComment-1422181 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.