test sur une image(fonction)

x@v
Mammouth du PHP | 570 Messages

31 mars 2007, 06:22

Bonjour,
j'ai une fonction qui m'affiche une table, l'ennui c'est que les lignes qui sont vide m'affiche une le cadre de l'image absente et donc je cherche l'astuce pour ne pas afficher l'image absente si il n'y a rien dans la ligne demander.
http://88.167.164.83/jean-paul/index_xajax.php
function produitvu() {
  $reponse = new xajaxResponse();
  $req="SELECT DISTINCT rubrique FROM pages";
  $query = mysql_query($req);
  $txt = '';
  $txt.='<table id="diaporama">';
  $i=0;
  while($tb = mysql_fetch_assoc($query)){
  if($i%9 == 0)  $txt .= '<tr>';
  $txt .= '<td>';
  $txt .= '<a href="javascript:void(0);" OnClick="xajax_detailvu(\'' . $tb['rubrique'] . '\');">';
  $txt .= '<img src="./conte/'.$tb['rubrique'].'.png" alt="'.$tb['rubrique'].'" style="width:81px;height:64px;border:1px solid black;" onMouseOver="diaporama_bigimg('.($i+1).')" id="diaporama_img_'.($i+1).'" /><br />';
  $txt .='<span id="menu_carte">';
  $txt .= $tb['rubrique'] . '</span></a>';
  $txt .= '</td>';
  if(($i+1%9) == 0)  $txt .= '</tr>';
  $i++;
  }
  $txt .= '</table>';
  $reponse->addAssign("menu_conte", "innerHTML", $txt);
  $reponse->addScriptCall("xajax_date_local");
  $reponse->addScriptCall("xajax_insertion_stat");
  $reponse->addScriptCall("xajax_pied_page");
  return $reponse->getXML();
}
j'ai essayer avec un test sans succès ?
  if (isset($tb['rubrique'])) {
  $txt .= '<img src="./conte/'.$tb['rubrique'].'.png" alt="'.$tb['rubrique'].'" style="width:81px;height:64px;border:1px solid black;" onMouseOver="diaporama_bigimg('.($i+1).')" id="diaporama_img_'.($i+1).'" /><br />';
  $txt .='<span id="menu_carte">';
  $txt .= $tb['rubrique'] . '</span></a>';
  }
Merci

Eléphant du PHP | 170 Messages

31 mars 2007, 08:06

Hip,

EDIT, j'ai rien dit j'ai lu en diagonale !
Modifié en dernier par Expreg le 31 mars 2007, 10:10, modifié 1 fois.
Benjamin Franklin a dit :
Tu me dis, j'oublie. Tu m'enseignes, je me souviens. Tu m'impliques, j'apprends

Invité
Invité n'ayant pas de compte PHPfrance

31 mars 2007, 10:02

Moi a ce que j'ai compris, essaie un truc comme sa :
if(is_file('ton image')) echo '<img src="ton img" border="0" />';
else echo 'Pas d image disponible';

x@v
Mammouth du PHP | 570 Messages

01 avr. 2007, 04:31

j'ai fait autrment, le chemin dans la un champs de ma table, merci