skoobi Posted October 26, 2011 Share Posted October 26, 2011 Hi im not sure if this can be done or not but im trying to do a site without using mysql and i want to be able to compare 3 values and depending on the values have them aranged lowest to highest... for example: Apple = 8 Pear = 3 Bannana = 5 so the results would be displayed like... Pear with a total of 3 bannana with a total of 5 Apple with a total of 8 Is this possible using just PHP or will i need to use Mysql as well... Thank you Chris Quote Link to comment https://forums.phpfreaks.com/topic/249845-comparing-values-and-displaying-without-database/ Share on other sites More sharing options...
AyKay47 Posted October 26, 2011 Share Posted October 26, 2011 I strongly recommend that you use a database to store your information. While there are ways to store information without using a database, using a database can greatly decrease the coders workload and help to maintain an organized data system.. that being said, for this particular problem, you can use an array and sort the values. $arr = array("Apple" => 8, "Pear" => 3, "Banana" => 5); asort($arr,SORT_NUMERIC); foreach($arr as $key => $value){ echo "$key with a total of $value <br />"; } Quote Link to comment https://forums.phpfreaks.com/topic/249845-comparing-values-and-displaying-without-database/#findComment-1282410 Share on other sites More sharing options...
Drongo_III Posted October 26, 2011 Share Posted October 26, 2011 Where are the values coming from in the first place? Query string? Input form? Hi im not sure if this can be done or not but im trying to do a site without using mysql and i want to be able to compare 3 values and depending on the values have them aranged lowest to highest... for example: Apple = 8 Pear = 3 Bannana = 5 so the results would be displayed like... Pear with a total of 3 bannana with a total of 5 Apple with a total of 8 Is this possible using just PHP or will i need to use Mysql as well... Thank you Chris Quote Link to comment https://forums.phpfreaks.com/topic/249845-comparing-values-and-displaying-without-database/#findComment-1282430 Share on other sites More sharing options...
skoobi Posted October 27, 2011 Author Share Posted October 27, 2011 Hi thanks for your reply after a bit of working out what im going to do on the site and whats needed for it and so on i think your right with the database... It was going to be a small site only a 2-3 page site with a few values that i can input manualy into the code. But after some thaught about what happens if it takes off and i need to add stuff to it, then id have to redesign it all again so i think a database is definetly the way to go like you suggested... Thank you for your help... (have posted another problem up now though lol) Cheers Chris Quote Link to comment https://forums.phpfreaks.com/topic/249845-comparing-values-and-displaying-without-database/#findComment-1282590 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.