Transformer une variable en lien

Répondre


Cette question est un moyen d’empêcher des soumissions automatisées de formulaires par des robots.
Smileys
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: =D> #-o =P~ :^o :non: :priere: 8-|
Voir plus de smileys
  Revue du sujet
 

  Étendre la vue Revue du sujet : Transformer une variable en lien

par HD » 04 sept. 2005, 21:49

lol non :lol: tu vas juste mettre resolu

par davidc » 04 sept. 2005, 21:47

:oops:

Quand je pense que je me prends la tête pour un truc con, pour lequel d'ailleurs, dans mon esprit, j'ai vérifié 200 fois...

Y'a des fois ou son écran devient un véritable brouillard

Merci énormement, moi je vais me tirer une balle dans le genou...

par Truc » 04 sept. 2005, 21:44

euh ...comment veut tu affcher "link2" alors que tu ne fait pas un select dessus
$req6= "SELECT part2 FROM radioshow WHERE id=".$idMix;
$exec6 = mysql_query($req6); 
ca ne serai pas plus:
$req6= "SELECT link2 FROM radioshow WHERE id=".$idMix;
$exec6 = mysql_query($req6); 

par davidc » 04 sept. 2005, 21:41

Exactement.
<?php 
while($radioshow = mysql_fetch_assoc($exec6)) 
{ 
echo $radioshow['link2']; 
} 
?> 
Comme ça, il m'affiche bien le nom du fichier du type '251-1.mp3'

par Truc » 04 sept. 2005, 21:38

alors tu dis que comme ca il affiche les liens
<?php
while($radioshow = mysql_fetch_assoc($exec6))
{
echo $radioshow['link2'];
}
?>
et avec le code précédemment donné il n'affiche plus la variable ????? :-k

par davidc » 04 sept. 2005, 21:36

Dans ce cas, le lien correspondant me donne www.monurl/mix/.mp3

Il manque le nom du fichier... :roll:

L'exemple ici: http://www.samidee.com/radioshow.php

Je joins mon code au cas ou...
<?php include('connection.inc.php'); ?>
<?php
// Connexion à la base
$conn=mysql_connect($host,$user,$password) or die("Impossible de se connecter au serveur MySQL"); 
$bd=mysql_select_db($bdd,$conn) or die("Impossible de se connecter à la base de données"); 

$idMix = (isset($_GET['idMix']))?$_GET['idMix']:null;
// Requete 1
$req= "SELECT id, num_show FROM radioshow";
$exec = mysql_query($req);

// Requete 2
$req2= "SELECT baseline FROM radioshow WHERE id=".$idMix;
$exec2 = mysql_query($req2);

// Requete 3
$req3= "SELECT part1 FROM radioshow WHERE id=".$idMix;
$exec3 = mysql_query($req3);

// Requete 4
$req4= "SELECT link1 FROM radioshow WHERE id=".$idMix;
$exec4 = mysql_query($req4);

// Requete 5
$req5= "SELECT part2 FROM radioshow WHERE id=".$idMix;
$exec5 = mysql_query($req5);

// Requete 6
$req6= "SELECT part2 FROM radioshow WHERE id=".$idMix;
$exec6 = mysql_query($req6);
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Sami Dee, le site officiel</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
body,td,th {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-size: 11px;
	color: #FFFFFF;
}
a {
	font-size: 12px;
	color: #FFFFFF;
}
a:visited {
	color: #FCD300;
	text-decoration: none;
}
a:hover {
	color: #FCD300;
	text-decoration: none;
}
a:active {
	color: #FCD300;
	text-decoration: none;
}
a:link {
	text-decoration: none;
}
.Style1 {
	font-size: 11px;
	font-weight: bold;
}
body {
	background-color: #FFFFCC;
}
.Style2 {
	color: #FDD303;
	font-weight: bold;
}
.Style3 {
	color: #FCD300;
	font-weight: bold;
}
-->
</style>
</head>

