problem with else if
Posted: Tue Jul 06, 2010 6:07 am
I have the following piece of code, which redirects to different pages.
The first half will send a user to a page based on if 'url_text1' is set or not. This bit works fine.
It is the Else part I need to change and everything I try just doesnt seem to want to work. Currently if the 'url_text1' is not set, then it will redirect to 1 page.
However I need it to redirect to 4 varied pages based on an ID pulled from the table.
The above is the clean code. The following is my edit which so far doesn't do what I need it to.
The ' $_REQUEST['cid']=='49' ' refers to an ID from the table which defines a product location.
Any help would be awesome!
Thanks,
Aravona
The first half will send a user to a page based on if 'url_text1' is set or not. This bit works fine.
It is the Else part I need to change and everything I try just doesnt seem to want to work. Currently if the 'url_text1' is not set, then it will redirect to 1 page.
However I need it to redirect to 4 varied pages based on an ID pulled from the table.
Code: Select all
if(isset($_REQUEST['URL_Text1'])){
$WHEre='';
$SUBCat_NaMe=explode("-",$_REQUEST['URL_Text1']);
$lastValue=$SUBCat_NaMe[sizeof($SUBCat_NaMe)-1];
for($i=0;$i<sizeof($SUBCat_NaMe);$i++){
if($WHEre==""){
$WHEre=" name LIKE '".$SUBCat_NaMe[$i]."%'";
}else if($i==sizeof($SUBCat_NaMe)-1){
$WHEre.=" AND name LIKE '%".$SUBCat_NaMe[$i]."'";
//$WHEre.=" AND subcategory LIKE '%".$SUBCat_NaMe[$i]."'";
}else{
$WHEre.=" AND name LIKE '%".$SUBCat_NaMe[$i]."%'";
}
}
$query = "SELECT cID FROM ver_child WHERE $WHEre";
$result_SET = $class->ResultSet($query);
if($class->NumRows($result_SET)!=0){
$_REQUEST['cmd']=2;
$row_SET = $class->FetchObject($result_SET);
$_REQUEST['SCID']=$row_SET->cID;
}
else{
$query = "SELECT prID FROM ver_pro WHERE $WHEre";
$result_SET = $class->ResultSet($query);
$_REQUEST['cmd']=7;
$row_SET = $class->FetchObject($result_SET);
$_REQUEST['pr']=$row_SET->prID;
}
}Code: Select all
if(isset($_REQUEST['URL_Text1'])){
$WHEre='';
$SUBCat_NaMe=explode("-",$_REQUEST['URL_Text1']);
$lastValue=$SUBCat_NaMe[sizeof($SUBCat_NaMe)-1];
for($i=0;$i<sizeof($SUBCat_NaMe);$i++){
if($WHEre==""){
$WHEre=" name LIKE '".$SUBCat_NaMe[$i]."%'";
}else if($i==sizeof($SUBCat_NaMe)-1){
$WHEre.=" AND name LIKE '%".$SUBCat_NaMe[$i]."'";
//$WHEre.=" AND subcategory LIKE '%".$SUBCat_NaMe[$i]."'";
}else{
$WHEre.=" AND name LIKE '%".$SUBCat_NaMe[$i]."%'";
}
}
$query = "SELECT cID FROM ver_child WHERE $WHEre";
$result_SET = $class->ResultSet($query);
if($class->NumRows($result_SET)!=0){
$_REQUEST['cmd']=2;
$row_SET = $class->FetchObject($result_SET);
$_REQUEST['SCID']=$row_SET->cID;
}
else{
if ($_REQUEST['cid']=='49'){
$_REQUEST['cmd']=9;
}
else {
$query = "SELECT prID FROM ver_pro WHERE $WHEre";
$result_SET = $class->ResultSet($query);
$_REQUEST['cmd']=7;
$row_SET = $class->FetchObject($result_SET);
$_REQUEST['pr']=$row_SET->prID;
}
}
}Any help would be awesome!
Thanks,
Aravona