0

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();

Edited by ElegantElephant: n/a

2
Contributors
4
Replies
5
Views
7 Years
Discussion Span
Last Post by ElegantElephant
0

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();
?>
0

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.

Edited by ElegantElephant: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.