简体   繁体   English

如何避免通过php显示名为id的mysql表列

[英]How to avoid displaying mysql table column named id via php

Iam using this code to display all the column fields from database table and it works fine. 我使用此代码显示数据库表中的所有列字段,并且工作正常。

Please how do I avoid displaying column named id which is the first column in the table 请如何避免显示名为id的列,该列是表中的第一列

<?php
require('db.php');
$result = $db->prepare('SHOW COLUMNS from info4');

$result->execute(array());
while ($row = $result->fetch()) 
{

echo $rw = $row[0];
}
?>

You can display columns one by one! 您可以一一显示列!

$data = $result->fetchall();
foreach($data as $row){
   echo $row['col1'];
   echo $row['col2'];
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM