Jump to content


Photo

Sorting record by current user


  • Please log in to reply
4 replies to this topic

#1 cnl83

cnl83
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 14 March 2006 - 10:56 PM

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.

<?
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.";

?>


#2 hitman6003

hitman6003
  • Members
  • PipPipPip
  • Advanced Member
  • 1,807 posts

Posted 14 March 2006 - 10:59 PM

Change:

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

to:

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

You may have to add in a "\n" or something along those lines for flash to intrepret each one seperatly.

#3 cnl83

cnl83
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 14 March 2006 - 11:12 PM

[!--quoteo(post=355111:date=Mar 14 2006, 10:59 PM:name=hitman6003)--][div class=\'quotetop\']QUOTE(hitman6003 @ Mar 14 2006, 10:59 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
Change:

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

to:

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

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.

#4 keeB

keeB
  • Staff Alumni
  • Advanced Member
  • 1,078 posts
  • LocationCalifornia

Posted 14 March 2006 - 11:27 PM

change

$query = "SELECT * FROM users";

to

$query = "SELECT * FROM users WHERE login = '<userlogin>' ";

Come visit my site to see my latest projects
http://nick.stinemates.org/wordpress/


#5 cnl83

cnl83
  • Members
  • PipPipPip
  • Advanced Member
  • 31 posts

Posted 14 March 2006 - 11:34 PM

[!--quoteo(post=355124:date=Mar 14 2006, 11:27 PM:name=keeB)--][div class=\'quotetop\']QUOTE(keeB @ Mar 14 2006, 11:27 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
change

$query = "SELECT * FROM users";

to

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


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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users