The PHP array is written into the table and the table is messed up.

Source: Internet
Author: User

has an array
$row =array ("username" + "admin" "Mail" = "admin@admin.com" "id" + "1")
I want to output it.

echo "
  
   
   
     ";echo " 
    
       ";echo " 
      ";echo " 
      ";echo " 
      ";echo " 
     ";echo " 
    
".$row['id']."".$row['username']."".$row['id']."
";

Why is the table messed up? The column widths of each table will change

Reply content:

has an array
$row =array ("username" + "admin" "Mail" = "admin@admin.com" "id" + "1")
I want to output it.

echo "
  
   
   
     ";echo " 
    
       ";echo " 
      ";echo " 
      ";echo " 
      ";echo " 
     ";echo " 
    
".$row['id']."".$row['username']."".$row['id']."
";

Why is the table messed up? The column widths of each table will change

You don't have to create a new table for every line.

Then fix the style of the watch.

The Foreach loop should be in the table, not outside.

Take a look at the picture you posted, line split line is thicker, row split line is relatively thin, most of it is a table per row

should traverse TR TD

First the landlord your array of writing is not right, should be$row=array("username"=>"admin","mail"=>"admin@admin.com","id"=>"1");
If your array is a one-dimensional array, that's it.

echo "
  
   
   
     ";echo " 
    
       ";echo " 
      ";echo " 
      ";echo " 
      ";echo " 
     ";echo " 
    
".$row['id']."".$row['username']."".$row['id']."
";

If the array is a two-dimensional array, you should have the Foreach loop misplaced.
For example:

$row=array(    array("username"=>"admin","mail"=>"admin@admin.com","id"=>"1"),    array("username"=>"uer1","mail"=>"user1@user.com","id"=>"2"),    array("username"=>"uer2","mail"=>"user2@user.com","id"=>"3")    );    echo "
  
   
   
     ";foreach ($row as $key => $value) { echo " 
    
       "; echo " 
      "; echo " 
      "; echo " 
      "; echo " 
     ";}echo " 
    
".$value['id']"".$value['username']."".$value['id']."
";样式:

  • Related Article

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.