1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107
| <?php
if(isset($_GET['orderno'])){
$orderno = $_GET['orderno'];
}
$pt_sql = mysql_query("SELECT * FROM orders where orderno='$orderno' ");
if (mysql_num_rows($pt_sql) >0)
{
// recuperation du nombre d'enregistrement
while($pt_get=mysql_fetch_array($pt_sql))
{
$nb_record = $pt_get['numitems'];
$g_orderno = $pt_get['orderno'];
$itemname = $pt_get['itemname'];
$title = preg_split('/\|/', $itemname, -1 , PREG_SPLIT_NO_EMPTY);
// on se sert du nombre d'enregistrement pour traiter les resultats
switch($nb_record){
case ($nb_record == 0) :
// aucun retour
echo 'There are no contracts available for download for your order.';
break;
case ($nb_record == 1) :
// un seul retour
echo "<a href='contract.php?orderno=$g_orderno' target='_blank'><strong>Contract</strong></a> for <i>$title[0]</i>";
break;
case ($nb_record > 1) :
// plusieurs retour
// les enregistrements sont compte a partir de 1, alors q'on a besoin de partir de 0 -> on enleve 1
$nb_record = $nb_record -1;
$title[$i] = str_replace("LEASE for ","", $title[$i]);
$title[$i] = str_replace("TRACK SEPARATION for ","", $title[$i]);
$title[$i] = str_replace("TRACK SEPARATION & RIGHT OF FIRST REFUSAL for ","", $title[$i]);
$title[$i] = str_replace("LIFETIME RIGHT OF FIRST REFUSAL for ","", $title[$i]);
$title[$j] = str_replace("LEASE for ","", $title[$j]);
$title[$j] = str_replace("TRACK SEPARATION for ","", $title[$j]);
$title[$j] = str_replace("TRACK SEPARATION & RIGHT OF FIRST REFUSAL for ","", $title[$j]);
$title[$j] = str_replace("LIFETIME RIGHT OF FIRST REFUSAL for ","", $title[$j]);
// un boucle pour comparer l'enregistrement au precedent
for($i=0; $i < $nb_record; $i++){
if($i > 0){$j = $i -1;
$title[$i] = str_replace("LEASE for ","", $title[$i]);
$title[$i] = str_replace("TRACK SEPARATION for ","", $title[$i]);
$title[$i] = str_replace("TRACK SEPARATION & RIGHT OF FIRST REFUSAL for ","", $title[$i]);
$title[$i] = str_replace("LIFETIME RIGHT OF FIRST REFUSAL for ","", $title[$i]);
$title[$j] = str_replace("LEASE for ","", $title[$j]);
$title[$j] = str_replace("TRACK SEPARATION for ","", $title[$j]);
$title[$j] = str_replace("TRACK SEPARATION & RIGHT OF FIRST REFUSAL for ","", $title[$j]);
$title[$j] = str_replace("LIFETIME RIGHT OF FIRST REFUSAL for ","", $title[$j]);
}else{$j=1;
$title[$i] = str_replace("LEASE for ","", $title[$i]);
$title[$i] = str_replace("TRACK SEPARATION for ","", $title[$i]);
$title[$i] = str_replace("TRACK SEPARATION & RIGHT OF FIRST REFUSAL for ","", $title[$i]);
$title[$i] = str_replace("LIFETIME RIGHT OF FIRST REFUSAL for ","", $title[$i]);
$title[$j] = str_replace("LEASE for ","", $title[$j]);
$title[$j] = str_replace("TRACK SEPARATION for ","", $title[$j]);
$title[$j] = str_replace("TRACK SEPARATION & RIGHT OF FIRST REFUSAL for ","", $title[$j]);
$title[$j] = str_replace("LIFETIME RIGHT OF FIRST REFUSAL for ","", $title[$j]);
} // <-- un oubli
if ( $title[$i] == $title[$j] ) {
echo "<a href='contract.php?orderno=".$g_orderno."' target='_blank'><strong>Contract</strong></a> for <i>".$title[$i]."</i>";
} else {
echo "<a href='contract".$i.".php?orderno=".$g_orderno."' target='_blank'><strong>Contract</strong></a> for <i>".$title[$i]."</i><br /><br />";
echo "<a href='contract".$j.".php?orderno=".$g_orderno."' target='_blank'><strong>Contract</strong></a> for <i>".$title[$j]."</i><br />";
}break;
}
}
/*
if ( $title[1] == "" ) {
echo "<a href='contract.php?orderno=$g_orderno' target='_blank'><strong>Contract</strong></a> for <i>$title[0]</i>";
} elseif ( $title[0] == $title[1] ) {
echo "<a href='contract.php?orderno=$g_orderno' target='_blank'><strong>Contract</strong></a> for <i>$title[0]</i>";
} else {
echo "<a href='contract.php?orderno=$g_orderno' target='_blank'><strong>Contract</strong></a> for <i>$title[0]</i><br /><br />";
echo "<a href='contract2.php?orderno=$g_orderno' target='_blank'><strong>Contract</strong></a> for <i>$title[1]</i>";
}
*/
}
//cas où il ya des résultats : traitement
} else {
echo 'There are no contracts available for download for your order.';
}
mysql_close();
?> |
Partager