Jump to content

Recommended Posts

Hi All,

 

I have a page called "myaccount.php" where I want a client to go and only see their information. right now, the page displays all client rows and I can't seem to figure out how to sort by the data by current user...Any help is greatly appreciated!

 

This is what I have so far...

 

Thanks!

Session verify:

<?php
session_start();

if (!isset($_SESSION['user']))
{
die ("Access Denied");
}

?>

 

Display table;

<?php
      include 'dbc.php';
  $data = mysql_query("SELECT * FROM users order by full_name where user_email LIKE ".$_SESSION['user']."")
  or die(mysql_error());
  Print "<table border=1 cellpadding=2 cellspacing=0 width=100%>
  <tr>
	 <td valign=top align=left><strong>Name</strong></td>
	 <td valign=top align=left><strong>Address</strong></td>
	 <td valign=top align=left><strong>Joined</strong></td>
	 <td valign=top align=left><strong>Email</strong></td>
         </tr>";
 while($info = mysql_fetch_array( $data ))
   {
	Print "<tr>";
	Print "<td bgcolor=#accbed>".$info['full_name'] . "</td> ";
	Print "<td>".$info['address'] . "</td> ";
	Print "<td>".$info['joined'] . "</td> ";
	Print "<td>".$info['user_email'] . "</td></tr> ";

	}
	Print "</table>";
?>

Try modifying your query to something like:

"SELECT * FROM users WHERE user_email = {$_SESSION['user']} ORDER BY full_name"

 

I just tried it and I got the following error within the page.

 

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '@earthlink.net ORDER BY full_name' at line 1

Maybe try

"SELECT * FROM users WHERE user_email = '{$_SESSION['user']}' ORDER BY full_name"

OR

"SELECT * FROM users WHERE user_email = \"{$_SESSION['user']}\" ORDER BY full_name"

 

The second line worked!!!! I'm all set guys! Thank you so much for your help!!!!!!

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.