Hello,

I've been having extensive email conversations with people over at
MySQL.com's email list.  From what I'm able to prove using myphpadmin,
my problem is not with the query, but with how PHP handles it.

All I want to do is open a text file, read in  two van numbers that are
there.  I want to then query a table and find out what the gross pay was
for each van.

I've set up a test model.  The text file contains two van numbers and
looks like this:
1111
2222

The table contains the following:
+-------------+-----------+
 |  vanNumber |   grossPay |
 |--------------|------------|
 |            1111 |        1000  |
 |            1111 |          500  |
 |            2222 |          100  |
 |            2222 |          100  |
+-------------+-----------+

I can log into myphpadmin and execute the following query:
SELECT SUM(grossPay) FROM Nero_Daily_03 WHERE vanNumber=2222

I get a result of 200, which is the correct answer.

I can log into myphpadmin and execute the following query:
SELECT SUM(grossPay) FROM Nero_Daily_03 WHERE vanNumber=1111

I get a result of 1500, which is the correct answer.

Now, lets jump to my php code.  Here is the Routine I'm trying to
accomplish:

if ($viewYearEnd)
{
$readThis = ($dir."vans.txt");
$Open = fopen ($readThis, "r") or die ("Call Roger, cannot open file
$readThis");
$vanList = file ($readThis);
fclose ($Open);

$trimmedVanOne = rtrim($vanList[0]);
$trimmedVanTwo = rtrim($vanList[1]);
$sql = "SELECT SUM(grossPay) FROM Nero_Daily_03 WHERE vanNumber=1111";
$run_sql = mysql_query($sql);
?>
  <table>
  <tr>
  <td align="left"><?php echo $trimmedVanOne ?></td>
  <td align="left"><?php echo $run_sql ?></td>
 </tr>
<?php
$sql = "SELECT SUM(grossPay) FROM Nero_Daily_03 WHERE vanNumber=2222";
$run_sql = mysql_query($sql);
?>
  <tr>
  <td align="left"><?php echo $trimmedVanTwo ?></td>
  <td align="left"><?php echo $run_sql ?></td>
 </tr>
  </table>
<?php
exit;
}

When I run this bit of code I get the following output:
1111  Resource id #3
2222  Resource id #4

When I should be getting:
1111  1500
2222  200

For some reason the php is not 'parsing' my query(s) correctly.  Can
anyone tell me why?  Please?......


Thanks,
Roger




-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to