Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6879225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:49:11+00:00 2026-05-27T04:49:11+00:00

I have the code below which grabs data from a table based on what

  • 0

I have the code below which grabs data from a table based on what week the user has chosen, there are only 2 possible weeks to choose from.

It puts the title of the recipe into the relevant table based on the if statement but seems to be producing weird output.

When ever i try to view a week which only has part data filled in it bunches of the data onto the wrong cells; look in this image:
Table problem
‘Salad’ located on the top row should be in ‘Sunday’

This only happens when the table is incomplete.

 if(!empty($_POST['selectweek'])) {
                        $selectweek = mysql_real_escape_string($_POST['selectweek']);

                        function ouptutMeal($selectweek, $mealtime, $mealname) {
                            $sqlmeasurement2 = mysql_query("SELECT title, dayid
                                                            FROM recipe
                                                            JOIN menu ON recipe.recipeid = menu.recipeid
                                                            WHERE menu.weekid = '$selectweek'
                                                            AND menu.mealtimeid = '$mealtime'
                                                            ORDER BY dayid");

                            echo "<br/>
                                <table>
                                    <td></td>
                                    <td><strong>Monday</strong></td>
                                    <td><strong>Tuesday</strong></td>
                                    <td><strong>Wednesday</strong></td>
                                    <td><strong>Thursday</strong></td>
                                    <td><strong>Friday</strong></td>
                                    <td><strong>Saturday</strong></td>
                                    <td><strong>Sunday</strong></td>
                                <tr>
                                   <td><strong>$mealname</strong></td>";
                                while($info2 = mysql_fetch_array( $sqlmeasurement2 )) {
                                    if($info2['dayid'] == '1') {
                                        echo '
                                              <td>', $info2['title'], '</td>';
                                    }

                                    elseif($info2['dayid'] == '2') {
                                        echo '
                                              <td>', $info2['title'], '</td>';
                                    }

                                     elseif($info2['dayid'] == '3') {
                                        echo '
                                              <td>', $info2['title'], '</td>';
                                    }

                                    elseif($info2['dayid'] == '4') {
                                        echo '
                                              <td>', $info2['title'], '</td>';
                                    }

                                    elseif($info2['dayid'] == '5') {
                                        echo '
                                              <td>', $info2['title'], '</td>';
                                    }

                                    elseif($info2['dayid'] == '6') {
                                        echo '
                                              <td>', $info2['title'], '</td>';
                                    }

                                    else {
                                        echo '
                                              <td>', $info2['title'], '</td>';
                                    }
                                } 
                            echo '</tr>
                                </table>';
                            }
                        ouptutMeal($selectweek, 1, 'Breakfast');
                        ouptutMeal($selectweek, 2, 'Lunch');
                        ouptutMeal($selectweek, 3, 'Evening Meal');
                        ouptutMeal($selectweek, 4, 'Pudding');
                        ouptutMeal($selectweek, 5, 'Supper & Snacks');
                        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T04:49:11+00:00Added an answer on May 27, 2026 at 4:49 am

    Do an if statement to see if a value exists if not then

       <td>& nbsp;</td>
    

    so it fills your table correctly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the below code, which iterates over a list based on a custom
Consider the code below (which has been simplified). I have a service class that
I have code below which has been working on devices of type Windows Mobile
I have the code below that grabs some html from an AJAX request and
So far i have got the code below which works lovely when trying an
I have the code below, which works fine it can be viewed for an
I have the code below, which sends the value of the textarea and either
I have the below code for my a Dialog box for a which contains
I have a code like this below, which gives me a $link that equals
I have below is the html code for TD which gets appended after matching

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.