php呼叫資料庫字段,php mysql資料庫裡面乙個字段值的呼叫和顯示問題,線上等

時間 2021-09-06 02:07:32

1樓:

你如果懂php資料庫鏈結請往下看

include "conn.php";

//插入資料

$sql="insert into table (name,phone,product) values ("姓名","手機","產品名稱")";//("姓名","手機","產品名稱")括號裡面的可以用變數代替。

mysql_query($sql);

//輸出資料庫中的資料。

$sql="select * from table";

$query=mysql_query($sql);

while($row=mysql_fetch_array($query))

php+mysql資料庫裡面乙個字段值的呼叫和顯示問題,**等!

2樓:匿名使用者

【思路】

取值,解析成陣列,迴圈輸出

【效果】

【php】

<?php

header('content-type:text/html; charset=utf-8');

/*** special_str_to_arr 轉為陣列

* 2014-12-03

* * @author rudon <[email protected]>

* @param string $str

* @return array $return

*/function special_str_to_arr ($str)

/* 格式化 */

$human_preg = '/([a-za-z\d]+):/i';

$human_str = preg_replace($human_preg, '', $str); // demo1

$human_str = str_replace(';', '}', $human_str); // demo3

$human_str = preg_replace('/";(["\d]+)/i', '":$1', $human_str); // demo4

$human_str = preg_replace('/\}(\d+)/i', '},$1', $human_str); // demo5

$human_str = str_replace(';"', ',"', $human_str); // demo6

$human_str = preg_replace('/([^\d])(\d+):/i', '$1"$2":', $human_str); // demo7

/* 字串轉陣列 */

$arr = json_decode($human_str, true);

if (is_array($arr) && count($arr))

return $return;

}/**

* get_upper_abc_by_i 通過數字取大寫字母 4=>d 1=>a

* 2014-12-03

* * @author rudon <[email protected]>

* @param int $n

* @return string $return

*/function get_upper_abc_by_i ($n = 1)

return $return;

}/* 從欄位取出字串 */

$xuanxiang_str = 'a:4:i:2;a:2:i:3;a:2:i:4;a:2:}';

$options = special_str_to_arr($xuanxiang_str); // demo8 陣列

// print_r($arr);die;

/* 增加選項對應的字母 */

if (count($options))

}// print_r($options);die;

/* html** */

echo '';

die();

/************** 示例 **************

// 目標格式:,"2": ... }

// demo1 => 2;3;4;}

// demo2 => 2:3:4:}

// demo3 => 2:3:4:}

// demo4 => 2:3:4:}

// demo5 => ,2:,3:,4:}

// demo6 => ,2:,3:,4:}

// demo7 => ,"2":,"3":,"4":}

// demo8 => 在最下面

*****************************/

/*****解析出來的陣列demo8****

array

([1] => array

([k] => 1

[xx] => 你

)[2] => array

([k] => 2

[xx] => 我

)[3] => array

([k] => 3

[xx] => 你們

)[4] => array

([k] => 4

[xx] => 我們))

******/

VF資料庫把資料庫中的字段複製到另資料庫中

select byzx.byzxmc from byzx into table zxs.syd vf中怎樣將乙個欄位的內容複製到另一字段中 如果是同一條記錄的乙個字段值複製到另乙個字段值,可用替換命令repl all 欄位1名 with 欄位2名其中欄位1是指接收資料的字段 欄位2是指提供資料的字段...

php提交表單到資料庫

楓默有愛 php資料庫操作主要分為5個步驟 1連線mysql 2連線到你的資料庫 3寫sql語句 4執行sql語句 5關閉資料庫 第一步 con mysql connect localhost root 123456789 第二步 mysql select db rankingme conn 第三步...

php擷取資料庫中內容

1全部strip tags是php自帶的過濾html標籤的函式。row mb substr htmlspecialchars strip tags latestnews content 0,26,utf 8 如果想把之間的也去掉,只能正則了 str preg replace usi str 用下面的...