Different results in function on PHP 4 and PHP 5
| From: | Stephen Lake | Date: | Tue, 28 Feb 2006 20:22:30 +0000 |
| Subject: | Different results in function on PHP 4 and PHP 5 | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-231231@lists.php.net to get a copy of this message | ||
Good Afternoon Folks,
After pounding my head into the ground for days over a problem I am having,
I decided to post here to see what you guys and girls think.
I have a user defined function that outputs categories from a database and
assosiated eShops. Now in PHP 4 this is working perfectly however my client
has PHP 5, and the function is only outputting the first eshop for each
category. How can I get this working properly in PHP 5?
Below is the function in question:
function getAllCategories($mysql,$region) {
$cat_list = "SELECT * FROM ilp_category_zone ORDER BY category";
$mysql->execute_query($cat_list);
if($mysql->numrows() <= 0) {
print "There are currently no categories";
} else {
while($r = $mysql->fetchrow()) {
$cid[] = $r['cid'];
}
foreach($cid as $value) {
$get_shops_by_cat = "SELECT * FROM
ilp_eshop_zones,ilp_category_zone,ilp_region_zone WHERE
ilp_category_zone.cid=ilp_eshop_zones.cid AND
ilp_eshop_zones.cid='".$value."' AND
ilp_region_zone.rid='".$region."' ORDER
BY ilp_category_zone.category";
$mysql->execute_query($get_shops_by_cat);
if($mysql->numrows() <= 0) {
//print "No eShops for the category";
} else {
while($r2 = $mysql->fetchrow()) {
$eid = $r2['eid'];
$category = $r2['category'];
$name = $r2['name'];
$conphrase = $r2['conphrase'];
$description = $r2['description'];
$rid = $r2['rid'];
$flag = $r2['flag_locale'];
$num = $mysql->numrows();
if(!$l) {
print "<h2><img
src=\"images/flags/".$flag."\"> ".$category."</h2>\n";
print "<form style=\" display: inline; margin-bottom: 0px;\"
name=\"categories\"><a id=\"cat-paragraph\"><a
id=\"cat\">".$name ." <font
color=\"#CC0000\"><b>".$conphrase."</b></font>\n";
print "<select name=\"region\" size=\"1\"
onChange=\"location.href=document.categories.region.options[document.categories.region.selectedIndex].value\">\n";
getRegion($mysql,$region,$eid,$_SERVER['PHP_SELF']);
print "</select>\n";
print "<input type=\"button\" value=\"Go!\"
onClick=\"javascript:goTo(this.form.region);\">\n";
print "<br>\n";
print "<a id=\"desc\">".$description.
"</a></i></p></form><br><br>\n";
print "<HR color=#f0f8ff SIZE=1>";
$l=$num-1;
} else {
print "<form style=\" display: inline; margin-bottom: 0px;\"
name=\"categories\"><a id=\"cat-paragraph\"><a
id=\"cat\">".$name ." <font
color=\"#CC0000\"><b>".$conphrase."</b></font>\n";
print "<select name=\"region\" size=\"1\"
onChange=\"location.href=document.categories.region.options[document.categories.region.selectedIndex].value\">\n";
getRegion($mysql,$region,$eid,$_SERVER['PHP_SELF']);
print "</select>\n";
print "<input type=\"button\" value=\"Go!\"
onClick=\"javascript:goTo(this.form.region);\">\n";
print "<br>\n";
print "<a id=\"desc\">".$description.
"</a></i></p></form><br><br>\n";
print "<HR color=#f0f8ff SIZE=1>";
$l--;
}
}
}
}
}
}
If anyone can give me some pointers or point out probable reasons for this
not working properly on PHP 5, then it would be much appreciated.
Best Regards,
Steve