Affichage de logement php

Résolu/Fermé
gmartine - 4 juin 2010 à 14:35
louloute300 Messages postés 335 Date d'inscription jeudi 3 juin 2010 Statut Membre Dernière intervention 28 novembre 2012 - 4 juin 2010 à 15:12
Bonjour,

voilà j'ai un problème j'ai réussi à afficher un logement à la fois en version imprimable grace a ce code :

mais j'aimerai pouvoir afficher tout les logements à la suite en version imprimable
pour éviter d'imprimer 1 par 1 les logements.

Merci de bien vouloir m'aider.



<?php

require_once("file_header.php");



if(isset($_GET["loge"])){

$num=$_GET["loge"];

}

if(isset($_GET["num"])){

$num=$_GET["num"];

}



//$print=$_GET["print"];

//$db = connection();

?>



<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link rel="stylesheet" href="../css/alescimp.css" type="text/css">

</head>



<title>Logement numéro : <?php echo $num; ?> -- ALESC</title>



<script>window.moveTo(0,0);</script>



<body bgcolor="#FFFFFF" text="#000000">

<?php

$num_ex = explode(";", $num);



for($i=0;$i<count($num_ex);$i++){



$num=$num_ex[$i];



$res =mysql_query("SELECT * FROM logement l, logeur lo, type_logement t, sanitaire_logement sl, repas_logement rl, distance_pied dp, distance_voiture dv, ville v

		WHERE l.l_id=".$num."

 		AND l.l_lg_id=lo.lg_id

		AND l.l_t_id=t.t_l_id

		AND l.l_sanitaires=sl.s_id

		AND l.l_r_id=rl.r_id

		AND l.l_d_p_id=dp.d_p_id

		AND l.l_d_v_id =dv.d_v_id

		AND l.l_v_id=v.v_id");

//$res = requete($db, $sql);



$val = valeur($res);



$aryMois = array(1 => "Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre");//<



echo"

<table width=\"100%\">

	<tr style=\"page-break-after: always;\">

		<td>";



AfficheTitre("&nbsp;Logements N° ".$num."&nbsp;");



?>

<br>



			<table width="100%"  border="0" cellspacing="5" cellpadding="0" align="center">

				<tr>

					<td>

						<table border="0" width="100%" cellspacing="5" cellpadding="0" align="center">

							<tr>

								<td align="right">Type : </td><td><?php echo $val["t_l_nom"];?></td>

    							<td  align="right">Superficie : </td>

								<td> 

      <?php echo $val["l_superficie"];?>

      M²					</td>

  							</tr>

  							<tr>

								<td colspan="4" >&nbsp;</td>

							</tr>

							<tr>

								<td align="right">Date de disponibilité : </td><td><?php $temp = explode("-",$val["l_date_dispo"]); echo $temp[2]." ".$aryMois[intval($temp[1])]." ".$temp[0]; ?>&nbsp;&nbsp;&nbsp;&nbsp;</td>

    							<!--<td  align="right">Indépendant : </td> -

								<td>

      <input type="checkbox" <?php //if($val["l_independant"]==1) {echo "CHECKED";}?>> -->

          						</td>

							</tr>

        					<tr>

								<td colspan="4" >&nbsp;</td>



  							</tr>

						</table>

					</td>

					<td valign="middle" align="center"><?php switch($val["l_qualite"]) {case 1:?><img src="../images/qualite1.jpg"><?php break;case 2:?><img src="../images/qualite2.jpg"><?php break; case 3:?><img src="../images/qualite3.jpg"><?php break;}?><br><div alogn="left"><b><?php if($val["l_qualite"]>=2) {echo $val["l_annee_qualite"];}?></b></div></td>

				</tr>

			</table><hr>

			<table width="80%" border="0" cellspacing="0" cellpadding="0" align="center">

  				<tr> 

    				<td valign="top" width="15%"><b> 

      <h2>Localisation : </h2>

      </b>			</td>

    				<td valign="top" width="15%">&nbsp;</td>

    				<td colspan="2"> 

      <?php echo $val["num_appart"];?>

	  <br>

	  <?php echo str_replace("\\", "", $val["l_adresse1"]);?>

      <br>

      <?php echo str_replace("\\", "", $val["l_adresse2"]);?>

    				</td>

  				</tr>

  				<tr> 

    				<td  colspan="4">&nbsp;</td>

  				</tr>

  				<tr> 

    				<td colspan="2" align="right"  >&nbsp;</td>

    				<td> 

      <?php echo $val["l_cp"];?>

      &nbsp;&nbsp; 

      <?php echo str_replace("\\", "", $val["v_nom"]);?>

    				</td>

    				<td>Plan : 

      <?php echo $val["l_plan"];?>

    				</td>

  				</tr>

  				<tr> 

    				<td colspan="4">La localisation est calculée depuis Benjamin Franklin</td>

  				</tr>

  				<tr> 

    				<td colspan="3" align="left"  >Temps à Pied : &nbsp; 

      <?php echo str_replace("\\", "", $val["d_p_nom"]);?>

    				</td>

    				<td>Distance km : 

      <?php echo str_replace("\\", "", $val["d_v_nom"]);?>

    				</td>

    				<td>&nbsp;</td>

  				</tr>

			</table>

<br>

<hr>

			<table width="80%" cellspacing="0" cellpadding="0" border="0" align="center">

  				<tr> 

    				<td colspan="7"><b> 

      <h2>Elements Descriptifs</h2>

      </b>			</td>

  				</tr>

  				<tr> 

    				<td align="right" colspan="2">Meublé : </td>

    				<td width="9%">&nbsp; 

      <input type="checkbox" <?php if($val["l_meubles"]==1) {echo "CHECKED";}?>>

    				</td>

    				<td align="right" width="6%">&nbsp;</td>

    				<td width="14%">&nbsp; 

      <input type="hidden" <?php if($val["l_fumeur"]==1) {echo "CHECKED";}?>>

    				</td>

    				<td align="right" width="11%">Sanitaires : </td>

    				<td width="27%">&nbsp; 

      <?php echo str_replace("\\", "", $val["s_nom"]);?>

    				</td>

 				</tr>

  				<tr> 

    				<td align="right" colspan="2">&nbsp;</td>

    				<td width="9%">&nbsp; 

      <input type="hidden" <?php if($val["l_sex_garcon"]==1) {echo "CHECKED";}?>>

    				</td>

    				<td align="right" width="6%">&nbsp;</td>

    				<td width="14%">&nbsp; 

      <input type="hidden" <?php if($val["l_sexe"]==1) {echo "CHECKED";}?>>

    				</td>

    				<td align="right" width="11%">Cuisine : </td>

    				<td width="27%">&nbsp; 

      <?php echo $val["r_nom"];?>

    				</td>

  				</tr>

  				<tr> 

    				<td align="right" colspan="5">&nbsp;</td>

  				</tr>

  				<tr> 

    				<td valign="top" width="14%" align="left">Commentaires : </td>

    				<td valign="top" colspan="6"> 

      <?php echo str_replace("\\", "", $val["l_commentaire"]); ?>

      <br>

    				</td>

  				</tr>

  				<tr> 

    				<td align="left" width="14%">&nbsp;</td>

    				<td align="left" width="19%">&nbsp;</td>

    				<td align="left" width="9%">&nbsp;</td>

    				<td align="left" width="6%">&nbsp;</td>

    				<td align="left" width="14%">&nbsp;</td>

  				</tr>

  				<tr> 

    				<td valign="top" width="14%" align="left">Commentaires privés : </td>

    				<td valign="top" colspan="6">

      <?php echo str_replace("\\", "", $val["l_commentaires_prives"]); ?>

      <br>

    				</td>

  				</tr>

			</table>

<br><hr>

			<table width="80%" cellspacing="0" cellpadding="0" border="0" align="center">

  				<tr>

					<td colspan="4"><b><h2>Conditions Financières</h2></b></td>

				</tr>

				<tr>

					<td align="right">Loyer : </td>

					<td>&nbsp;<?php echo str_replace(".",",",$val["l_loyer"]); ?> €</td>

					<!--<td align="right">Durée Minimale du bail : </td>

					<td>&nbsp;<?php //echo $val["l_duree_bail"]; ?></td>-->

				</tr>

				<tr>

					<td align="right">Charges : </td>

					<td>&nbsp;<?php echo str_replace(".",",",$val["l_charges"]); ?> €</td>

					<td align="right">Dépôt de garantie : </td>

					<td>

      &nbsp;<?php echo str_replace(".",",",$val["l_caution"]);?>

    				</td>

				</tr>

			</table><hr><br>

			<table width="80%" cellspacing="0" cellpadding="0" border="0" align="center">

  				<tr> 

    				<td colspan="4"><b><h2>Personne à Contacter</h2></b></td>

  				</tr>

  				<tr> 

    				<td rowspan="3">Nom du logeur : <?php echo ucwords($val["lg_nom"])."  ".ucwords($val["lg_prenom"]);?></td>

    				<td align="right">Tél Professionnel : </td>

    				<td>&nbsp;<?php echo $val["lg_tel_pro"]; ?></td>

  				</tr>

  				<tr> 

    				<td align="right">Tél Domicile : </td>

    				<td>&nbsp;<?php echo $val["lg_tel_dom"]; ?></td>

  				</tr>

  				<tr> 

    				<td align="right">Tél Portable : </td>

    				<td>&nbsp;<?php echo $val["lg_tel_port"]; ?></td>

  				</tr>

			</table><hr><br>

			<table width="80%" cellspacing="0" cellpadding="0" border="0" align="center">

<?php $val_max=250;//<img src="../images/spacer.gif" height=" echo $val_max;  " width="1"> ?>

				<tr>

					<td width="1">&nbsp;</td>



					<td align="center">
<?php

if(isset($_GET["printphoto"]))
	$printphoto = $_GET["printphoto"];
else
	$printphoto="";

if($printphoto!=""){ 
	//display photos
	$query = mysql_query("SELECT * from photo p, type_photo tp where p.p_t_p_id=tp.t_p_id AND p_l_id=$num");
	if(mysql_num_rows($query) > 0){
		$i = 0;
		
		echo '<table width="80%" cellspacing="0" cellpadding="0" border="0" align="center">';
		
		while($result = mysql_fetch_array($query)){
								
			if($i%2 == 0){
				echo '<tr>';			
				echo '<td width="1"><img src="images/spacer.gif" height="250" width="1"></td>';
			}
			
			echo '<td align="center">';
			echo '<img src="../images/logements/'.$num.'/'.$result["p_chemin"].'" >';
			echo '<br><br>';
			echo '</td>';
			
			if($i%2 != 0)
				echo '</tr>';
				
			$i++;	
		} 
		echo '</table>';
	}
}

if(isset($_GET["print"]))
  $print=$_GET["print"];
else
	$print="";
	
if($print!="y") 
 	echo '<center><input type="submit" value="Fermer" onClick="window.close();"></center>';


if($print=="y")
	echo '<script>print();</script>'; 

echo "</td></tr></table>";

//WTF??
}
?>
</body>
</html>








A voir également:

1 réponse

louloute300 Messages postés 335 Date d'inscription jeudi 3 juin 2010 Statut Membre Dernière intervention 28 novembre 2012 29
4 juin 2010 à 15:12
Il y a juste à rajouter une boucle à mon avis:

<?php

require_once("file_header.php");



if(isset($_GET["loge"])){

$num=$_GET["loge"];

}

if(isset($_GET["num"])){

$num=$_GET["num"];

}



//$print=$_GET["print"];

//$db = connection();

?>



<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<link rel="stylesheet" href="../css/alescimp.css" type="text/css">

</head>



<title>Logement numéro : <?php echo $num; ?> -- ALESC</title>



<script>window.moveTo(0,0);</script>



<body bgcolor="#FFFFFF" text="#000000">

<?php

$num_ex = explode(";", $num);



for($i=0;$i<count($num_ex);$i++){



$num=$num_ex[$i];



$res =mysql_query("SELECT * FROM logement l, logeur lo, type_logement t, sanitaire_logement sl, repas_logement rl, distance_pied dp, distance_voiture dv, ville v

WHERE l.l_id=".$num."

AND l.l_lg_id=lo.lg_id

AND l.l_t_id=t.t_l_id

AND l.l_sanitaires=sl.s_id

AND l.l_r_id=rl.r_id

AND l.l_d_p_id=dp.d_p_id

AND l.l_d_v_id =dv.d_v_id

AND l.l_v_id=v.v_id");

//$res = requete($db, $sql);


for($i=0;$i<mysql_num_rows($res);$i++){

$val = mysql_fetch_array($res);



$aryMois = array(1 => "Janvier","Février","Mars","Avril","Mai","Juin","Juillet","Août","Septembre","Octobre","Novembre","Décembre");//<



echo"

<table width=\"100%\">

<tr style=\"page-break-after: always;\">

<td>";



AfficheTitre(" Logements N° ".$num." ");



?>

<br>



<table width="100%" border="0" cellspacing="5" cellpadding="0" align="center">

<tr>

<td>

<table border="0" width="100%" cellspacing="5" cellpadding="0" align="center">

<tr>

<td align="right">Type : </td><td><?php echo $val["t_l_nom"];?></td>

<td align="right">Superficie : </td>

<td>

<?php echo $val["l_superficie"];?>

M² </td>

</tr>

<tr>

<td colspan="4" > </td>

</tr>

<tr>

<td align="right">Date de disponibilité : </td><td><?php $temp = explode("-",$val["l_date_dispo"]); echo $temp[2]." ".$aryMois[intval($temp[1])]." ".$temp[0]; ?>    </td>

<!--<td align="right">Indépendant : </td> -

<td>

<input type="checkbox" <?php //if($val["l_independant"]==1) {echo "CHECKED";}?>> -->

</td>

</tr>

<tr>

<td colspan="4" > </td>



</tr>

</table>

</td>

<td valign="middle" align="center"><?php switch($val["l_qualite"]) {case 1:?><img src="../images/qualite1.jpg"><?php break;case 2:?><img src="../images/qualite2.jpg"><?php break; case 3:?><img src="../images/qualite3.jpg"><?php break;}?><br><div alogn="left"><b><?php if($val["l_qualite"]>=2) {echo $val["l_annee_qualite"];}?></b></div></td>

</tr>

</table><hr>

<table width="80%" border="0" cellspacing="0" cellpadding="0" align="center">

<tr>

<td valign="top" width="15%"><b>

<h2>Localisation : </h2>

</b> </td>

<td valign="top" width="15%"> </td>

<td colspan="2">

<?php echo $val["num_appart"];?>

<br>

<?php echo str_replace("\\", "", $val["l_adresse1"]);?>

<br>

<?php echo str_replace("\\", "", $val["l_adresse2"]);?>

</td>

</tr>

<tr>

<td colspan="4"> </td>

</tr>

<tr>

<td colspan="2" align="right" > </td>

<td>

<?php echo $val["l_cp"];?>

  

<?php echo str_replace("\\", "", $val["v_nom"]);?>

</td>

<td>Plan :

<?php echo $val["l_plan"];?>

</td>

</tr>

<tr>

<td colspan="4">La localisation est calculée depuis Benjamin Franklin</td>

</tr>

<tr>

<td colspan="3" align="left" >Temps à Pied :  

<?php echo str_replace("\\", "", $val["d_p_nom"]);?>

</td>

<td>Distance km :

<?php echo str_replace("\\", "", $val["d_v_nom"]);?>

</td>

<td> </td>

</tr>

</table>

<br>

<hr>

<table width="80%" cellspacing="0" cellpadding="0" border="0" align="center">

<tr>

<td colspan="7"><b>

<h2>Elements Descriptifs</h2>

</b> </td>

</tr>

<tr>

<td align="right" colspan="2">Meublé : </td>

<td width="9%"> 

<input type="checkbox" <?php if($val["l_meubles"]==1) {echo "CHECKED";}?>>

</td>

<td align="right" width="6%"> </td>

<td width="14%"> 

<input type="hidden" <?php if($val["l_fumeur"]==1) {echo "CHECKED";}?>>

</td>

<td align="right" width="11%">Sanitaires : </td>

<td width="27%"> 

<?php echo str_replace("\\", "", $val["s_nom"]);?>

</td>

</tr>

<tr>

<td align="right" colspan="2"> </td>

<td width="9%"> 

<input type="hidden" <?php if($val["l_sex_garcon"]==1) {echo "CHECKED";}?>>

</td>

<td align="right" width="6%"> </td>

<td width="14%"> 

<input type="hidden" <?php if($val["l_sexe"]==1) {echo "CHECKED";}?>>

</td>

<td align="right" width="11%">Cuisine : </td>

<td width="27%"> 

<?php echo $val["r_nom"];?>

</td>

</tr>

<tr>

<td align="right" colspan="5"> </td>

</tr>

<tr>

<td valign="top" width="14%" align="left">Commentaires : </td>

<td valign="top" colspan="6">

<?php echo str_replace("\\", "", $val["l_commentaire"]); ?>

<br>

</td>

</tr>

<tr>

<td align="left" width="14%"> </td>

<td align="left" width="19%"> </td>

<td align="left" width="9%"> </td>

<td align="left" width="6%"> </td>

<td align="left" width="14%"> </td>

</tr>

<tr>

<td valign="top" width="14%" align="left">Commentaires privés : </td>

<td valign="top" colspan="6">

<?php echo str_replace("\\", "", $val["l_commentaires_prives"]); ?>

<br>

</td>

</tr>

</table>

<br><hr>

<table width="80%" cellspacing="0" cellpadding="0" border="0" align="center">

<tr>

<td colspan="4"><b><h2>Conditions Financières</h2></b></td>

</tr>

<tr>

<td align="right">Loyer : </td>

<td> <?php echo str_replace(".",",",$val["l_loyer"]); ?> €</td>

<!--<td align="right">Durée Minimale du bail : </td>

<td> <?php //echo $val["l_duree_bail"]; ?></td>-->

</tr>

<tr>

<td align="right">Charges : </td>

<td> <?php echo str_replace(".",",",$val["l_charges"]); ?> €</td>

<td align="right">Dépôt de garantie : </td>

<td>

 <?php echo str_replace(".",",",$val["l_caution"]);?>

</td>

</tr>

</table><hr><br>

<table width="80%" cellspacing="0" cellpadding="0" border="0" align="center">

<tr>

<td colspan="4"><b><h2>Personne à Contacter</h2></b></td>

</tr>

<tr>

<td rowspan="3">Nom du logeur : <?php echo ucwords($val["lg_nom"])." ".ucwords($val["lg_prenom"]);?></td>

<td align="right">Tél Professionnel : </td>

<td> <?php echo $val["lg_tel_pro"]; ?></td>

</tr>

<tr>

<td align="right">Tél Domicile : </td>

<td> <?php echo $val["lg_tel_dom"]; ?></td>

</tr>

<tr>

<td align="right">Tél Portable : </td>

<td> <?php echo $val["lg_tel_port"]; ?></td>

</tr>

</table><hr><br>

<table width="80%" cellspacing="0" cellpadding="0" border="0" align="center">

<?php $val_max=250;//<img src="../images/spacer.gif" height=" echo $val_max; " width="1"> ?>

<tr>

<td width="1"> </td>



<td align="center">
<?php

if(isset($_GET["printphoto"]))
$printphoto = $_GET["printphoto"];
else
$printphoto="";

if($printphoto!=""){
//display photos
$query = mysql_query("SELECT * from photo p, type_photo tp where p.p_t_p_id=tp.t_p_id AND p_l_id=$num");
if(mysql_num_rows($query) > 0){
$i = 0;

echo '<table width="80%" cellspacing="0" cellpadding="0" border="0" align="center">';

while($result = mysql_fetch_array($query)){

if($i%2 == 0){
echo '<tr>';
echo '<td width="1"><img src="images/spacer.gif" height="250" width="1"></td>';
}

echo '<td align="center">';
echo '<img src="../images/logements/'.$num.'/'.$result["p_chemin"].'" >';
echo '<br><br>';
echo '</td>';

if($i%2 != 0)
echo '</tr>';

$i++;
}
echo '</table>';
}
}



if(isset($_GET["print"]))
$print=$_GET["print"];
else
$print="";

if($print!="y")
echo '<center><input type="submit" value="Fermer" onClick="window.close();"></center>';


if($print=="y")
echo '<script>print();</script>';

echo "</td></tr></table>";
}
//WTF??
}
?>
</body>
</html>






Les lignes rajoutés:

for($i=0;$i<mysql_num_rows($res);$i++){

$val = mysql_fetch_array($res);

+ un } en fin de fichier...
0