How can I make table in PHP with two columns and 10 variables for example (without loop)?

For example:

$var1= $row<"name">;$var2= $row<"age">;The way I want to show it in the table:

______________________ | Customer Name | $var1| | Customer Age | $var2|

Đang xem: Php for loops exercise: create a table using for loop

*

*

Without loop:

echo “

Customer Name “, $var1, “
Customer Age “, $var2, “
Customer … “, $var3, “

“;With foreach loop

$myFields = array(“Customer Name” => $row<"Name">, “Customer Age” => $row<"Age">);echo “

“;foreach($myFields as $field_title => $field_value) echo “

“;echo “

“, $field_title, “ “, $field_value, “

“;

*

Simple. Use this syntax:

Customer Name

Customer Age

Customer Name

Customer Age

Customer Name

Customer Age

Customer Name

Customer Age

Customer Name

Customer Age

Xem thêm:

*

You can use something like this:

$array = array();$array<0><"name">;$array<0><"age">;or instead of that , you can use a loop:

$i=0;while($i
Thanks for contributing an answer to Stack Overflow!

Please be sure to answer the question. Provide details and share your research!

But avoid

Asking for help, clarification, or responding to other answers.Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged php html-table or ask your own question.

Xem thêm:

*

site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev2021.3.3.38704

Related Post

Leave a Reply

Your email address will not be published. Required fields are marked *