更新时间:2023-02-23 09:20:40
$查询=的mysql_query(SELECT * FROM表其中uid ='1'ORDER BY ID DESC);
$结果=阵列();
而($行= mysql_fetch_array($查询,MYSQL_ASSOC)){
$结果[] = $行;
}
I have a mysql table that looks like this:
id | uid | title | description | parent
1 | 1 | Portraits | desc. | photostream
2 | 1 | Abstract | descr. | photostream
and I am trying to build a multi-dimensional array that would end up looking like this:
Array
(
[0]
[id] => 1
[uid] => 1
[title] => Portraits
[description] => desc.
[parent] => photostream
[1]
[id] => 2
[uid] => 1
[title] => Abstract
[description] => descr.
[parent] => photostream
)
I am using the select query:
$query = mysql_query(
"SELECT * FROM `table` WHERE `uid`='1' ORDER BY `id` DESC");
Does anyone know how to do this? Thanks, Levi
$query = mysql_query("SELECT * FROM table WHERE uid = '1' ORDER BY id DESC");
$results = array();
while($line = mysql_fetch_array($query, MYSQL_ASSOC)){
$results[] = $line;
}