Ich habe eine Tabelle wie folgt aus:UPDATE alle Zeilen nach der 2. Reihe, von 1 auf diese Zeilen ADDING
id subject position visible
1 Home 1 1
2 About us 2 1
3 Our partners 3 1
18 Products 4 1
19 Extra 5 0
Ich möchte 1 Nummer hinzufügen, um alle Zeilen nach Position = 2, wie folgt aus:
id subject position visible
1 Home 1 1
2 About us 2 1
3 Our partners 4 1
18 Products 5 1
19 Extra 6 0
ich so versucht, aber das funktioniert nicht:
$row=mysql_query("SELECT * FROM table");
$count=mysql_num_rows($row);
$position=3;
$add=($position+1);
while($position<=$count)
{
$sql="UPDATE subjects SET position=$add WHERE position=$position";
mysql_query($sql);
$add++;
$position++;
}
Nach oben Code anwenden, sieht meine Tabelle wie folgt aus:
id subject position visible
1 Home 1 1
2 About us 2 1
3 Our partners 6 1
18 Products 6 1
19 Extra 6 0
Gibt es eine Lösung?
Bitte sagen Sie mir, Sie sind nicht Updates in Ihrer Schleife zu tun. – PeeHaa