Html dans code php..
Résolu
Philzik
Messages postés
6
Date d'inscription
Statut
Membre
Dernière intervention
-
Philzik Messages postés 6 Date d'inscription Statut Membre Dernière intervention -
Philzik Messages postés 6 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
J'ai un petit pb qui va surement vous sauter au yeux de tout le monde
j'aimerai utiliser la fonction If pour écrire un code html
J'aimerai que si la variable vloic et null le code s'affiche et si elle n'est pas null ecrir cette valeur.
<td width="86">
<?php
if ($row->vloic="")
{
echo "<input type="radio" name="vloic" id="radio" value="1" />";
echo "O";
echo "<input type="radio" name="vloic" id="radio2" value="0" />";
echo "N";
}
else
{
echo $row->vloic;
}
?>
</td>
Je ne sais pas bien l'écrire .
Merci d'avance pour le temps que vous me consacré
Bien cordialement
Philippe
J'ai un petit pb qui va surement vous sauter au yeux de tout le monde
j'aimerai utiliser la fonction If pour écrire un code html
J'aimerai que si la variable vloic et null le code s'affiche et si elle n'est pas null ecrir cette valeur.
<td width="86">
<?php
if ($row->vloic="")
{
echo "<input type="radio" name="vloic" id="radio" value="1" />";
echo "O";
echo "<input type="radio" name="vloic" id="radio2" value="0" />";
echo "N";
}
else
{
echo $row->vloic;
}
?>
</td>
Je ne sais pas bien l'écrire .
Merci d'avance pour le temps que vous me consacré
Bien cordialement
Philippe
A voir également:
- Html dans code php..
- Code ascii - Guide
- Code puk bloqué - Guide
- Comment déverrouiller un téléphone quand on a oublié le code - Guide
- Code activation windows 10 - Guide
- Editeur html - Télécharger - HTML
3 réponses
Bonjour
Il faut aussi échapper les " à l'intérieur des chaînes, sinon ils sont pris pour des fins de chaîne :
Il faut aussi échapper les " à l'intérieur des chaînes, sinon ils sont pris pour des fins de chaîne :
echo "<input type=\"radio\" name=\"vloic\" id=\"radio\" value=\"1\" />"; echo "<input type=\"radio\" name=\"vloic\" id=\"radio2\" value=\"0\" />";
develweb
Messages postés
9
Date d'inscription
Statut
Membre
Dernière intervention
1
oui :) ou les remplacer par de simple quote '
bonjour,
peut être manquerai t'il un '=' ici:
if ($row->vloic=="")
sinon essaie avec des print à la place de echo.
bonne journée
peut être manquerai t'il un '=' ici:
if ($row->vloic=="")
sinon essaie avec des print à la place de echo.
bonne journée
Bonjour,
Merci de votre aide le code Html s'affiche bien mais si la valeur et différente de null le Else n'apparait pas :s
Savez - vous d'où cella peu venir?
je vous met le code complet:
<?php
include("../connection.php");
$idcat=$_GET["idcat"];
$requete="select * from t_morceau where propo=$idcat";
$result=mysql_query($requete);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Villa Romée</title>
<link href="../mavr.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
background-color: #333333;
}
-->
</style></Head>
<table width="1000">
<tr>
<td width="30">id</td>
<td width="42">Propo </td>
<td width="160">Artiste</td>
<td width="192">Titre</td>
<td width="87">Lien Youtube</td>
<td width="86">Loic</td>
<td width="84">Fred</td>
<td width="78">Harley</td>
<td width="77">Phil</td>
<td width="120"> </td>
</tr>
<?php while($row=mysql_fetch_object($result))
{
?><form action="formvote.php?id=$id" method="post" name="form<?php echo $row->id; ?>" target="_blank" id="form<?php echo $row->id; ?>">
<tr>
<td width="30"><input name="id" type="text" id="id" value="<?php echo $row->id; ?>" size="5" /></td>
<td width="42"><?php echo $row->par; ?></td>
<td><?php echo $row->artiste; ?></td>
<td><?php echo $row->titre; ?></td>
<td><a href="<?php echo $row->lien; ?>" target="_blank">Musique</a></td>
<td width="86">
<?php
if ($row->vloic="")
{
echo "<input type=\"radio\" name=\"vloic\" id=\"radio\" value=\"1\" />";
echo "O";
echo "<input type=\"radio\" name=\"vloic\" id=\"radio2\" value=\"0\" />";
echo "N";
}
else
{
echo $row->vloic;
}
?>
</td>
<td width="84"><input type="radio" name="vfred" id="radio3" value="1" />
O
<input type="radio" name="vfred" id="radio4" value="0" />
N</td>
<td width="78"><input type="radio" name="vharley" id="radio5" value="1" />
O
<input type="radio" name="vharley" id="radio6" value="0" />
N</td>
<td width="77"><input type="radio" name="vphil" id="radio7" value="1" />
O
<input type="radio" name="vphil" id="radio8" value="0" />
N</td>
<td><input type="submit" name="button" id="button" value="Envoyer" /></td>
</tr>
</form>
<?php
} ?>
</table>
<table background="../index/images/degradevv.jpg" b width="620" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>
D'avance merci
Cordialement
Philippe
Merci de votre aide le code Html s'affiche bien mais si la valeur et différente de null le Else n'apparait pas :s
Savez - vous d'où cella peu venir?
je vous met le code complet:
<?php
include("../connection.php");
$idcat=$_GET["idcat"];
$requete="select * from t_morceau where propo=$idcat";
$result=mysql_query($requete);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Villa Romée</title>
<link href="../mavr.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
body {
background-color: #333333;
}
-->
</style></Head>
<table width="1000">
<tr>
<td width="30">id</td>
<td width="42">Propo </td>
<td width="160">Artiste</td>
<td width="192">Titre</td>
<td width="87">Lien Youtube</td>
<td width="86">Loic</td>
<td width="84">Fred</td>
<td width="78">Harley</td>
<td width="77">Phil</td>
<td width="120"> </td>
</tr>
<?php while($row=mysql_fetch_object($result))
{
?><form action="formvote.php?id=$id" method="post" name="form<?php echo $row->id; ?>" target="_blank" id="form<?php echo $row->id; ?>">
<tr>
<td width="30"><input name="id" type="text" id="id" value="<?php echo $row->id; ?>" size="5" /></td>
<td width="42"><?php echo $row->par; ?></td>
<td><?php echo $row->artiste; ?></td>
<td><?php echo $row->titre; ?></td>
<td><a href="<?php echo $row->lien; ?>" target="_blank">Musique</a></td>
<td width="86">
<?php
if ($row->vloic="")
{
echo "<input type=\"radio\" name=\"vloic\" id=\"radio\" value=\"1\" />";
echo "O";
echo "<input type=\"radio\" name=\"vloic\" id=\"radio2\" value=\"0\" />";
echo "N";
}
else
{
echo $row->vloic;
}
?>
</td>
<td width="84"><input type="radio" name="vfred" id="radio3" value="1" />
O
<input type="radio" name="vfred" id="radio4" value="0" />
N</td>
<td width="78"><input type="radio" name="vharley" id="radio5" value="1" />
O
<input type="radio" name="vharley" id="radio6" value="0" />
N</td>
<td width="77"><input type="radio" name="vphil" id="radio7" value="1" />
O
<input type="radio" name="vphil" id="radio8" value="0" />
N</td>
<td><input type="submit" name="button" id="button" value="Envoyer" /></td>
</tr>
</form>
<?php
} ?>
</table>
<table background="../index/images/degradevv.jpg" b width="620" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td></td>
</tr>
</table>
D'avance merci
Cordialement
Philippe
Ça c'est résolu, maintenant si vous avez le temps bien sur , je voudrais faire un If a 3 variable :
if ($loic=="")
{
echo $loic;
echo "<input type=\"radio\" name=\"vloic\" id=\"radio\" value=\"Oui\" />";
echo "O";
echo "<input type=\"radio\" name=\"vloic\" id=\"radio2\" value=\"Non\" />";
echo "N";
}
if ($loic=="Oui")
{
echo $loic;
echo "<input type=\"radio\" name=\"vloic\" id=\"radio\" value=\"Oui\" checked=\"checked\" />";
echo "O";
echo "<input type=\"radio\" name=\"vloic\" id=\"radio2\" value=\"Non\" />";
echo "N";
}
if ($loic=="Non")
{
echo $loic;
echo "<input type=\"radio\" name=\"vloic\" id=\"radio\" value=\"Oui\" />";
echo "O";
echo "<input type=\"radio\" name=\"vloic\" id=\"radio2\" value=\"Non\" checked=\"checked\" />";
echo "N";
}
Je ne sais pas comment écrire ça de façon correct ...
Merci encore du temps que vous consacré à mon modeste projet ^^
Bien cordialement
Philippe
if ($loic=="")
{
echo $loic;
echo "<input type=\"radio\" name=\"vloic\" id=\"radio\" value=\"Oui\" />";
echo "O";
echo "<input type=\"radio\" name=\"vloic\" id=\"radio2\" value=\"Non\" />";
echo "N";
}
if ($loic=="Oui")
{
echo $loic;
echo "<input type=\"radio\" name=\"vloic\" id=\"radio\" value=\"Oui\" checked=\"checked\" />";
echo "O";
echo "<input type=\"radio\" name=\"vloic\" id=\"radio2\" value=\"Non\" />";
echo "N";
}
if ($loic=="Non")
{
echo $loic;
echo "<input type=\"radio\" name=\"vloic\" id=\"radio\" value=\"Oui\" />";
echo "O";
echo "<input type=\"radio\" name=\"vloic\" id=\"radio2\" value=\"Non\" checked=\"checked\" />";
echo "N";
}
Je ne sais pas comment écrire ça de façon correct ...
Merci encore du temps que vous consacré à mon modeste projet ^^
Bien cordialement
Philippe