can anyone see an error in this code :S?? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <? echo '<h1>Registered Users</h1>'; require_once ('mysqli_connect.php'); $q = "select concat(last_name, ', ', first_name) as name, date_format(registration_date, '%m %d, %y') as fr from users order by registration_date asc"; $r = @mysqli_query ($dbc, $q); if ($r) { echo '<table align="center" cellspacing="3" cellpadding="3" width="75%"> <tr> <td align="left"><b>Name</b></td> <td align="left"><b>Date Registered</b></td> </tr>'; while ($row = mysqli_fetch_array($r, mysqli_assco)) { echo '<tr><td align="left">' . $row['name'] . '</td> <td align="left">' . $row['dr'] . '</td> </tr>'; } echo '</table>'; mysqli_free_result ($r); } else { echo '<p>The Current users could not be retrieved</p>'; echo '<p>' . mysql_error($dbc) . '<br /><br />Query: ' . $q . '</p>'; } mysqli_close($dbc); ?> </body> </html> PHP:
Eh,,, This $q = "select concat(last_name, ', ', first_name) as name, date_format(registration_date, '%m %d, %y') as fr from users order by registration_date asc"; PHP: Should be this: (one line) $q = "select concat(last_name, ', ', first_name) as name, date_format(registration_date, '%m %d, %y') as fr from users order by registration_date asc"; PHP:
It doesn't matter if it's on one line or not. What's it outputting? The PHP looks fine, looks to be something to do with the query. Try this to see if there is an error: $r = mysqli_query ($dbc, $q) or die( mysqli_error($dbc ) ); PHP:
basically it should put out the users in the mysql database and put them into a table ordered by the date they signed up. i have seen this script exactly how i have written it in a book called 'php 6 and mysql 5' by visual quickpro guide and larry ullman. so it should work!
this is what is in the users table in the db... -- phpMyAdmin SQL Dump -- version 3.2.5 -- http://www.phpmyadmin.net -- -- Host: localhost -- Generation Time: Jan 22, 2011 at 11:30 PM -- Server version: 5.1.48 -- PHP Version: 5.2.17 SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO"; -- -- Database: `web111-members-2` -- -- -------------------------------------------------------- -- -- Table structure for table `users` -- CREATE TABLE `users` ( `user_id` mediumint(8) unsigned NOT NULL AUTO_INCREMENT, `first_name` varchar(20) NOT NULL, `last_name` varchar(40) NOT NULL, `email` varchar(80) NOT NULL, `pass` char(40) NOT NULL, `registration_date` datetime NOT NULL, PRIMARY KEY (`user_id`) ) ENGINE=MyISAM DEFAULT CHARSET=latin1 AUTO_INCREMENT=2 ; -- -- Dumping data for table `users` -- INSERT INTO `users` (`user_id`, `first_name`, `last_name`, `email`, `pass`, `registration_date`) VALUES (1, 'Lloyd', 'Dear', 'management@xpresscenter.co.uk', 'd1fb70ff8f817945b31b369177a44ec237a8a3d6', '2011-01-22 17:01:03');
okaay try this code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <? echo '<h1>Registered Users</h1>'; require_once ('mysqli_connect.php'); $q = "select first_name, last_name, registration_date from users order by registration_date asc"; $r = @mysqli_query ($dbc, $q); if ($r) { echo '<table align="center" cellspacing="3" cellpadding="3" width="75%"> <tr> <td align="left"><b>Name</b></td> <td align="left"><b>Date Registered</b></td> </tr>'; while ($row = mysqli_fetch_array($r, mysqli_assco)) { echo '<tr><td align="left">' . $row['first_name'] . ' '. $row['last_name'] .'</td> <td align="left">' . $row['registration_date'] . '</td> </tr>'; } echo '</table>'; mysqli_free_result ($r); } else { echo '<p>The Current users could not be retrieved</p>'; echo '<p>' . mysql_error($dbc) . '<br /><br />Query: ' . $q . '</p>'; } mysqli_close($dbc); ?> </body> </html> PHP:
http://xpresscenter.co.uk/loginarea/view_users.php this is what is shown after i have changed it to the code above
I think I got it <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> </head> <body> <? echo '<h1>Registered Users</h1>'; require_once ('mysqli_connect.php'); $q = "select first_name, last_name, registration_date from users order by registration_date asc"; $r = @mysqli_query ($dbc, $q); if ($r) { echo '<table align="center" cellspacing="3" cellpadding="3" width="75%"> <tr> <td align="left"><b>Name</b></td> <td align="left"><b>Date Registered</b></td> </tr>'; while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) { echo '<tr><td align="left">' . $row['first_name'] . ' '. $row['last_name'] .'</td> <td align="left">' . $row['registration_date'] . '</td> </tr>'; } echo '</table>'; mysqli_free_result ($r); } else { echo '<p>The Current users could not be retrieved</p>'; echo '<p>' . mysql_error($dbc) . '<br /><br />Query: ' . $q . '</p>'; } mysqli_close($dbc); ?> </body> </html> PHP: mysqli_assco MYQLI_ASSOC
it works ! I am good xpresscenter.co.uk/loginarea/view_users.php Congratz I want your style on xpresscenter.co.uk Where did you find it ?
I know I noticed it just few seconds after you edited it I want your style on xpresscenter.co.uk Where did you find it ?
i am a website designer i just dont do the PHP side of things much, just getting onto it. i designed it myself