How to display record in html table

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
waabro
Forum Newbie
Posts: 2
Joined: Thu May 15, 2014 6:20 am

How to display record in html table

Post by waabro »

Hi all ,
iam new in PHP
i have two tables with fields
Employee (empId,Name , Fname, contactno, email Address)
Acadmics ( acadmicId, empId, qualification,passingyear)
Now i have to reterive record like this in html table

Name Fathername contactno email qualifcation passingYear Address
xyz abc 0333-3333 abc@gmail.com matric 1999 abc
HSC 2000
BS 2006
waheed Ahmed 033333 abc@gmail matric 2000 india
HSC 2002
iam new in php please provide the articles for more learning
Any Idea
Regards,
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How to display record in html table

Post by Celauran »

What have you done so far? Where are you stuck? For absolute basics, check out PHP: The Right Way
waabro
Forum Newbie
Posts: 2
Joined: Thu May 15, 2014 6:20 am

Re: How to display record in html table

Post by waabro »

Thanks for reply

i have written the code below

Code: Select all

<?php echo "<table class='table'>
            <thead>
              <tr>
                <th>empId</th>
                <th>Name</th>
                <th>email</th>
                <th>Contact Number</th>
                <th>qualification</th>
                <th>PassingYear</th>
                 <th>Address</th>
              </tr> </thead>"; 

                    while($row = mysqli_fetch_array($result))
                      {
                      echo "<tr class='success'>";
                      echo "<td>" . $row['empName'] . "</td>";
                      echo "<td>" . $row[''email'] . "</td>";
                      echo "<td>" . $row['Contact Number'] . "</td>";
                    // Here the qualifcation and passing Year will come from employeeAcadmic Table how i can display it
                      echo "<td>" . $row['qualifcation'] . "</td>";
                      echo "<td>" . $row['PassingYear'] . "</td>";
                    // End 
                      echo "<td>" . $row['Address'] . "</td>";
                      echo "</tr>"; }
             echo "</table>"; ?>
Issue is how i can display the employee qualifciation like below
[text]
Name email ContactNumber qualifciation Passing Year Address
abc abc@gmail.com 333333 SSC 1999 abc
HSC 2000
BS 2006
xyz xyz@gmail.com 333333 SSC 2000 zyz
[/text]
Regards,
Last edited by Celauran on Fri May 16, 2014 6:35 am, edited 1 time in total.
Reason: Please use syntax tags to keep code legible
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

Re: How to display record in html table

Post by Celauran »

You need to add some fields to your query and join the tables.

Code: Select all

SELECT e.name, e.fname, e.contactno, e.email, a.qualifications, a.passingyear
FROM employees AS e
JOIN academics AS a ON e.empid = a.empid
ryancody
Forum Newbie
Posts: 14
Joined: Wed May 21, 2014 1:48 am

Re: How to display record in html table

Post by ryancody »

You will have to use the table coding and then use while statement to fetch all the information from the database using SQL statement select you want to display in the table.
Post Reply