The php array is written to the table, and the table is messy.

Source: Internet
Author: User
There is an array $ rowarray (& quot; username & quot; & amp; gt; & quot; admin & quot; mail & quot; & amp; gt; & quot; admin@admin.com & quot; id & quot; & amp; gt; & quot; 1 & quot;) I want to output {code ...} why is the table messy? The column width of each table changes.

There is an array
$ Row = array ("username" => "admin" "mail" => "admin@admin.com" "id" => "1 ")
I want to output

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

Why is the table messy? The column width of each table changes.

Reply content:

There is an array
$ Row = array ("username" => "admin" "mail" => "admin@admin.com" "id" => "1 ")
I want to output

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

Why is the table messy? The column width of each table changes.

You shouldn't have created a new table for each row.

Set the style of the table.

Foreach loop should be in table, not outside

Let's take a look at the figure you posted. The row split line is rough and the column split line is fine. Most of the rows are a table.

Traverse tr td

First, your array is not written. It should be$row=array("username"=>"admin","mail"=>"admin@admin.com","id"=>"1");
If your array is a one-dimensional array

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

If the array is a two-dimensional array, you should have put an error in the foreach loop.
For example:

$ Row = 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']."
"; Style:

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.