Jump to content


This topic is now archived and is closed to further replies.


Retrieve data from 2 different database's same form

Recommended Posts

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


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)){

# 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.");

<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'>";
                            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>
<? } } ?>[/code]

Share this post

Link to post
Share on other sites


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.