Similar to yesterday

This is a discussion on Similar to yesterday within the PHP General forums, part of the PHP Programming Forums category; $id_support contains 8 results $id_traffic contains 0 results (this is correct) $id_card returns a *single* result when it should return ...


Go Back   Usenet Forums > PHP Programming Forums > PHP General

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 04-26-2007
Dan Shirah
 
Posts: n/a
Default Similar to yesterday

$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'];
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'];
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'";
$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>

Reply With Quote
  #2 (permalink)  
Old 04-26-2007
Zoltán Németh
 
Posts: n/a
Default Re: [PHP] Similar to yesterday

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>

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT +1. The time now is 11:37 PM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0