You are here: Complicated while loop for a simpleton « PHP Programming Language « IT news, forums, messages
Complicated while loop for a simpleton

Posted by Nancy on 02/27/06 01:27

Greetings:

First, I apologize if my posting format is improper. The code below does
what I intended it to do, but presently only displays 1 table entry. I've
grown it to this point, but really need it to loop through the table and do
everything where data_store_no matches $store_no. I've tried placing where
at a couple different points with no real success - it either doesn't work
at all, exceeds the time allowed for a process (presently set to 60 sec) or
still only displays one table row. I regularly have problems understanding
the online documentation and am obviously way over my head. Am I trying to
do too much for it to loop? I need to display, in table format, 4 fields
from each row that appears in the table where it matches store_no. I am
limited to php ver 4.3.2. Any efficiency pointers and stupid mistake
notices are also welcome.
TIA!!
nan

[code]
$store_no = $HTTP_GET_VARS['store_no'];

// Lets look and see if there are any counts on file to retrieve
$data_count_query = db_query("select data_query_no, data_query_id,
data_store_no, data_count, data_return_code, data_return_message,
data_select, data_query_date, data_zip4, data_radius from data_count_request
where data_store_no = '" . $store_no . "'");
// Set some variables we'll need
$zip4 = $data_count_values['data_zip4'];
$data_date = $data_count_values['data_query_date'];
$data_date_formatted = substr($data_date,4,2) . '/' . substr($data_date,6,2)
.. '/' . substr($data_date,0,4);

if ($data_count_values['data_store_no']) { // There is something in the
data_count_request table for this store
// set titles for data selects
$DS001 = 'Nurturing Moms';
$DS002 = 'Fill';
$DS003 = 'Leading Edge Food Focus';
$data_select = $$data_count_values['data_select']; // turns returned
field into acutal variable
// Check and see what the status of the count is
if ($data_count_values['data_return_code'] == '99' AND
$data_count_values['data_count'] == '0') {
// This count was still processing earlier, lets look again and see
if it's ready
// Specify the URL string to open
$queryid = $data_count_values['data_query_id'];
$url =
"http://data.website.com/databridge/databridge.asp?id=12345&pwd=PaSsWoRd&actioncode=2&campaign=01&queryid=$queryid";
// open the url, get the returned data, close the url.
$fp = fopen($url, "r");
$strYourXML = fgets($fp);
fclose($fp);

// Parse the returned XML into a multidemensional array
$objXML = new xml2Array();
$arrOutput = $objXML->parse($strYourXML);

// Flatten the array into a single array
flattenArray($arrOutput);
// Format it in a way we can use
$formatted = array(
$tmp['name0']=>$tmp['tagData0'], // COUNT
$tmp['name1']=>$tmp['tagData1'], // PRICE
$tmp['name2']=>$tmp['tagData2'], // QUERYID
$tmp['name3']=>$tmp['tagData3'], // CAMPAIGN
$tmp['name4']=>$tmp['tagData4'], // RETURNCODE
$tmp['name5']=>$tmp['tagData5'], // RETURNMSG
);
if ($formatted['RETURNCODE'] == '0' AND
$formatted['RETURNMSG'] == 'success') {
$count = $formatted['COUNT']; // count returned from
Experian
db_query("update data_count_request set data_count =
'" . $count . "', data_return_code = '" . $formatted['RETURNCODE'] . "',
data_return_message = '" . $formatted['RETURNMSG'] . "' where data_query_id
= '" . $formatted['QUERYID'] . "'");
}
// Checked data web site and count still processing
elseif ($formatted['RETURNCODE'] == '99' AND
$formatted['COUNT'] == '0'){ // count still processing

$count = '<font color="red">Count Still Processing</font>';
}
}
// Pull counts from table if they are there
if ($data_count_values['data_return_code'] == '0' AND
$data_count_values['data_return_message'] == 'success') {
$count = $data_count_values['data_count'];

$data_listing = '<tr><td>' . $data_select . '</td>
<td>' . $count . '</td>
<td>' . $data_count_values['data_radius'] . '
mi.</td>
<td>' . $data_date_formatted .'</td></tr>';
}
} else { // There are no count requests for this store.
$count = '<font color="red">No requests have been made</font>';
}
[/code]

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация