variable dans une balise image
Voila mon problème : j'aimerai diminuer ma longueur et ma largeur de x%
J'ai choisi de mettre ma liens image sous mysql, car j'aurai d'autres infos à mettre avec les photos et des liens entre les tables à créer. J'ai simplifier le code pour cibler le problème
voilà : mes "fabrications".
Précision : je suis nul en calcul.
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
<?
$sql="SELECT nom_img FROM img";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
while($data = mysql_fetch_assoc($req))
{
list($width, $height) = getimagesize($data['nom_img']);
for($width; $data = mysql_fetch_assoc($req); $width/"30")
{
for($height; $data = mysql_fetch_assoc($req); $height/"30")
{
echo '<img width=$width $height=$height src="'.$data['nom_img'].'">';
}}}
?> |
et
Code:
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
|
<?
$sql="SELECT nom_img FROM img";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
while($data = mysql_fetch_assoc($req))
{
list($width, $height) = getimagesize($data['nom_img']);
$ratio_width = array($width*(30/100));
$ratio_height = array($height*(30/100));
foreach($ratio_width as $largeur)
{
foreach($ratio_height as $longueur)
{
echo '<img width=$largeur $height=$longueur src="'.$data['nom_img'].'">';
}}}
?> |
et
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
|
<?
$sql="SELECT nom_img FROM img";
$req = mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
while($data = mysql_fetch_assoc($req))
{
list($width, $height, $type, $attr) = getimagesize($data['nom_img']);
$ratio_width=($width/2);
$ratio_height=($height/2);
echo $ratio_width;
echo '<img width="$ratio_width" height="$ratio_height" src="'.$data['nom_img'].'" /> ';
}
?> |
Dans ce dernier code le 'echo $ratio_width;' me retourne bien la taille divisé par deux.Il est mit pour contrôle. Cependant $ratio_width et $ratio_height placer dans la balise image, ne fonctionne pas.
Pq?
Merci pour votre réponse