Bonjour,
je tente de convertir la requête suivante en PDO :
Version PDO
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 $sqla = sprintf("SELECT cont_".$lang." FROM flatforswap_continent ORDER BY cont_".$lang." ASC"); $reqa = mysql_query($sqla) or die('Erreur SQL !<br>'.$sqla.'<br>'.mysql_error()); while($dataa = mysql_fetch_assoc($reqa)) { if ($continent == $dataa['cont_'.$lang.'']) { echo '<option value="'.$dataa['cont_'.$lang.''].'" selected="selected">'.$dataa['cont_'.$lang.''].'</option>'; } if ($continent != $dataa['cont_'.$lang.'']) { echo '<option value="'.$dataa['cont_'.$lang.''].'">'.$dataa['cont_'.$lang.''].'</option>'; } }
mais je coince sur la array...
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 $sqla = $db->prepare("SELECT cont_".$lang." FROM flatforswap_continent ORDER BY cont_".$lang." ASC"); $sqla->execute(array()); while($dataa = $sqla->fetch()) { if ($continent == $dataa['cont_'.$lang.'']) { echo '<option value="'.$dataa['cont_'.$lang.''].'" selected="selected">'.$dataa['cont_'.$lang.''].'</option>'; } if ($continent != $dataa['cont_'.$lang.'']) { echo '<option value="'.$dataa['cont_'.$lang.''].'">'.$dataa['cont_'.$lang.''].'</option>'; } }
Partager