Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/72.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 在mysql函数中指定序列号 while($one=mysql\u fetch\u数组($two)){ 这里要序列号吗 }_Php_Mysql_While Loop_Autonumber - Fatal编程技术网

Php 在mysql函数中指定序列号 while($one=mysql\u fetch\u数组($two)){ 这里要序列号吗 }

Php 在mysql函数中指定序列号 while($one=mysql\u fetch\u数组($two)){ 这里要序列号吗 },php,mysql,while-loop,autonumber,Php,Mysql,While Loop,Autonumber,我想自动编号序列号。。有可能吗?我的印象是,您试图为每一行生成一个连续的数字: while ($one = mysql_fetch_array($two)) { <td>Want Serial No Here</td> <td><?=$something['something']?></td> } 我的印象是,您试图为每一行生成一个连续的数字: while ($one = mysql_fetch_array($two)) { <

我想自动编号序列号。。有可能吗?

我的印象是,您试图为每一行生成一个连续的数字:

while ($one = mysql_fetch_array($two)) {
<td>Want Serial No Here</td> 
<td><?=$something['something']?></td>
}

我的印象是,您试图为每一行生成一个连续的数字:

while ($one = mysql_fetch_array($two)) {
<td>Want Serial No Here</td> 
<td><?=$something['something']?></td>
}

MySQL
本机不支持
rownum
/
row\u number

您可以使用会话变量模拟它:

<?php

$count = 0;
while($row = mysql_fetch_assoc($res)){
    $count++;

    echo '<tr><td>' . $count . '</td><td>' . htmlspecialchars($row['name']) . '</td></tr>';
}
,或者更好,只需使用
PHP
变量:

SET @r := 0;

SELECT  @r := @r + 1 AS rownum, t.*
FROM    mytable
ORDER BY
        myfield

MySQL
本机不支持
rownum
/
row\u number

您可以使用会话变量模拟它:

<?php

$count = 0;
while($row = mysql_fetch_assoc($res)){
    $count++;

    echo '<tr><td>' . $count . '</td><td>' . htmlspecialchars($row['name']) . '</td></tr>';
}
,或者更好,只需使用
PHP
变量:

SET @r := 0;

SELECT  @r := @r + 1 AS rownum, t.*
FROM    mytable
ORDER BY
        myfield