Hey! I'm quite new to this whole thing, so please don't fire me with shait on this one =D
I'm trying to learn PHP and MySQL, and atm I am trying to make a website which corresponds with a database - a database with customers.
1. I want the page to show all the customers in the database - with first- and surname.
2. I want each customer to be clickable - when you click a customer, it shows all the information about that customer which is stored in the database.
I can post some of the stuff I tried out with, but I'm not good with PHP (yet! =D), and therefore I got stuck quite early... but here's some of the stuff I've done so far..
<?php
// Connect to the database server
$dbcnx = @mysql_connect('localhost', 'root', 'password');
if (!$dbcnx) {
exit('<p>Unable to connect to the database server at this time.</p>');
}
// Select the database
if (!@mysql_select_db('customerdb')) {
exit('<p>Unable to locate the database at this time');
}
?>
<p>Here are all the customers:</p><br />
// Request data from the database
$customers = @mysql_query('SELECT * FROM customers');
if (!$customers) {
exit('<p>Error performing query: ' . mysql_error() . '</p>');
}
while ($row = mysql_fetch_array($customers)) {
$customerID = $row['kundeID'];
$customer_forename = $row['forename'];
$customer_surname = $row['surname'];
echo '<p>' . $customer_forename .
$customer_surname .
' <a href="' . $_SERVER['PHP_SELF'] .
'?showcustomer=' . $customerID . '">' .
'customer details</a></p>';
}
?>
This piece of code also gives me no spaces between the $customer_forename and $customer_surname.. How can I make a space between them?
And one last question :) In this example, I have just created a link at the end of the customers listed - which says customer details.. Is there a way to make the $customer_forename and $customer_surname a clickable link which executes what I am trying to achieve?
Thanks, and sorry for not being really good at this, at all! =D
Have a nice day!