Oh my...
Here's another snippet from the same intranet, by the same person...
if ($ordre != "" ){
if($customer){
if($cal_date != ""){
$todo = "SELECT * FROM todo WHERE done_todo = 0 AND
id_customer=$customer AND date_end=\"$cal_date\" ORDER BY $ordre";
}else{
$todo = "SELECT * FROM todo WHERE done_todo = 0 AND id_customer=$customer ORDER BY $ordre";
}
}else{
if($cal_date != ""){
$todo = "SELECT * FROM todo WHERE done_todo = 0 AND date_end=\"$cal_date\" ORDER BY $ordre";
}else{
$todo = "SELECT * FROM todo WHERE done_todo = 0 ORDER BY $ordre";
}
}
}
else {
if($customer){
if($cal_date != ""){
$todo = "SELECT * FROM todo WHERE done_todo = 0 AND
id_customer = $customer AND date_end = \"$cal_date\" ORDER BY date_end
ASC";
}else{
$todo = "SELECT * FROM todo WHERE done_todo = 0 AND id_customer = $customer ORDER BY date_end ASC";
}
}else{
if($cal_date != ""){
$todo = "SELECT * FROM todo WHERE done_todo = 0 AND date_end = \"$cal_date\" ORDER BY date_end ASC";
}else{
$todo = "SELECT * FROM todo WHERE done_todo = 0 ORDER BY date_end ASC";
}
}
}
if ($p_do = @mysql_query($todo,$conn)){
// SNIP a lot of things
while ($rs_do = @mysql_fetch_array($p_do)){
// SNIP more things
<?
$SQL_customer = "SELECT * FROM customers WHERE id_customer = $rs_do[id_customer] ";
if ($p_customer = @mysql_query($SQL_customer,$conn)){
$rs_customer = @mysql_fetch_array($p_customer)
?>
<b>
<?= $rs_customer[denomination_customer] ?>
</b><br>
<?= $rs_customer[nom_customer] ?>
<?= $rs_customer[prenom_customer] ?>
<?
}
?>
// .... SNIP yet more stuff
<?
}// end condition loop
} // end loop
} // end condition
?>
WTF ? This intranet is such a mess...
I've just reduced a 200-lines-long piece of shit to a clean and readable file, acomplishing the same task in less than 50... sigh