Jump to content

Sorting record by current user


cnl83

Recommended Posts

This script is for Flash, but it works cause I tested it out. All im doing is pulling the record for the current user. Basically, just the name for now. The problem I have is that, it is pulling the first record int he DB. Im still a noob, and if someone could help with this code, that would be awesome.

[code]
<?
include ('Include.inc');
require ('/home/apex/scormsource-www/'."/classes/access_user/access_user_class.php");

$page_protect = new Access_user;
// $page_protect->login_page = "login.php"; // change this only if your login is on another page
$page_protect->access_page(); // only set this this method to protect your page

if (isset($_GET['action']) && $_GET['action'] == "log_out") {
    $page_protect->log_out(); // the method to log off
}


//stuff for FLASH

mysql_connect($DBhost,$DBuser,$DBpass);
@mysql_select_db("$DBName");

$mid=$mid-1;

$query = "SELECT * FROM users";
$result = mysql_query($query);

$real_name = mysql_result($result,0,"real_name");
//$one = mysql_result($result,0,"one");
print "&real_name=$real_name";
//print "&one=$one";


print "&status=DONE.";

?>[/code]
Link to comment
https://forums.phpfreaks.com/topic/4985-sorting-record-by-current-user/
Share on other sites

Change:

[code]$real_name = mysql_result($result,0,"real_name");
//$one = mysql_result($result,0,"one");
print "&real_name=$real_name";
//print "&one=$one";[/code]

to:

[code]for ($i = 0; $i < mysql_num_rows($result); $i++) {
  print "&real_name=" . mysql_result($result,$i,"real_name");
}[/code]

You may have to add in a "\n" or something along those lines for flash to intrepret each one seperatly.
[!--quoteo(post=355111:date=Mar 14 2006, 10:59 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Mar 14 2006, 10:59 PM) [snapback]355111[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Change:

[code]$real_name = mysql_result($result,0,"real_name");
//$one = mysql_result($result,0,"one");
print "&real_name=$real_name";
//print "&one=$one";[/code]

to:

[code]for ($i = 0; $i < mysql_num_rows($result); $i++) {
  print "&real_name=" . mysql_result($result,$i,"real_name");
}[/code]

You may have to add in a "\n" or something along those lines for flash to intrepret each one seperatly.
[/quote]
Thank you for your reply...
Im not trying to read all the records at one time though. Im trying to read the record for the current user.
[!--quoteo(post=355124:date=Mar 14 2006, 11:27 PM:name=keeB)--][div class=\'quotetop\']QUOTE(keeB @ Mar 14 2006, 11:27 PM) [snapback]355124[/snapback][/div][div class=\'quotemain\'][!--quotec--]
change

[code]$query = "SELECT * FROM users";[/code]

to

[code]$query = "SELECT * FROM users WHERE login = '<userlogin>' ";[/code]
[/quote]


Ok thanks...where are you getting <userlogin>?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.