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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T02:36:57+00:00 2026-05-24T02:36:57+00:00

<?php $dbhost = ‘localhost’; $dbuser = ‘/////////’; $dbpass = ‘////////’; $conn = mysql_connect($dbhost, $dbuser,

  • 0
<?php
    $dbhost = 'localhost';
    $dbuser = '/////////';
    $dbpass = '////////';

    $conn = mysql_connect($dbhost, $dbuser, $dbpass) or die                      ('Error connecting to mysql');

    $dbname = '///////';
    mysql_select_db($dbname);
    mysql_query("SET NAMES 'utf8'", $conn);  
    $result = mysql_query($query);
    $query  = "SELECT * FROM 3orod";
    $result = mysql_query($query);
    $i= 0;
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html dir="rtl" xmlns="http://www.w3.org/1999/xhtml">

    <head>
    <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
    <meta content="ar-sa" http-equiv="Content-Language" />
    <title>آخر العروض</title>
    <style type="text/css">
    body {
      width: 99%;
      margin-left:auto;
      margin-right:auto;
      background-color: gray;
      color: #505050;
    }

    .website {
      background-color: #FFFFFF;
      border:1px solid #000000;
      border-radius: 10px;
      min-width:860px;
      box-shadow: 5px 5px 5px #000000;
      max-height: 99%;
      min-height: 600;
      height: 99%;
    }

    .header {
    background-color: #E6F3DB;
    font-size:small;
    font-style:oblique;

    }

    .header2 {
    background-color: #E6F3DB;
    font-size:small;
    font-style:oblique;

    }


    .row {
    background-color: #FFFFFF;
    font-size:small;
    font-style:oblique;
    }


    table {
    border:1px solid #000000;
    max-width:99%;
    }
    td {
    }
    </style>

    </head>

    <body>
    <div class="website">
    <table width="100%" border="1">
    <?php
    while($row = mysql_fetch_assoc($result))
    {

    if ($i == 0){
    echo "<tr>".
            "<td  class='header'>   {$row['A']}</td>".
            "<td width='3%' class='header'> {$row['B']}</td>".
             "<td  class='header'>  {$row['C']}</td>".
             "<td  class='header'>  {$row['D']}</td>".
             "<td  class='header'>  {$row['E']}</td>".
             "<td  class='header'>  {$row['F']}</td>".
             "<td  class='header'>  {$row['G']}</td>".
             "<td  class='header'>  {$row['H']}</td>".
             "<td  class='header2'> {$row['I']}</td>".
             "<td width='1px' class='header'>   {$row['J']}</td>".
             "<td width='1px' class='header'>   {$row['K']}</td>".
             "<td  class='header'>  {$row['L']}</td>".
             "<td  class='header'>  {$row['M']}</td>".
             "<td  class='header'>  {$row['N']}</td>".
             "<td  class='header'>  {$row['O']}</td>".
             "<td  class='header'>  {$row['P']}</td>".
             "<td  class='header'>  {$row['Q']}</td>".
             "<td  class='header'>  {$row['R']}</td>".
             "<td  class='header'>  {$row['S']}</td>".
             "<td  class='header'>  {$row['T']}</td>".
             "<td  class='header'>  {$row['U']}</td>".
             "<td  class='header'>  {$row['V']}</td>".
             "<td  class='header'>  {$row['W']}</td>".
             "<td  class='header'>  {$row['X']}</td>".
             "<td  class='header'>  {$row['Y']}</td>".
             "<td  class='header'>  {$row['Z']}</td>".
             "</tr>"     ;
             $i=1;
    }
    else
    {
        echo "<tr>".
            "<td  class='row'>  {$row['A']}</td>".
            "<td width='3%' class='row'>    {$row['B']}</td>".
             "<td  class='row'> {$row['C']}</td>".
             "<td  class='row'> {$row['D']}</td>".
             "<td  class='row'> {$row['E']}</td>".
             "<td  class='row'> {$row['F']}</td>".
             "<td  class='row'> {$row['G']}</td>".
             "<td  class='row'> {$row['H']}</td>".
             "<td  class='row2'>    {$row['I']}</td>".
             "<td width='1px' class='row'>  {$row['J']}</td>".
             "<td width='1px' class='row'>  {$row['K']}</td>".
             "<td  class='row'> {$row['L']}</td>".
             "<td  class='row'> {$row['M']}</td>".
             "<td  class='row'> {$row['N']}</td>".
             "<td  class='row'> {$row['O']}</td>".
             "<td  class='row'> {$row['P']}</td>".
             "<td  class='row'> {$row['Q']}</td>".
             "<td  class='row'> {$row['R']}</td>".
             "<td  class='row'> {$row['S']}</td>".
             "<td  class='row'> {$row['T']}</td>".
             "<td  class='row'> {$row['U']}</td>".
             "<td  class='row'> {$row['V']}</td>".
             "<td  class='row'> {$row['W']}</td>".
             "<td  class='row'> {$row['X']}</td>".
             "<td  class='row'> {$row['Y']}</td>".
             "<td  class='row'> {$row['Z']}</td>".
             "</tr>"     ;
    } 
    }
    mysql_close();
    ?>
    </table>
    </div>
    </body>

    </html>

