Page 1 of 1

How to display record in html table

Posted: Thu May 15, 2014 6:33 am
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,

Re: How to display record in html table

Posted: Thu May 15, 2014 6:44 am
by Celauran
What have you done so far? Where are you stuck? For absolute basics, check out PHP: The Right Way

Re: How to display record in html table

Posted: Thu May 15, 2014 10:57 pm
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,

Re: How to display record in html table

Posted: Fri May 16, 2014 6:36 am
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

Re: How to display record in html table

Posted: Thu May 22, 2014 3:49 am
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.