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 3453444
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:22:30+00:00 2026-05-18T09:22:30+00:00

Here is a very simple Sudoku like HTML table . What I want is

  • 0

Here is a very simple Sudoku like HTML table.

What I want is to generate this with PHP considering the following.

Each cell should look like this (or similar):

<!-- Position "a1" -->

<?php
if ($a1_pos_txt !== TRUE){

    echo "<td>" . $numbers["a1_pos"] . "</td>";

}else{

?>

<td><input type="text" name="a1_post" size="1" maxlength="1" /></td>

<?php   
}
?>

This is obviously the the “a1” cell.

Just in case, “c4” and “f9” should look like THIS.

So the table generated by PHP should look like THIS and so on for all the rows.

As I said, and dont want to copy and paste this code and replace a1 for a2 and so on 81 times, I want his table and variables to be dynamically generated with PHP.

I tried to make it as clear as possible with all the code I could provide but please ask if you need any clarifications!!!

NOTE: Sorry for the crappy choice in variables ($a1_pos_txt , $a1_pos and a1_post) no vert friendly 🙂

  • 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-18T09:22:31+00:00Added an answer on May 18, 2026 at 9:22 am

    This should do it:

    $lit = range('A', 'J');
    echo '<table border="1">';
    for($y = 0; $y < 9; $y++) {
        echo '<tr>';
        for($x = 0; $x < 9; $x++) {
            $block = floor($x / 3) + floor($y / 3) * 3;
            $cell  = ($x % 3 + 1) + ($y % 3) * 3;
            echo '<td>'.$lit[$block].$cell.'</td>';
        }
        echo '</tr>';
    }
    echo '</table>';
    

    Output:

    A1 A2 A3 B1 B2 B3 C1 C2 C3
    A4 A5 A6 B4 B5 B6 C4 C5 C6
    A7 A8 A9 B7 B8 B9 C7 C8 C9
    D1 D2 D3 E1 E2 E3 F1 F2 F3
    D4 D5 D6 E4 E5 E6 F4 F5 F6
    D7 D8 D9 E7 E8 E9 F7 F8 F9
    G1 G2 G3 H1 H2 H3 I1 I2 I3
    G4 G5 G6 H4 H5 H6 I4 I5 I6
    G7 G8 G9 H7 H8 H9 I7 I8 I9
    

    Probably can be simplified down a bit, but should give you what you need. $block is the current 3×3 grid, and $cell is the cell number in that grid.

    EDIT

    I checked your example and this might not be what you wanted. Apparently you want A for first row, B for second etc, not per 3×3 block. Here’s how you can do that:

    echo '<table border="1">';
    foreach(range('A', 'J') as $y) {
        echo '<tr>';
        for($x = 1; $x <= 9; $x++) {
            echo '<td>'.$y.$x.'</td>';
        }
        echo '</tr>';
    }
    echo '</table>';
    

    Output:

    A1 A2 A3 A4 A5 A6 A7 A8 A9
    B1 B2 B3 B4 B5 B6 B7 B8 B9
    C1 C2 C3 C4 C5 C6 C7 C8 C9
    D1 D2 D3 D4 D5 D6 D7 D8 D9
    E1 E2 E3 E4 E5 E6 E7 E8 E9
    F1 F2 F3 F4 F5 F6 F7 F8 F9
    G1 G2 G3 G4 G5 G6 G7 G8 G9
    H1 H2 H3 H4 H5 H6 H7 H8 H9
    I1 I2 I3 I4 I5 I6 I7 I8 I9
    J1 J2 J3 J4 J5 J6 J7 J8 J9
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's a very simple Prototype example. All it does is, on window load, an
Here's a very simple question. I have an SP that inserts a row into
My goal here is to create a very simple template language. At the moment,
Liu Chang asked a very similar question to this one here, Linux equivalent of
Once again a very beginner-ish question, but here I go: I would like to
Here is very simple question for experienced Git user. I've created repository on git
Here is very simple code, #include <iostream> using namespace std; int main() { unsigned
got a (I guess...) very simple problem: I want to set a session within
Here is a very simple C++ application I made with QtCreator : int main(int
Here's a very simple example using SQL Server CE 3.5 SP1 where I attempt

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.