Need help with some php code :)
Posted on
16th Feb 2014 07:03 pm by
admin
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.
I managed to make the page show all the customers in the database - with first- and surname.
I want each of these customers to be clickable - when you click a customer, it shows all the information about that customer which is stored in the database.
So far I have managed to make them clickable, but I don't know how to make it so that the click posts all the associated information about that customer on the page..
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..
Code: <?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>';
}
?>
Thanks!
No comments posted yet
Your Answer:
Login to answer
189
44
Other forums
Best way to check for end of a record and send it back to the first record
I'm hoping someone can help me out and explain the best way to accomplish this.
What I'm doin
AJAX form submit
I recently built a form that submits data to my database with an ajax function that is called throug
Strange PHP/mySQL error ... am I just tired?
Code: <?
## CONNECT TO DB FUNCTION!
function ConnectTo($db2con)
{
$hostNam
Restricted access to sub-folder in iis6 doesn't work?
Basically I'm trying to add restriction to sub-folder (which contains pdf) in web.config for iis6 as
Fatal error: Call to a member function fetchrow() on a non-object in C:xamppht
okay i have this query and everytime i add `item_id`=? to it... it gives me the error in the title..
retrieving policy name inside the function called by this particular policy
Hi there,
I've playing around with dbms_rls package, trying to set up some security repo
SAP Business Suite
Hi all:
Within the SAP Business Suite solution I would like to ask you the main differenc
DateTimeZone::listIdentifiers headache
http://php.net/manual/en/datetimezone.listidentifiers.php
So the documentation states tha
check how many commas the variable containing the query has between [i]select[/i
Hi...
iv made an sql table that contains id number - name of sql query and an sql query.
T
update post issues
I am trying to create an update to a post function, while the update does occur, the page routing an