I am currently working on a client management system for my Computing Coursework and I've come to the "Client Details" section, which allows staff and admin to view personal information about each client.

I've successfully coded the query and everything else around it, I'm just a but stuck on how to actually output the details of each client in a table.

The table will only contain details about a specific client, and so will contain only two columns and as many rows as many columns in the mysql table, like this:

Name | Mark
Surname | Kent
Address | 55 Street

The table has about 10 columns

etc

Here is my code:

$clientid = $_GET['client'];
$query = "SELECT * FROM client_details INNER JOIN users ON client_details.userID = users.id WHERE userID = $clientid";
$result = mysqli_query($dbcon,$query) or die('Error executing database query');
if (mysqli_num_rows($result) < 1) {
                    die('Error obtaining client details, no rows found. <a href="' . $_SERVER["HTTP_REFERER"] . '">Go Back</a>');
                }
while ($row = mysqli_fetch_array($result)) {
                    echo $row['firstname'] . '<br />';
                    echo $row['lastname'] . '<br />';                                       
                }
exit();

Recommended Answers

All 4 Replies

Do you mean like this?

<?php
$clientid = mysql_real_escape_string($_GET['client']);
$query = "SELECT * FROM client_details INNER JOIN users ON client_details.userID = users.id WHERE userID = $clientid";
$result = mysqli_query($dbcon,$query) or die('Error executing database query');
if (mysqli_num_rows($result) < 1) {
    die('Error obtaining client details, no rows found. <a href="' . $_SERVER["HTTP_REFERER"] . '">Go Back</a>');
    }
echo '<table border=1 cellpadding=5 cellspacing=0>';
while ($row = mysqli_fetch_assoc($result)) {
    echo '<tr><td>'.$row['firstname'].'</td><td>'.$row['lastname'].'</td></tr>';
    }
echo '</table>';
exit();
?>

Yeah, thanks very much, what a quick reply :)

Actually sorry (my fault) that's not what I meant. I want PHP to output a two column table with the left column containing the actual field name in the mysql table and the right column containing the data for that client.

For example:

First Name | Joe
Second Name | Bloggs
Email Address | joe@life.com
Address | 10 Downing St

etc

Is this possible to do?

If you still don't understand what I am trying to do please let me know.

Ahh nevermind, I figured it out :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.