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

  • SEARCH
  • Home
  • 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 4087514
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T18:51:53+00:00 2026-05-20T18:51:53+00:00

This code pretty much just shows a a table with 16 cells (4 columns

  • 0

This code pretty much just shows a a table with 16 cells (4 columns and 4 rows). Except on the top right, there are two “RESERVED” cells. This code also paginates.

There’s two things I want to fix with this code. Right now the two “RESERVED cells” are the same. Meaning the two cells both say RESERVED. How do I make it so I can change what’s inside the two reserved cell. Sorry if this is a little hard to understand.

Also, I want the two reserved cells to only be shown on the first page. Other than the first page, it would just echo a table with 4×4 cells, as if the reserved cells weren’t there.

Can anyone please make this possible?

Without further ado, here’s the code:

        $Page = $_GET["Page"];
        if(!$_GET["Page"])
        {
            $Page=1;
        }

        $Prev_Page = $Page-1;
        $Next_Page = $Page+1;

        $Page_Start = (($Per_Page*$Page)-$Per_Page);
        if($Num_Rows<=$Per_Page)
        {
            $Num_Pages =1;
        }
        else if(($Num_Rows % $Per_Page)==0)
        {
            $Num_Pages =($Num_Rows/$Per_Page) ;
        }
        else
        {
            $Num_Pages =($Num_Rows/$Per_Page)+1;
            $Num_Pages = (int)$Num_Pages;
        }

        $strSQL .=" order  by GalleryID ASC LIMIT $Page_Start , $Per_Page";
        $objQuery  = mysql_query($strSQL);
$cell = 0;
echo '<table border="1" cellpadding="2" cellspacing="1"><tr>';
while($objResult = mysql_fetch_array($objQuery))
{
  if($cell % 4 == 0) {
    echo '</tr><tr>';
  }

  if($cell == 2 || $cell == 3) {
    echo '<td>RESERVED</td>'; **//How do I make it so there are two separate reserve slots,  
  rather than one <td> which controls both cells?** 
  } else {
    echo '<td><img src="https://s3.amazonaws.com/thumbnails/' . $objResult["Picture"] . '" />' .
            $objResult["GalleryName"] . '</td>'; }
  $cell++;
}
echo '</tr></table>';
    ?>

        <br>
view more:
        <?php
        if($Prev_Page)
        {
            echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'>prev</a> ";
        }
            {
                echo "|";
        }
        if($Page!=$Num_Pages)
        {
            echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>next</a> ";
        }
        ?>


</body>
</html>
<?php
mysql_close($objConnect);
?>
  • 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-20T18:51:54+00:00Added an answer on May 20, 2026 at 6:51 pm
    if($cell == 2) {
        echo '<td>RESERVED</td>';
    } elseif ($cell == 3) {
        echo '<td>The other cell</td>';
    } else {
        echo '<td><img src="https://s3.amazonaws.com/thumbnails/' . $objResult["Picture"] . '" />' .
        $objResult["GalleryName"] . '</td>'; }
        $cell++;
    }
    

    Edit: this was getting a bit frustrating to understand exactly what was happening on your end, so I rewrote this. This is pretty much what your code should look like. If you can’t understand the basic conditionals from here, you need to invest more work in understanding fundamentals on your own time, because a lot of this stuff is rudimentary.

    $Page = max((int)$_GET["Page"], 1);
    $Prev_Page = $Page - 1;
    $Next_Page = $Page + 1;
    
    $Page_Start = max(0, ($Per_Page * ($Page - 1) - 2));
    if ($Page === 1) $Per_Page = $Per_Page - 2;
    $Num_Pages = ceil($Num_Rows / $Per_Page);
    
    $strSQL .= "ORDER BY GalleryID ASC LIMIT {$Page_Start},{$Per_Page}";
    $objQuery = mysql_query($strSQL);
    
    $cell = 0;
    $total = mysql_num_rows($objQuery);
    ?>
    
    <table border="1" cellpadding="2" cellspacing="1">
        <? for ($cell = 0; $cell < $total; ++$cell) : ?>
            <? if ($cell % 4 === 0) : ?>
                <tr>
            <? endif; ?>
            <td>
                <? if ($Page === 1 && $cell === 2) : ?>
                    First reserved cell
                    <? --$cell; ?>
                <? elseif ($Page === 1 && $cell === 3) : ?>
                    Second reserved cell
                    <? --$cell; ?>
                <? else: ?>
                    <? $objResult = mysql_fetch_array($objQuery); ?>
                    <img src="https://s3.amazonaws.com/thumbnails/<?=$objResult["Picture"]; ?>" />
                    <?=$objResult["GalleryName"]; ?>
                <? endif; ?>
            </td>
            <? if ($cell % 4 === 3) : ?>
                </tr>
            <? endif; ?>
        <? endfor; ?>
    </table>
    
    <br>
    view more:
    <?php
        if($Prev_Page) {
            echo " <a href='$_SERVER[SCRIPT_NAME]?Page=$Prev_Page'>prev</a> ";
            if($Page != $Num_Pages) echo " | ";
        }
    
        if($Page != $Num_Pages) {
            echo " <a href ='$_SERVER[SCRIPT_NAME]?Page=$Next_Page'>next</a> ";
        }
    ?>
    
    
    </body>
    </html>
    <?php
    mysql_close($objConnect);
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is pretty much the same problem i have, except with very different code:
I have this code: $coder = JSON::XS->new->utf8->pretty->allow_nonref; %perl = $coder->decode ($json); When I write
I am pretty new at C# and .NET, but I've made this code to
...at least to me. This code used to work fine. I'm pretty sure nothing
i am pretty ok with basic reg-ex. but this line of code used to
The expressions used in the following Java code are nuts and pretty much unacceptable
Just out of curiosity i wanted to make something similar to what pretty much
I have found this piece of code in the Haskell sendfile package: http://patch-tag.com/r/mae/sendfile/snapshot/current/content/pretty/src/Network/Socket/SendFile/Linux.hsc --
This Code: Something = new Guid() is returning: 00000000-0000-0000-0000-000000000000 all the time and I
This code gives me an empty result. I expect it to print out the

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.