本文介紹了mysql_field_name 到新的 mysqli的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我有辦法獲取表列的名稱.它工作正常,但現在我想更新到新的 mysqli ?(我嘗試了 mysqli_fetch_field 但我不知道如何應用到這種情況下,我不確定它是否是 wright 選項)
I have a way to get the name of the columns of a table. It works fine but now I want to update to the new mysqli ? (I tried the mysqli_fetch_field but I don't know how to apply to this case and I am not sure if it is the wright option)
如何用 mysqli 做同樣的事情?:
How to do the same with mysqli ? :
$sql = "SELECT * from myTable";
$result = mysql_query($sql,$con);
$id = mysql_field_name($result, 0);
$a = mysql_field_name($result, 1);
echo $id;
echo $a;
推薦答案
我不確定是否有更好的方法來做到這一點,但我檢查了這是否可以僅獲取列的名稱并且是新的mysqli:
I'm not sure if there is a better way to do that, but I checked that this works to get just the name of the columns and is the new mysqli :
$result = mysqli_query($con, 'SELECT * FROM myTable');
while ($property = mysqli_fetch_field($result)) {
echo $property->name;
}
這篇關于mysql_field_name 到新的 mysqli的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!