Syntaxe html et php
Résolu
Bonjour,
J'ai fait un code, avec du html dans du php... Lorsque je met le php avant la balise ul tout fonctionne, mais j'ai besoin de mettre mon code à l'intérieur des balise ul , mais j'ai un gros problème de syntaxe
voici mon code
Mais j'ai un soucis au niveau de la syntaxe, j'ai essayé de mettre entre ' ' mes balies HTML mais cela ne fonctionne pas quand même ... Pourriez vous m'expliqer comment je dois faire ?
Merci !
J'ai fait un code, avec du html dans du php... Lorsque je met le php avant la balise ul tout fonctionne, mais j'ai besoin de mettre mon code à l'intérieur des balise ul , mais j'ai un gros problème de syntaxe
voici mon code
<ul>
<?php
$fichier = 'http://wcf.tourinsoft.com/Syndication/cdt65/b1155573-8443-49fb-a3d0-bb05526278e6/Objects?$filter=ListingCOMMUNE eq\'CAPVERN\'';
$dom = new DOMDocument('utf-8');
if (!$dom->load($fichier))
{
die('Impossible de charger le fichier XML');
}
$itemList = $dom->getElementsByTagName('properties');
foreach ($itemList as $item2)
{
$nom = $item2->getElementsByTagName('ListingCOMMUNE');
$nom1 = $nom->item(0)->nodeValue;
$photo = $item2->getElementsByTagName('ListingPHOTOPRINCIPALE');
$photo1 = $photo->item(0)->nodeValue;
$photo1 = str_replace('URL : ', '', $photo1);
$photo1 = str_replace('Libellé :', '', $photo1);
$description = $item2->getElementsByTagName('ListingDESCRIPTIONCOMMERCIALE');
$description1 = $description->item(0)->nodeValue;
$location = $item2->getElementsByTagName('ListingRESERVATION');
$location1 = $location->item(0)->nodeValue;
}
<li class="itmList">
<a href="capvern.php" attr-id="HPAMID065FS0005U">
<div class="placeholder">
echo $photo1;
//echo strlen($photo1);
if(strlen($photo1)==0)
{
$photo1= '<img src="imgreplace.png">';
echo $photo1;
}
</div>
<h2> echo $nom1; </h2>
<p class="description"> echo $description1; </p>
<p class="location">Location : echo $location1; </p>
</a>
</li>
?>
</ul>
Mais j'ai un soucis au niveau de la syntaxe, j'ai essayé de mettre entre ' ' mes balies HTML mais cela ne fonctionne pas quand même ... Pourriez vous m'expliqer comment je dois faire ?
Merci !
2 réponses
-
Salut,
Rajoutes des echo devant tes balises HTML :
Exemple : echo '<li class="itmList">'; -
Quand je met les balises html entre ''
ça donne :
<ul> <?php $fichier = 'http://wcf.tourinsoft.com/Syndication/cdt65/b1155573-8443-49fb-a3d0-bb05526278e6/Objects?$filter=ListingCOMMUNE eq\'CAPVERN\''; $dom = new DOMDocument('utf-8'); if (!$dom->load($fichier)) { die('Impossible de charger le fichier XML'); } $itemList = $dom->getElementsByTagName('properties'); foreach ($itemList as $item2) { $nom = $item2->getElementsByTagName('ListingCOMMUNE'); $nom1 = $nom->item(0)->nodeValue; $photo = $item2->getElementsByTagName('ListingPHOTOPRINCIPALE'); $photo1 = $photo->item(0)->nodeValue; $photo1 = str_replace('URL : ', '', $photo1); $photo1 = str_replace('Libellé :', '', $photo1); $description = $item2->getElementsByTagName('ListingDESCRIPTIONCOMMERCIALE'); $description1 = $description->item(0)->nodeValue; $location = $item2->getElementsByTagName('ListingRESERVATION'); $location1 = $location->item(0)->nodeValue; } '<li class="itmList">' '<a href="capvern.php" >' '<div class="placeholder">' echo $photo1; //echo strlen($photo1); if(strlen($photo1)==0) { $photo1= '<img src="imgreplace.png">'; echo $photo1; } '</div>' '<h2>' echo $nom1; '</h2>' '<p class="description">' echo $description1; '</p>' '<p class="location">'Location : echo $location1; '</p>' '</a>' '</li>' ?> </ul>
Et j'ai ce message d'erreur : Parse error: syntax error, unexpected ''<a href="capvern.php" >'' (T_CONSTANT_ENCAPSED_STRING) in C:\wamp\www\projet_ot\listitemcapvern.php on line 46
Pouvez vous me dire ce que je dois modifier ?
Merci à vous