<body>
<table width="740" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="000000" >
  <tr>
    <td><table width="740" border="0" align="center" cellpadding="0" cellspacing="0">
      <tr>
        <td><table width="740" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td><img src="img/hautgauche.jpg" width="330" height="150"></td>
              <td><a href="index.php"><img src="img/hautdroite.jpg" width="410" height="150" border="0"></a></td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td><? include "menu.php" ?></td>
      </tr>
      <tr>
        <td height="420" background="img/background-radioshow.jpg" ><table width="100%"  border="0" cellspacing="0" cellpadding="0">
          <tr>
            <td height="55" colspan="6">&nbsp;</td>
            </tr>
          <tr>
            <td width="26" height="306">&nbsp;</td>
            <td width="391" height="306" align="left" valign="top">
				<table width="100%"  border="0">
                <tr>
                  <td>
	<span class="Style2">
	<?php
	while($radioshow = mysql_fetch_assoc($exec2)) 
    {
	echo $radioshow['baseline'];
	}
	?>
	</span>
	<div align="justify"></div></td>
                </tr>
                <tr>
                  <td height="4"><div align="justify"><br>
                    <br>
                  </div></td>
                </tr>
                <tr>
                  <td>
	<span class="Style2">PART. ONE</span><br>	<?php
	while($radioshow = mysql_fetch_assoc($exec3)) 
    {
	echo $radioshow['part1'];
	}
	?>
	<div align="justify"></div></td>
                </tr>
                <tr>
                  <td><div align="justify"></div></td>
                </tr>
                <tr>
                  <td align="right">
	<?php
	while($radioshow = mysql_fetch_assoc($exec4)) 
    {
	echo $radioshow['link1'];
	}
	?>
	<div align="justify"></div></td>
                </tr>
                <tr>
                  <td>
	<span class="Style3">PART 2.</span><br>	<?php
	while($radioshow = mysql_fetch_assoc($exec5)) 
    {
	echo $radioshow['part2'];
	}
	?>
	<div align="justify"></div></td>
                </tr>
                <tr>
                  <td><div align="justify"></div></td>
                </tr>
                <tr>
                  <td align="right">
	<?php
	while($radioshow = mysql_fetch_assoc($exec6))
	{
	echo '<a href="mix/'.$radioshow['link2'].'.mp3">Telecharger le fichier</a>'; 
	}
	?>
	
	<div align="justify"></div></td>
                </tr>
              </table>			
	
			
        
			  <div align="left"></div></td>
            <td width="84" height="306" valign="top"><div align="center">
			
			<br>
			<br>
			
			<?php
			// Requête 1 et récupération du lien
			while($radioshow = mysql_fetch_assoc($exec))
    { 
			  echo '<a href="'.$_SERVER['PHP_SELF'].'?idMix='.$radioshow['id'].'">'.$radioshow['num_show'].'</a><br/>'; 
} 
			?>
			
			</div></td>
            <td width="39" height="306"></td>
            <td width="178" height="306"><table width="100%" height="100%"  border="0" align="center" cellpadding="0" cellspacing="0">
              <tr>
                <td height="215"></td>
              </tr>
              <tr>
                <td align="center" valign="top"><div align="center"><span class="Style1"><a href="/mix/253-1.mp3" target="_blank"><br>
                  SEPTEMBRE 05<br>
                  AOUT 05 Part.1</a></span><br>
                    <span class="Style1"><a href="/mix/253-2.mp3" target="_blank">AOUT 05 Part 2.</a></span> </div></td>
              </tr>
            </table></td>
            <td height="306"></td>
          </tr>
          <tr>
            <td height="59" colspan="6"></td>
            </tr>
        </table></td>
      </tr>
      <tr>
        <td>
        <tr>
              <td><img src="img/footer2-on.jpg" width="740"></td>
        </tr>
            <tr>
              <td><img src="img/footer3.jpg" width="740" height="7"></td>
            </tr>
        </table></td>
  </tr>
</table>    </td>
  </tr>
</table>
<map name="Lien S.MediasMap">
  <area shape="rect" coords="685,3,731,18" href="#">
</map>
</body>
</html>

par Truc » 04 sept. 2005, 21:25

Je voudrais transformer la variable link2 extrait de ma table radioshow en lien pointant vers /mix/link2, (link2 étant en fait le nom du fichier à télécharger inscrit dans ma base, du type monlien.mp3)
David
Si j'ai bien compri tu veux lister les mp3 dt le nom est contenu ds ta base
et tu veux avoir un truc du style:

lien musique1
lien musique2
...

as tu essayé comme ça ?
<?php 
while($radioshow = mysql_fetch_assoc($exec6)) 
{ 
echo '<a href="mix/'.$radioshow['link2'].'.mp3">Telecharger le fichier</a>';
} 
?> 

par davidc » 04 sept. 2005, 20:59

Personne n'a pu m'aider malheureusement...

Bon bah pour résumer le tout, je retente mon appel à l'aide en essayant d'être plus clair.

Voici mon code:
<?php 
while($radioshow = mysql_fetch_assoc($exec6)) 
{ 
echo $radioshow['link2']; 
} 
?> 
Je voudrais transformer la variable link2 extrait de ma table radioshow en lien pointant vers /mix/link2, (link2 étant en fait le nom du fichier à télécharger inscrit dans ma base, du type monlien.mp3)

Merci de votre aide
David

par davidc » 04 sept. 2005, 11:17

Oui pardon, j'ai copié un autre bout de code pour ne pas avoir a le modifier... mais j'avais testé et ça marche bien.

J'ai testé et ma variable n'est pas vide, je l'ai insérée en dur dans ma base

par jeff » 04 sept. 2005, 11:12

d'apres la deuxieme partie de ton code tu ne fais pas appel a la meme requete, et la meme variable , a tu verifier que ta varible n'est pas vide ?

par davidc » 04 sept. 2005, 11:07

Pour juste afficher ma variable, mon code est le suivant :
<?php
	while($radioshow = mysql_fetch_assoc($exec5)) 
    {
	echo $radioshow['part2'];
	}
	?>
Et ça, ça marche bien.


Maintenant pour que ça devienne un lien, c'est une autre histoire... J'ai fait ça, mais dans mon lien, il m'affiche bien le chemin et l'extension, mais pas la variable...
<a href="/mix/<?php
	while($radioshow = mysql_fetch_assoc($exec6))
	     {echo $radioshow['link2'];}
	?>">Télécharger le fichier</a>

par jeff » 04 sept. 2005, 11:02

mais encore

par Cyrano » 04 sept. 2005, 11:02

Comment est donc initialisée ta variable ?

par davidc » 04 sept. 2005, 11:00

Y'en a aucun qui marche...

Les shorts open tags sont activés.

par Cyrano » 04 sept. 2005, 10:55

<a href="monchemin/<?=$mavariable; ?>.mp3">Telecharger le fichier</a>
:!: Attention avant d'utiliser les "short open tag" de vérifier chez l'hébergeur final si cette options est bien activée, sinon, bonjour le boulot pour refaires toutes les pages du script.