if you see the results you can see that the cells expanding with no reason
http://www.almousaakar.com/test/3orod/admin/

my regards

  • 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-24T02:36:58+00:00Added an answer on May 24, 2026 at 2:36 am

    The cells aren’t expanding for no reason, they’re expanding to fit the cell contents. Take a look at automatic table layout. Also, the HTML4 spec says about table cell width:

    If column widths prove to be too narrow for the contents of a particular table cell, user agents may choose to reflow the table.

    It’s bad form both to link to an enormous page as a sample and to link to an enormous page without warning. Some browsers might misbehave, and people won’t appreciate you crashing their browser. Samples (both pages and code) should be concise and complete. Remove anything extraneous, both from sample code and by reducing the results displayed.

    Off-Topic

    For header cells, use <th>, not <td> with a class. Keep it semantic.

    If you find yourself repeating code, you should be using a function or a loop.

    The mysql extension is on its way to deprecation. Use PDO or mysqli, both of which support prepared statements.

    Hopefully, you’re not putting the database credentials in the main script as you do in the sample. Sensitive information should be kept in a single location, where it’s easier to secure. Also, the more you repeat something, the greater chance for a typo. Don’t repeat yourself.

    Names should be descriptive; single letter column (or variable or …) names aren’t. They’ve even been part of a daily WTF. Hopefully, this is just in the sample code and the production code (and database) has more descriptive names.

    Style sheets are preferred over the width attribute for setting table cell width, as a consequence of separation of structure from presentation. You can give cells a class to target in selectors; when they have broader browser support, you can use :nth-child() or :nth-of-type() pseudo-classes in selectors (e.g. tr > nth-child(2), th:nth-of-type(2), td:nth-of-type(2)) rather than classes. From the same section of the HTML4 spec that was previously linked to:

    Note. Although the width attribute on the TABLE element is not deprecated, authors are encouraged to use style sheets to specify table widths.

    Here’s an example that incorporates changes for some of these issues. First, ‘localdb.php’, a class that handles DB connection creation and lets you isolate credentials somewhere (though where isn’t shown). Note that it still has problems (such as data access and presentation are too closely coupled).

    <?php
    class LocalDB {
        static function connect($dbName=null) {
            if ($dbName) {
                $dbName = ";dbname=$dbName";
            }
            try {
                $db = PDO("mysql:hostname=localhost$dbName", 
                          self::user(), self::password(), 
                          array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES 'utf8'"));
                $db->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
                # can cause problems in some versions of PHP 5.2
                $db->setAttribute(PDO::ATTR_EMULATE_PREPARES, False);
                return $db;
            } catch (PDOException $exc) {
                # remove call to PDO's constructor from trace, which will include
                # database credentials
                throw new PDOException($exc->getMessage(), $exc->getCode());
            }
        }
        static private user() {...}
        static private password() {...}
    }
    

    Next, the main script (without the embedded style sheet, since that doesn’t matter in the example and should, in any case, be placed in an external style sheet):

    <?php
    include_once('path/to/localdb.php');
    $db = LocalDB::connect(...);
    ?>
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html dir="rtl" xmlns="http://www.w3.org/1999/xhtml">
      <head>
        <meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
        <meta content="ar-sa" http-equiv="Content-Language" />
        <title>آخر العروض</title>
      </head>
      <body>
        <div class="website">
        <?php
        try {
            $result = $db->query(...);
            $result->setFetchMode(PDO::FETCH_ASSOC);
            ?>
            <table>
              <?php $header = $result->fetch(); ?>
              <tr>
                <?php foreach ($header as $field => $value) { ?>
                  <th class="<?php echo $field ?>"><?php echo $value; ?></th>
                <?php } ?>
              </tr>
              <?php foreach ($result as $row) { ?>
                <tr>
                  <?php foreach ($row as $field => $value ?>
                    <td class="<?php echo $field ?>"><?php echo $value ?></td>
                  <?php } ?>
                </tr>
              <?php } ?>
            </table>
          <?php } catch (PDOException $exc) { ?>
              <p>There was an internal error when fetching the data. It's been logged, and we'll look into it.</p>
              <?php 
              // log exception
              ...
          } ?>
        </div>
      </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

the following short test script <?php define('DBHOST', '/tmp'); define('DBNAME', 'XXX'); define('DBUSER', 'XXX'); define('DBPASS', 'XXX');
I've been learnging php/mysql for a short while and I got some basic stuff
I've wrote a quick PHP class to ease the access to a mysql database.
Possible Duplicate: What happens if MySQL connections continually aren't closed on PHP pages? If
I get the error PHP Fatal error: Call to a member function execute() on
I'm trying to establish a PHP (5.2.6)/MySQL connection via mysqli. error_log( sprintf( 'Querying %s:%s
PHP has a great function called htmlspecialcharacters() where you pass it a string and
PHP's explode function returns an array of strings split on some provided substring. It
PHP, as we all know is very loosely typed. The language does not require
PHP stores its session information on the file system of the host of 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.