php - mysql linux pear
GOAL:
I have 2 tables one is XML_Lenders the other is PostedApps. XML_Lenders is all the lenders we have available to post apps to. PostedApps is all apps that have been posted. I am so far good up to the point where the inital posting of the app hits the first lender, the XML response is parsed and the results are stored in PostedApps. I am looking to somehow make it so that when the response is declined, the app is sent to the next available lender. I have tried a few things with no sucess. I can get it to post the app over and over again in a loop to the lenders or to one lender etc, but i can not figure out how to post the app only once to each then quit when there are no more left to post to! The code i think i need is simply a MYSQL SELECT WHERE statment and possibly a foreach or while loop that will maybe use an array to select the next lender and quit once there are no more available.
PLEASE HELP!!!
The coding is very lengthy, if someone could please lend a hand i can email the pages etc for a fuller viewing. Below is the small area i am stuck at:
session_start();
global $lenderlist;
$lenderlist[] = "";
$total = array_unshift($lenderlist, "$lenderdata[lender_id]");
$hostname = "localhost";
$username = "########";
$dbpassword = "#######";
$database = "##########";
mysql_connect ($hostname, $username, $dbpassword) or die (mysql_error());
$connect = mysql_select_db( $database ) or die (mysql_error());
global $next_lender;
while( $next_lender = 0 )
{
foreach($lenderlist as $value)
{
$res = mysql_query("SELECT * FROM XML_Lender WHERE cc_lender_id <> '$value' AND active = 'YES'
AND no_under_1000 LIKE '%".$SESSION['per_month']."%' AND no_checking LIKE '%".$SESSION['active']."%' AND no_part_time LIKE '%".$SESSION['full_time']."%'
AND on_days LIKE '%".$SESSION['day_of_week']."%' AND accept_states LIKE '%".$SESSION['home_state']."%' AND no_direct_deposit LIKE '%".$SESSION['direct_deposit']."%'
AND employment_min < '".$_SESSION['days_employed']."' ORDER BY totem ASC") or die(mysql_error());
$row = mysql_fetch_assoc($res);
$next_lender = "".$row['cc_lender_id']."";
}
mysql_free_result($res);
}
if ("".$_SESSION['next_lender']."" == "0")
{
$redirect = ("www.#########.com");
header("Location: $redirect");
("Location: $redirect");
}
else
{
//recreate lender array
$lenderdata = "";
global $lenderdata;
$lenderdata = array(
"dest_url" => "".$row['post_url']."",
"user_id" => "".$row['user_id']."",
"password" => "".$row['password']."",
"store_id" => "".$row['store_id']."",
"trans_type" => "".$row['trans_type']."",
"mkt_code" => "".$row['mkt_code']."",
"rcvd_from" => "".$row['rcvd_from']."",
"lender_id" => "".$row['cc_lender_id']."",
"packet_file" => "".$row['xml_packet_file']."");
session_register ("lenderdata");
Z