Jump to content

Comparing values and displaying without database


skoobi

Recommended Posts

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

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 />";
}

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

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.