2017-04-23 55 views
-1

我想顯示來自特定表的列,我做了它,但我完全是新來的這個,我試圖爲我自己和社區建立這個網站,所以他們可以兌換齒輪從他們通過發佈得分。腳本工作正常,但我想擺脫這個東西陣列和箭頭,你可以看到它在我提供的截圖,我只想顯示用戶名和點,但不是整個事情。SQLite和PHP顯示使用數組的數據

https://gyazo.com/1cbb85765ae3fd21efa76215b7042329

這裏是我使用的代碼:

<?php 
     $db = new SQLite3('phantombot.db'); 

     $sql = "SELECT variable, value FROM phantombot_points"; 

     $result = $db->query($sql);//->fetchArray(SQLITE3_ASSOC); 

     $row = array(); 

     $i = 0; 

     while($res = $result->fetchArray(SQLITE3_ASSOC)){ 

      if(!isset($res['variable'])) continue; 

       $row[$i]['variable'] = $res['variable']; 
       $row[$i]['value'] = $res['value']; 
       $i++; 

      } 

      print_r($row); 
?> 

回答

0

您可以創建表爲

<table> 
    <tr><th>Username</th><th>Points</th></tr> 
     <?php foreach($row as $datum): ?> 
      <tr> 
       <td><?php echo $datum['variable'];?></td> 
       <td><?php echo $datum['value'];?></td> 
      </tr> 
     <?php endforeach;?> 
</table> 
+0

因此,基本上所有我需要做的是去除最後幾部分代碼,只需粘貼這個? – racan01

+0

您需要在while方法之後粘貼它。刪除'print_r($ row);'並粘貼答案以代替'print_r' –

+0

工作就像一個魅力!感謝AGAM! – racan01