include('core/init.inc.php');
?>
<html>
<head>
<title>Registered Users</title>
</head>
<body>
<div>
<?php
foreach (fetch_users()) as $user){
?>
<p>
<a href=""><?php echo $user['username']; ?></a>
</p>
<?php
}
?>
</div>
</body>
</html>
core/init.inc.php
<?php
session_start();
mysql_connect('localhost','root','1234');
mysql_select_db('youtube');
$path = dirname(__FILE__);
include("($path)/inc/user.inc.php");
$_SESSION['id']=1;
?>
core/inc/user.inc.php
<?php
//fetches all of the users from the table.
function fetch_users(){
$result = mysql_query('SELECT 'id' as 'id', 'username' as 'username' FROM 'user'');
$users = array();
//basically this is an array that goes through your database
while (($row = mysql_fetch_assoc($result)) !== false){
$users[] = $row;
}
return $users;
}
?>
user_list.php
<?php
include('core/init.inc.php');
?>
<html>
<head>
<title>Registered Users</title>
</head>
<body>
<div>
<?php
foreach (fetch_users()) as $user){
?>
<p>
<a href=""><?php echo $user['username']; ?></a>
</p>
<?php
}
?>
</div>
</body>
</html>
When I open http://localhost/user_list.php, I am supposed to see usernames, but I get: Parse error: syntax error, unexpected ')' in C:\wamp\www\user_list.php on line 13.
my database is called 'youtube' and my table is called 'user': http://s1085.photobucket.com/albums/j43 ... titled.png
Thanks a lot for any help!! I really appreciate it because this will be the most complex part of my site. I know that if I can get this to work the rest will be fine (except for maybe the search).
