Hi all,
I'm trying to grab information from two DBs one being a mamber db and the
other a report DB
I want to print a list of users(pilots for a Virtual Airline) from the Pilot
db and then next to them the n� of reports and total hours they have so far
from the REPORT DB. The Pilot ID on this list must be a link so that when
clicked it will show the details of the reports.
I got this to but in a general for using a variable $login
so when the pilot/member logins it stores his ID in the $login and then I
use the SELECT * FROM table WHERE column = $login
to be more specific using this code:
<?
require("require/config.php");
require("require/authentication.php");
$auth=authenticate($login, $password);
$link = mysql_connect("localhost", "user", "password")
or die("Could not connect");
mysql_select_db("databse") or die("Could not select database");
$query = "SELECT flight_hhmm FROM pirep WHERE pilot_id='$login'";
$result = mysql_query($query) or die("Query failed");
while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {
$hhmm=explode(':',$line['flight_hhmm']);
$totalm+=$hhmm[0]*60+$hhmm[1];
}
mysql_free_result($result);
?>
then to print out the number of hours I use this:
<?
echo $auth["login"]. '. You have ';
echo floor($totalm / 60).':'.($totalm % 60). ' total hours.';
?>
this show the total hours for $login which is the pilot id in the report DB.
now I have this code to produce TOTAL reports for the site:
$link = mysql_connect("localhost", "user", "password")
or die("Could not connect");
mysql_select_db("database") or die("Could not select database");
$query = "SELECT * FROM pirep ";
$result = mysql_query($query) or die("Query failed");
$nb1 = mysql_numrows($result);
This gets me the n� of rows for all pilots the using echo $nb1 will print
the total reports.
Now I tried alot but no luck. I wanted to get a list like so:
MVC103 - 100 reports Filed - 130 Hours Total
MVC104 - 10 report filed - 50 hours total
etc,
having the ID (MVCxxx) being a link so when clicked it will show the
datails. I tried the count() statement but like I said I new to PHP.
If anyone can help PLS.. take a look at the site, mind you it is in
portuguese http://novo.cdmvirtual.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php