Jump to content

Recommended Posts

I have a table.. five rows by 30/31 days.

 

Each cell has a status level which it gets from a database.

 

My current script works, but it queries the database to see the status of each cell

 

So that means every time a month is displayed, it makes about 150 queries to the database.

Is that bad/unacceptable?

 

It's currently like this-

 

$rows = array('1','2','3','4','5');
foreach ($rows as $row) {
     for ($day=0;$day<$DaysinMonth;$day++) {
             $res = mysql_fetch_array(mysql_query("SELECT ... WHERE `row` = $row AND `day` = $day));
             if ($res['level'] == 1) {
                      do something
             }
             else if ($res['level'] == 2) {
                      do something else
             }
     }
}

 

Is there a better way to structure this to cut down on queries? Or is it not an issue?

Link to comment
https://forums.phpfreaks.com/topic/70642-cut-down-on-db-queries/
Share on other sites

Yeh...

 

What is the purposes of the table

 

What data is stored and with that data what do you want to output

 

Maybe a screenshot of your database 'browse' in phpmyadmin or something

 

Then we can help you redesign the database or structure the query :D

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.