我怎样才能回应这些功能而不是做

时间:2013-11-21 03:32:10

标签: php

我怎样才能回应我的功能,而不是按照我的方式进行。这是代码;

  mysql_connect(db_server, db_user, db_pass);
  $result2 = mysql_db_query(db_name,"SELECT * FROM user ORDER BY user_id ASC LIMIT 5");

  while($row2 = mysql_fetch_array($result2)) { 
  if($row = mysql_fetch_array($result)) { 
      echo "<tr style='padding-top:10px;'>";
      echo "<td>" . $row2['user_id'] . "</td>";  
      echo "<td>" . $row['online'] . "</td>";  
      echo "</tr>";
  }
  }

如果没有while和if标签设置,我如何回显我的代码?

1 个答案:

答案 0 :(得分:0)

这应该有效:

   <?php
   mysql_connect(db_server, db_user, db_pass);
   $result2 = mysql_db_query(db_name,"SELECT * FROM user ORDER BY user_id ASC LIMIT 5");

    while($row2 = mysql_fetch_array($result2)) { 
     if($row = mysql_fetch_array($result)) { 
       $userId = $row['user_id'];
       $userOnline = $row['online'];
       ?>
       <tr style='padding-top:10px;'>
       <td><?=$userId?></td>
       <td><?=$userOnline?></td>
       </tr>
       <?php
     }
    }
   ?>

我想我应该提出光荣的提议:mysql_connect(以及其他mysql_函数)已被折旧。你应该看看过渡到mysqli或PDO。