how to filter valuelists(solved)

A place for users and developers of the Xataface to discuss and receive support.

how to filter valuelists(solved)

Postby zmmaj » Mon Oct 08, 2012 2:44 pm

well this is situation...

I have in table several Admins... but every of them can add own customer in table client
I was use command beforeSave() to save on one field of table client Admin UserName...

now I need to make valuelist for Admin, but with only that client name who have in filed saved Admin UserName ...

I was use next:
Code: Select all
function valuelist__Majstor(){
    static $majstor = -1;
    if ( !is_array($majstor) ){
        $majstor = array();
        $rest = mysql_query("select ID, ImePrezime from majstori", df_db());
        if ( !$rest ) throw new Exception(mysql_error(df_db()));
        while ($rowt = mysql_fetch_row($rest) ) $majstor[$rowt[0]] = $rowt[1];
    }
    return $majstor;
}

But in this case Admin can see every ImePrezime from every Admin... That is NOT goal...

I need something like...
Code: Select all
function valuelist__Majstor(){
    static $majstor = -1;
    if ( !is_array($majstor) ){
        $majstor = array();
        $rest = mysql_query("select ID, ImePrezime from majstori", df_db());
       $AdminName =mysql_query("select ID,AdminName from majstori", df_db());
        if ( !$rest ) throw new Exception(mysql_error(df_db()));
        while ($rowt = mysql_fetch_row($rest) and $AdminName = $user->val('UserName') ) $majstor[$rowt[0]] = $rowt[1];
    }
    return $majstor;
}

But this wont work.... :(
help?
Last edited by zmmaj on Tue Oct 16, 2012 8:19 am, edited 1 time in total.
zmmaj
 
Posts: 48
Joined: Tue Sep 25, 2012 10:34 pm

Re: how to filter valuelists

Postby silma » Wed Oct 10, 2012 12:07 am

You said you have one field "AdminUsername" in the client table, so why not include it in the request ?

Code: Select all
   
function valuelist__Client() {
   $auth =& Dataface_AuthenticationTool::getInstance();
   $user =& $auth->getLoggedInUser();

   $username = $user->val("Username");

   $out = array();

   $sql = "select ClientID, ClientName from clienttable where AdminUsername='".$username."' order by ClientName";
   $res = mysql_query($sql, df_db());
   while ($row = mysql_fetch_assoc($res) ) $out[$row['ClientID']] = $row['ClientName'];
      
   return $out;
}
   
   
silma
 
Posts: 87
Joined: Tue Apr 28, 2009 11:47 pm

Re: how to filter valuelists

Postby zmmaj » Wed Oct 10, 2012 5:14 am

Thank you man..,. that is that what I need :)))
zmmaj
 
Posts: 48
Joined: Tue Sep 25, 2012 10:34 pm


Return to Xataface Users

Who is online

Users browsing this forum: No registered users and 0 guests

cron
Powered by Dataface
© 2005-2007 Steve Hannah All rights reserved