2007. 04. 26, csütörtök keltezéssel 10.12-kor Dan Shirah ezt írta:
> $id_support contains 8 results
> $id_traffic contains 0 results (this is correct)
> $id_card returns a *single* result when it should return an amount equal to
> the number of records retrieved by $id_support + $id_traffic.
>
> So, if $id_support returns multiple records as an array and $sql_card is a
> query that looks for records in a table based on $id_support, shouldn't it
> return the multiple records?
>
> // Select all child support requests that are ready to be processed
> $sql_support ="SELECT * FROM support_payment_request WHERE status_code =
> 'P'";
> $result_support = mssql_query($sql_support) or die(mssql_error());
> if(!empty($result_support)) {
> while ($row_support = mssql_fetch_array($result_support)) {
> $id_support = $row_support['_card_id'];
$id_support[] = $row_support['_card_id'];
otherwise it will only contain the last element
> print_r ($id_support); // This returns multiple records
> }
> }
>
> // Select all traffic/criminal requests that are ready to be processed
> $sql_traffic ="SELECT * FROM traffic_criminal_payment_request WHERE
> status_code = 'P'";
> $result_traffic = mssql_query($sql_traffic) or die(mssql_error());
> if(!empty($result_traffic)) {
> while ($row_traffic = mssql_fetch_array($result_traffic)) {
> $id_traffic = $row_traffic['credit_card_id'];
$id_traffic[] = $row_traffic['credit_card_id'];
as above
> print_r ($id_traffic); // This currently returns no records
> since all have been processed
> }
> }
> /* Select all credit_card records where the child support
> and traffic/criminal records have the same credit_card_id
> and have a status of "P" */
> $sql_card = "SELECT * FROM payment_request WHERE card_id = '$id_support'
> OR card_id = '$id_traffic'";
since $id_support and $id_traffic should be arrays, the above query
won't work with them. you should rather make a foreach for example,
query on every element of the arrays and collect the results in a third
array
foreach ($id_support as $ids) {
$sql_card = "SELECT * FROM payment_request WHERE card_id = '$ids'";
$result_card = mssql_query($sql_card) or die(mssql_error());
while ($row_card = mssql_fetch_array($result_card)) {
$id_card = $row_card['card_id'];
$dateTime = $row_card['date_request_received'];
$records[] = array($id_card, $dateTime);
}
}
then do a similar loop with $id_traffic.
then you'll have all records in $records, so you can print them out in
another loop.
greets
Zoltán Németh
> $result_card = mssql_query($sql_card) or die(mssql_error());
> ?>
> <table width='780' border='1' align='center' cellpadding='2' cellspacing='2'
> bordercolor='#000000'>
> <?php
> if(!empty($result_card)) {
> while ($row_card = mssql_fetch_array($result_card)) {
> $id_card = $row_card['card_id'];
> $dateTime = $row_card['date_request_received'];
> print_r ($id_card);
> ?>
> <tr>
> <td width='88' height='13' align='center' class='tblcell'><div
> align='center'><?php echo "<a
> href='javascript:editRecord($id_card)'>$id_card</a>" ?></div></td>
> <td width='224' height='13' align='center' class='tblcell'><div
> align='center'><?php echo "$dateTime" ?></div></td>
> <td width='156' height='13' align='center' class='tblcell'><div
> align='center'><?php echo "To Be Processed" ?></div></td>
> <td width='156' height='13' align='center' class='tblcell'><div
> align='center'><?php echo "Payment Type" ?></div></td>
> <td width='156' height='13' align='center' class='tblcell'><div
> align='center'><?php echo "Last Processed By" ?></div></td>
> </tr>
> <?php
> }
> }
> else {
> echo "<br>";
> }
> ?>
> </table>
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php