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
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.
Link to comment
Share on other sites

[!--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.
Link to comment
Share on other sites

[!--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>?
Link to comment
Share on other sites

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.