Jump to content


Photo

Retrieve data from 2 different database's same form


  • Please log in to reply
No replies to this topic

#1 ibda12u

ibda12u
  • Members
  • PipPip
  • Member
  • 23 posts

Posted 13 April 2006 - 04:39 PM

I have a phone list, that has all the contact details stored in 1 database.

My form retrieves all this data and displays it in a page.

What I would like to do is add a image that say in or out. (if the person has clocked in, or clocked out)
I wanted to do this by pulling data from my time clock database.

So when the page gets displayed it would look something like this

InOffice | Name | Phone Number | Office
In person1 111-1111 2b
Out person2 111-1112 2c

etc.......

My query for pulling the contacts works great, but added or tried to add the query to pull the time clock info in, and now my list doesn't display my contacts anymore. no errors.
Any idea's here is my code

<?
# List the contacts.
$qtable = "users";
$qfields = "userid, dept, location, name, phone, cell, email, initials, active";
# Sort by user (contact).

$qresult = mysql_query("select $qfields from $qtable where (phone != '' or cell != '') and (active = '1') order by name") or die ("Invalid Query: Possibly database server down.");

while(list($userid, $dept, $location, $name, $phone, $cell, $email, $initials)=mysql_fetch_row($qresult)){
$dept=stripslashes($dept);
$location=stripslashes($location);
$name=stripslashes($name);
$phone=stripslashes($phone);
$cell=stripslashes($cell);
$email=stripslashes($email);

# Get inoffice/outoffice
mysql_select_db (nuke,$db);
$qresult2 = mysql_query("select inoffice, username from nuke_users where username='$email'") or die ("Invalid Query: Possibly database server down.");
while(list($inoffice)=mysql_fetch_row($qresult2)){

?>
 <tr bgcolor="#FFFFFF">
                            <td align=center bgcolor=white>
<?
                            if ($inoffice==0) {
                              echo "<img src='images/out.jpg'>";
                            } elseif ($inoffice==1) {
                              echo "<img src='images/in.jpg'>";
                            } else {
                              echo "<img src='images/na.jpg'>";
                            }
                            ?>
                            </td>
                          <?
                            if ($email == "NA") {  ?>
                              <td><? echo $name; ?></td>
                          <?  } else { ?>
                              <td><? echo '<a href=mailto:' . $email . '>' . $name . '</a>'; ?></td>
                          <?  } ?>

                            <td><? echo $email; ?></td> <!--  -->
                            <td><? echo $dept; ?></td>
                            <td><? echo $location; ?></td>
                            <td><? echo $phone; ?></td>
                            <td><? echo $cell; ?></td>
                         </tr>
<? } } ?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users