0

I have simple php code here, where basically asking to display the value of query :

<?php
$table = "tbl_product";

/******************MULTIPLE QUERIES*******************/
 if($tbl_code==999){$condition = " WHERE (category = 'wellington') OR (category = 'hivis') OR (category = 'tools') OR (category = 'waterproof') ";}

else if($tbl_code==998){$condition = "  WHERE category = 'wellington' ";}
else if($tbl_code==997){$condition = "  WHERE category = 'hivis' ";}
else if($tbl_code==996){$condition = "  WHERE category = 'waterproof' ";}

else if($tbl_code==995){$condition = "  WHERE category = 'wellington' AND sub_category = 'women' ";}
else if($tbl_code==994){$condition = "  WHERE category = 'wellington' AND sub_category = 'cammo' ";}
else if($tbl_code==993){$condition = "  WHERE category = 'wellington' AND (sub_category = 'boy' OR sub_category = 'girl') ";}
else if($tbl_code==992){$condition = "  WHERE category = 'wellington' AND (sub_category = 'brandedmen' OR sub_category = 'brandedwomen') ";}
else if($tbl_code==991){$condition = "  WHERE category = 'wellington' AND sub_category = 'mens' ";}
else if($tbl_code==990){$condition = "  WHERE category = 'tools' AND sub_category = 'bags' ";}
else if($tbl_code==989){$condition = "  WHERE category = 'hivis' AND sub_category = 'men' ";}
else if($tbl_code==988){$condition = "  WHERE category = 'hivis' AND sub_category = 'women' ";}
else if($tbl_code==987){$condition = "  WHERE category = 'hivis' AND sub_category = 'kids' ";}
else if($tbl_code==986){$condition = "  WHERE category = 'waterproof' AND sub_category = 'men' ";}
else if($tbl_code==985){$condition = "  WHERE category = 'waterproof' AND sub_category = 'women' ";}
else if($tbl_code==984){$condition = "  WHERE category = 'waterproof' AND sub_category = 'kids' ";}

else if($tbl_code==983){$condition = "  WHERE category = 'hivis' AND sub_category = 'kids' ";}//new arrivals
else if($tbl_code==982){$condition = "  WHERE category = 'hivis' AND sub_category = 'kids' ";}//wholesale
else if($tbl_code==981){$condition = "  WHERE category = 'hivis' AND sub_category = 'kids' ";}//quickshipping
else if($tbl_code==980){$condition = "  WHERE category = 'hivis' AND sub_category = 'kids' ";}//with defect

else if($tbl_code==979){$condition = "  WHERE category = 'hivis' AND sub_category = 'kids' ";}
else if($tbl_code==978){$condition = "  WHERE category = 'hivis' AND sub_category = 'kids' ";}
else if($tbl_code==977){$condition = "  WHERE category = 'hivis' AND sub_category = 'kids' ";}
else if($tbl_code==976){$condition = "  WHERE category = 'hivis' AND sub_category = 'kids' ";}

else if($tbl_code==975){$condition = "  WHERE category = 'hivis' ";}
else if($tbl_code==974){$condition = "  WHERE category = 'wellington' AND (sub_category = 'cammo' OR sub_category = 'mens') ";}

else{ echo'<script>location.reload();</script>';}

?>

at first it works really great but when I'd tried to test every condition, It will send me on 404 error page. please check my code if I did a BAD programming here ! thnx =)

3
Contributors
4
Replies
21
Views
2 Years
Discussion Span
Last Post by markii.borabon_1
0

How does a query not working send you to a 404 (page not found) error?
Is the result being used to create a URL?
An incorrect SQl statement should generate a PHP error for you to view. Do you have display_errors on?

1

that is pretty nested. Try using switch statement.You can refactor the $tbl_code==976 to 983 as one query using PHP range function e.g. range(976,983).

range will give you an array. So, it would be nice if you can create a simple function to find out if the $tbl_code is in array to trigger the query.

0

yeah, yes sir it is used to create a url. i also have this code to force php to show if i have any error.

error_reporting(E_ALL);
ini_set('display_errors','1');

but suddenly it shows nothing, than sending me into 404 page..

0
veedeoo :
        the condition from 983 - 976 is just like a dummy, so far i prefer to use the same query just to know if the condition is working. and they really do.

  im sure that this is not the reason why query is sending me to 404 page, just because i have used to same query? or maybe i was wrong,



          what im trying to look is the $_SESSION. i know how to use session but not that deep. could you please tell me how sessions work. 





I end up hanging here -_-
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.