swatisonee
12-13-2005, 01:52 AM
hi,
I have a script that outputs data from a table except the user who put in the data ! Am going spare figuring out where I could be going wrong. The script just passes the name in the row of the 1st record to all the entries. The table with user info. works well for all other scripts
Pl advise. Thanks !
<? include("protection.php"); ?>
<?php
$group = $HTTP_POST_VARS["group"];
$year = $HTTP_POST_VARS["year"];
mysql_connect("localhost", $dbname, $dbpasswd )
or die ("Unable to connect to server.");
mysql_select_db($database)
or die ("Unable to select database.");
$result = mysql_query("SELECT * FROM `Group` WHERE id='$group' ");
$myrow = mysql_fetch_array($result);
$coname = $myrow["name"];
echo "<font face=arial size=2>";
print(date("l F d, Y"));
echo "<p><font color=red size=4> Payments of ";
echo $coname;
echo " for the year ";
echo $year;
echo "</font><p><hr>";
?>
<table border="1" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr bgcolor="#C0C0C0">
<td><font size=2 face=Tahoma><b>Payee</tr>
<td><font size=2 face=Tahoma><b> Fee</tr>
<td><font size=2 face=Tahoma><b>Leave</tr>
<td><font size=2 face=Tahoma><b>Loan </tr>
<td><font size=2 face=Tahoma><b>Deduction 1</tr>
<td><font size=2 face=Tahoma><b>Deductions 2</tr>
<td><font size=2 face=Tahoma><b>Increment</tr>
</tr>
<?
mysql_connect("localhost", $dbname, $dbpasswd )
or die ("Unable to connect to server.");
mysql_select_db($database)
or die ("Unable to select database.");
$sql1 = "SELECT * FROM `Contract` WHERE `group` ='$group' && `Month` ='$month' && `Year`= '$year' ORDER BY `userid` asc ";
$result1 = mysql_query($sql1)
or die (mysql_error());
if ($myrow1 = mysql_fetch_array($result1)) {
$userid = $myrow1["userid"];
$result2 = mysql_query("SELECT * FROM `users` WHERE userid='$userid' ");
$myrow2 = mysql_fetch_array($result2);
$first_name = $myrow2["firstname"];
$last_name = $myrow2["lastname"];
$name = $first_name." ".$last_name;
do {
printf("<tr>
<td><font face=\"Tahoma\" size=\"2\"> %s </td>
<td><font face=\"Tahoma\" size=\"2\"> %s </td>
<td><font face=\"Tahoma\" size=\"2\"> %s </td>
<td><font face=\"Tahoma\" size=\"2\"> %s </td>
<td><font face=\"Tahoma\" size=\"2\"> %s </td>
<td><font face=\"Tahoma\" size=\"2\"> %s </td>
<td><font face=\"Tahoma\" size=\"2\"> %s </td>
</tr>",
$name,
$myrow1["Fee"],
$myrow1["Leave"],
$myrow1["Loan"],
$myrow1["Deduction1"],
$myrow1["Deduction2"],
$myrow1["Increment"] );
} while ($myrow1 = mysql_fetch_array($result1));
} else {
echo "Sorry, no records were found!";
}
?>
I have a script that outputs data from a table except the user who put in the data ! Am going spare figuring out where I could be going wrong. The script just passes the name in the row of the 1st record to all the entries. The table with user info. works well for all other scripts
Pl advise. Thanks !
<? include("protection.php"); ?>
<?php
$group = $HTTP_POST_VARS["group"];
$year = $HTTP_POST_VARS["year"];
mysql_connect("localhost", $dbname, $dbpasswd )
or die ("Unable to connect to server.");
mysql_select_db($database)
or die ("Unable to select database.");
$result = mysql_query("SELECT * FROM `Group` WHERE id='$group' ");
$myrow = mysql_fetch_array($result);
$coname = $myrow["name"];
echo "<font face=arial size=2>";
print(date("l F d, Y"));
echo "<p><font color=red size=4> Payments of ";
echo $coname;
echo " for the year ";
echo $year;
echo "</font><p><hr>";
?>
<table border="1" style="border-collapse: collapse" bordercolor="#111111" width="100%">
<tr bgcolor="#C0C0C0">
<td><font size=2 face=Tahoma><b>Payee</tr>
<td><font size=2 face=Tahoma><b> Fee</tr>
<td><font size=2 face=Tahoma><b>Leave</tr>
<td><font size=2 face=Tahoma><b>Loan </tr>
<td><font size=2 face=Tahoma><b>Deduction 1</tr>
<td><font size=2 face=Tahoma><b>Deductions 2</tr>
<td><font size=2 face=Tahoma><b>Increment</tr>
</tr>
<?
mysql_connect("localhost", $dbname, $dbpasswd )
or die ("Unable to connect to server.");
mysql_select_db($database)
or die ("Unable to select database.");
$sql1 = "SELECT * FROM `Contract` WHERE `group` ='$group' && `Month` ='$month' && `Year`= '$year' ORDER BY `userid` asc ";
$result1 = mysql_query($sql1)
or die (mysql_error());
if ($myrow1 = mysql_fetch_array($result1)) {
$userid = $myrow1["userid"];
$result2 = mysql_query("SELECT * FROM `users` WHERE userid='$userid' ");
$myrow2 = mysql_fetch_array($result2);
$first_name = $myrow2["firstname"];
$last_name = $myrow2["lastname"];
$name = $first_name." ".$last_name;
do {
printf("<tr>
<td><font face=\"Tahoma\" size=\"2\"> %s </td>
<td><font face=\"Tahoma\" size=\"2\"> %s </td>
<td><font face=\"Tahoma\" size=\"2\"> %s </td>
<td><font face=\"Tahoma\" size=\"2\"> %s </td>
<td><font face=\"Tahoma\" size=\"2\"> %s </td>
<td><font face=\"Tahoma\" size=\"2\"> %s </td>
<td><font face=\"Tahoma\" size=\"2\"> %s </td>
</tr>",
$name,
$myrow1["Fee"],
$myrow1["Leave"],
$myrow1["Loan"],
$myrow1["Deduction1"],
$myrow1["Deduction2"],
$myrow1["Increment"] );
} while ($myrow1 = mysql_fetch_array($result1));
} else {
echo "Sorry, no records were found!";
}
?>