Bonjour à tous,
Comment peut-on renuméroter "automatiquement" une id en "auto_increment" suite à des suppressions de lignes dans la table ?
Merci d'avance.
Code : Tout sélectionner
$sql="SELECT id, DATE_FORMAT(date, '%d-%m-%Y') as dateFR, nom, prenom, spe01, spe02, spe03, spe04, spe05, spe06, spe07, spe08, spe09, spe10, spe11, spe12, spe13, spe14, spe15, spe15autre FROM free ORDER BY date DESC";
$req=mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$count=mysql_num_rows($req);
echo 'Nombre d\'inscrits : <span class="txt06">'.$count.'</span> ';
$sql_2="SELECT DATE_FORMAT(date, '%d-%m-%Y') as dateFR, heure FROM free WHERE id=$count";
$req_2=mysql_query($sql_2) or die('Erreur SQL !<br>'.$sql_2.'<br>'.mysql_error());
$data=mysql_fetch_assoc($req_2);
$data['heure']=substr($data['heure'],0,5);
echo 'Dernière inscription le <span class="txt06">'.$data['dateFR'].'</span> à '.$data['heure'].'';
Code : Tout sélectionner
SELECT
*
FROM
table
WHERE
id = MAX(id)Code : Tout sélectionner
$sql="SELECT id, DATE_FORMAT(date, '%d-%m-%Y') as dateFR, nom, prenom, spe01, spe02, spe03, spe04, spe05, spe06, spe07, spe08, spe09, spe10, spe11, spe12, spe13, spe14, spe15, spe15autre FROM free ORDER BY date DESC";
$req=mysql_query($sql) or die('Erreur SQL !<br>'.$sql.'<br>'.mysql_error());
$count=mysql_num_rows($req);
echo 'Nombre d\'inscrits : <span class="txt06">'.$count.'</span> ';
$sql_2="SELECT DATE_FORMAT(date, '%d-%m-%Y') as dateFR, heure FROM free WHERE id = MAX(id)";
$req_2=mysql_query($sql_2) or die('Erreur SQL !<br>'.$sql_2.'<br>'.mysql_error());
$data=mysql_fetch_assoc($req_2);
$data['heure']=substr($data['heure'],0,5);
echo 'Dernière inscription le <span class="txt06">'.$data['dateFR'].'</span> à '.$data['heure'].'';
Code : Tout sélectionner
SELECT *
FROM table
WHERE id = ( SELECT MAX(id) FROM table )Code : Tout sélectionner
SELECT *
FROM table
ORDER BY id DESC
LIMIT 1