Loop report output

Source: Internet
Author: User
Looping table output
How do I do tabular output with foreach?
The data in the database is (the following is a student's elective information)


I'm on the page.
$course = $row [' course_id '];
$sql = "SELECT * from Think_course where id= ' $course '";
$result =mysql_query ($sql);
$row =mysql_fetch_array ($result);
Take out the data in the database and now I want to use foreach to output the following form
NoNameTeacher_namePlaceTime
The output in the page is in the form

How to write foreach, novice just learn SQL operation I hope you teach, can put the code words better.
Database SQL MySQL Industry Data Select

Share to:


------Solution--------------------
$sql = "SELECT * from think_selected where stu_id= $stu";
Will there be more than one sentence? In $row =mysql_fetch_array ($result); Put a while outside this sentence.
------Solution--------------------
Outer layer (7 lines) $result =mysql_query ($sql);
Inner layer (17 rows) $result =mysql_query ($sql);
The inner $result cover the outer layer.
  • 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.