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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T18:18:21+00:00 2026-06-07T18:18:21+00:00

I am a beginner to MySQL here. I am looking to create a table

  • 0

I am a beginner to MySQL here. I am looking to create a table which resembles an actual plate of rows and columns, from A1 through C22 (I will call these coordinates as wells). The result of MySQL script looks similar like the arrangement shown below (I actually want to draw a table here with each well occupying a cell for illustrative purposes but this can do):

A1 A2 A3 A4 A5 A6 A7 A8 A9 A10 A11 A12 A13 A14 A15 A16 A17 A18 A19 A20 A21 A22

B1 B2 B3 B4 B5 B6 B7 B8 B9 B10 B11 B12 B13 B14 B15 B16 B17 B18 B19 B20 B21 B22

C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 C17 C18 C19 C20 C21 C22

In the actual database, the data containing A1 through A22 & C1 through C22 exist, and for that matter, they must be displayed in the form of italics as shown in the table above.
I have tried to create an array (I will call it $arr) containing A1 through C22, and compare that array to another array of the database which contains A1 through A22 & C1 through C22( I will call it $result). I used array_intersect to find an intersection between the element of $arr and the array from the database. If it exists, that element from $arr must go in italics.

This is how my script goes. I know it is garbage but I tried..

<?php
$con = mysql_connect("localhost","root","1234");

mysql_select_db("inhouse_collection", $con) or die (mysql_error());

$result = mysql_query("SELECT * from ft7 ORDER BY SUBSTRING(Plate_Loc, 1, 1) ,SUBSTRING(Plate_Loc, 2)+0"); 

$arr=array("A1","A2","A3","A4","A5","A6","A7","A8","A9","A10","A11","A12","A13","A14","A15","A16","A17","A18","A19","A20","A21","A22","B1","B2","B3","B4","B5","B6","B7","B8","B9","B10","B11","B12","B13","B14","B15","B16","B17","B18","B19","B20","B21","B22","C1","C2","C3","C4","C5","C6","C7","C8","C9","C10","C11","C12","C13","C14","C15","C16","C17","C18","C19","C20","C21","C22");

echo "<table border='1'>";

echo "<tr>"; 

$z= 0;

for( $i=0; $arr[$z++]; $i = ($i+1)) {
    if( array_intersect( $arr[$z-1], $result(Plate_Loc)) {
        echo "<td><i>". $arr[$z-1] ."</i></td>";
    }
    else
        echo "<td>" . $arr[$z-1] . "</td>";

    if($i == 21) 
        echo "</tr><tr>"; 
}

echo "</tr>";

echo "</table>";
?>
</div>
</html>
  • 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-06-07T18:18:23+00:00Added an answer on June 7, 2026 at 6:18 pm

    first fetch all data in to an array, and then use isset() to se if that key exists in the array

    /* Fetch all data in to an array */
    $result = mysql_query("SELECT Plate_Loc from ft7 ORDER BY SUBSTRING(Plate_Loc, 1, 1) ,SUBSTRING(Plate_Loc, 2)+0"); 
    $list = array();
    while($row = mysql_fetch_assoc($result))
    {
        $list[$row['Plate_Loc']] = TRUE;
    }
    
    echo "<table>";
    
    /* loop trough all rows */
    foreach(array('A','B','C') as $row_char)
    {
        echo "<tr>";
    
        /* loop trough all columns */
        foreach(range(1, 22) as $col_nr)
        {
            /* check if this cell was in database */
            if(isset($list[$row_char . $col_nr]))
            {
                echo "<td><i>{$row_char}{$col_nr}</i></td>";
            }
            else
            {
                echo "<td>{$row_char}{$col_nr}</td>";
            }
        }
    
        echo "</tr>";
    }
    
    echo "</table>";
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here's my background: Decent experience with PHP/MySql. Beginner's experience with OOP Why I want
SQL beginner here. I have a query which takes around 10 seconds to run,
MySQL beginner here. I had thought that copying the directory <mysql_path>/<data_base_name> to USB stick
all.I'm a beginner of Mysql and I have one simple question here. I want
i am a beginner of MYSQL please help me. i have a two table
I have MySQL tables looking like this: regions table id | region ------------------- 1
I have created a MySQL table where one of the columns stores a BLOB
I have stumped on this as I am a total beginner in MySql. Here
I have just discovered mysql and mysqli, so I'm really a beginner here. I
I am trying to order the records from a table desc (format mm/dd/yyyy) which

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.