Jump to content

Retrieve data from 2 different database's same form


ibda12u

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

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

[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>
<? } } ?>[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

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.