Now this question is a bit from left field and I somehow doubt it will be possible, but here's what I'd like to do:
I have two tables in my database; a log table and a users table. In the log table, I have four fields I retreive:
Log - user,campaign,status,seconds
In the users table, I only need one field:
Users - full_name
However, the users table has a 'user' field that is the same data as it is in the log. What I'm wanting to do is compare the user field in the log to the user field in the users table to pull the full_name for that user into my array. For example:
Now this is an abbreviated version of what I have going on, but for this example, it'll suffice. This works in that it appends the full_name to the end of each entry the way I was hoping it would. HOWEVER! This method only works when l.user=u.user. There are also system events in the log that are logged as a special 'user' that doesn't appear in the users table. Ergo, when the query checks the log and sees these entries (where l.user<>u.user) it skips them. Problem is, I need them and adding the system 'user' to the users table isn't an available option (the user field is numeric and the system 'user' is alphanumeric).PHP Code:sql="SELECT l.user,l.campaign,l.status,l.seconds,u.full_name FROM log l,users u WHERE l.user=u.user AND <date range or other filters>";
$result=mysql_query($sql, $link);
while($row=mysql_fetch_array($result, MYSQL_NUM)){
$array[]=$row;
if(!in_array($row[4], $user_array){
$user_array[]=array$row[4];
}
}
Is there some way to include the system log entries having them entered into $array with $row[5] being left blank?



LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks