After literally days of searching for a solution, I found a thread on this site talking about exactly what I need. There's a problem, though. I need a next step. I found how to turn a query results into a link to a specific page, based on the contractorid, but now I need to know how to populate a table on that page with his information, only. This is what I have on the first page:
echo "<td class='cell_client_left' align='center'>";
echo '<a href="week.php?contractorid='.$contractorid.'">' .$fname. "" .$lname. '</a>';
echo "</td>";
Now, when I click on a result, the address bar populates with the correct contractorID which is AWESOME, but... This is my second page:
<?PHP
session_start();
if( $_SESSION['login_type'] != "Client" ) header("Location:./errors/notclient.php");
//Troubleshooting
//include_once( "./includes/checksupers.php" );
//Require DB connect info
require_once( "./templates/header.php" );
require_once( "./includes/config.php" );
if ( $client_id == 3 ) $client_id = 14;
$sort = $_POST['sort'];
$clientid = $_SESSION['client_id'];
if( $sort == NULL )
{
$client_display_timecards_sql =
"SELECT Contractor.ContractorFName,
Contractor.ContractorLName,
TimeCards.ContractorID,
TimeCards.Week,
TimeCards.PO,
TimeCards.TimeCardDate,
TimeCards.TimeCardID,
TimeCards.TimeIn,
TimeCards.BreakBegin,
TimeCards.BreakEnd,
TimeCards.TimeOut,
TimeCards.HoursTotal,
TimeCards.WorkDescription
FROM Contractor
JOIN TimeCards
ON Contractor.ContractorID = TimeCards.ContractorID
WHERE TimeCards.ClientID = $clientid
AND TimeCards.Approved = 0";
$res_client_display_timecards = mysql_query( $client_display_timecards_sql )
or die( "Could not do client display cards query: " . mysql_error() );
echo <<<END
<span class="bold">Time Entry Details: </span>
<br /><br />
<div class="board" id="board_week_timecards">
<form action="week.php" method="post">
<div id="list_week_timecards">
<table id="table_week_timecards">
<tr>
<td class="head_client_left" align="center">PO #</td>
<td class="head_client" align="center">Date</td>
<td class="head_client" align="center">Time In</td>
<td class="head_client" align="center">Break Begin</td>
<td class="head_client" align="center">Break End</td>
<td class="head_client" align="center">Time Out</td>
<td class="head_client_right" align="center">Hours</td>
</tr>
END;
$x = 0;
while( $client_display_timecards = mysql_fetch_assoc( $res_client_display_timecards ) )
{
$lname = $client_display_timecards['ContractorLName'];
$fname = $client_display_timecards['ContractorFName'];
$contractorid = $client_display_timecards['ContractorID'];
$week = $client_display_timecards['Week'];
$po = $client_display_timecards['PO'];
$timecarddate = $client_display_timecards['TimeCardDate'];
$timecardid = $client_display_timecards['TimeCardID'];
$timein = $client_display_timecards['TimeIn'];
$breakbegin = $client_display_timecards['BreakBegin'];
$breakend = $client_display_timecards['BreakEnd'];
$timeout = $client_display_timecards['TimeOut'];
$hourstotal = $client_display_timecards['HoursTotal'];
$workdescription = $client_display_timecards['WorkDescription'];
$current_cards[$x] = array(
'contractorfname' => "$fname",
'contractorlname' => "$lname",
'week' => "$week",
'po' => "$po",
'timecarddate' => "$timecarddate",
'timecardid' => "$timecardid",
'timein' => "$timein",
'breakbegin' => "$breakbegin",
'breakend' => "$breakend",
'timeout' => "$timeout",
'hourstotal' => "$hourstotal",
'workdescription' => "$workdescription"
);
echo <<<END
<tr>
<td class="cell_client_left" align="center">$po</td>
<td class="cell_client" align="center">$timecarddate</td>
<td class="cell_client" align="center">$timein</td>
<td class="cell_client" align="center">$breakbegin</td>
<td class="cell_client" align="center">$breakend</td>
<td class="cell_client" align="center">$timeout</td>
<td class="cell_client_right" align="center">$hourstotal</td>
</tr>
<tr>
<td class="description_left" align="center"> </td>
<td class="description_right" colspan="7">$workdescription</td>
</tr>
END;
++$x;
}
echo "
</table>
</div>
</form>
</div>";
}
?>
What do I need to do to make this table show ONLY entries from the contractorID provided from the first page?