Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/237.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/65.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 数据库记录未完全连续放置_Php_Mysql - Fatal编程技术网

Php 数据库记录未完全连续放置

Php 数据库记录未完全连续放置,php,mysql,Php,Mysql,我有这个代码,我数据库中的主要代码是计数器 <input class="textbox1" tabIndex="8" maxLength="49" size="30" name="n_counter" value=' <?php $result = mysql_query("SELECT * FROM procurement WHERE counter != ' '"); while ( $row = mysql_fetch_array( $result ) ) {

我有这个代码,我数据库中的主要代码是计数器

<input class="textbox1" tabIndex="8" maxLength="49" size="30" name="n_counter" value='
<?php
   $result = mysql_query("SELECT * FROM procurement WHERE counter != ' '");
   while ( $row = mysql_fetch_array( $result ) ) {
      $value = $row['counter'];
   }
   $i = "0";
   while ( $i <= $value ) {
      $i++;
   }
   $value2 = strlen( $i );
   if ( $value2 == 1 ) {
      echo "00000" . $i;
   } else if ( $value2 == 2 ) {
      echo "0000" . $i;
   } else if ( $value2 == 3 ) {
      echo "000" . $i;
   } else if ( $value2 == 4) {
      echo "00" . $i;
   } else if ( $value2 == 5 ) {
      echo "0" . $i;
   } else {
      echo $i;
   }
?>'>
一切正常

只要更新这个

$result = mysql_query("SELECT * FROM procurement WHERE counter != ' ' ORDER BY counter ASC");
$result = mysql_query("SELECT * FROM procurement WHERE counter != ' ' ORDER BY counter ASC");
强烈建议您使用
mysqli
而不是
mysql

您必须更新
连接
,然后更新
查询执行

$connection = ($GLOBALS["___mysqli_ston"] = mysqli_connect( "db_server",  "db_user",  "db_password","database" )) or die( ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)) ) ;

$sql = "SELECT * FROM procurement WHERE counter != ' ' ORDER BY counter ASC";
$result = mysqli_query($GLOBALS["___mysqli_ston"],  $sql ) or die( ((is_object($GLOBALS["___mysqli_ston"])) ? mysqli_error($GLOBALS["___mysqli_ston"]) : (($___mysqli_res = mysqli_connect_error()) ? $___mysqli_res : false)) ) ; 
在sql查询中添加“按计数器ASC排序”