I have this table for insert files data :
|id|url|author|post_id|post_type|timestamp|
In url
field i insert PHP serialize
data and fetch with this function:
function _is_files_list_($id,$type){
$files = mysqli::fetch("SELECT * FROM " . NEWS_FILES . " WHERE news_id = ? AND type = ? ",$id , $type );
if (count($files) > 0) {
$list_files = unserialize($files[0]['url']);
$count = count($list_files[0]);
for($i=0; $i<$count; $i++){
$files_show[] = array($list_files[0][$i]);
}
return $files_show;
}
else
{
return FALSE;
}
}
and result :
if(($list = _is_files_list_($id,"download")) !== false){
foreach ($list as $key => $data) {
echo urldecode($data[0]);
}
}
This worked for me and print/show url field form table but I need to show other table field ie author
or timestamp
using this function.
How can I generate this ?
did you tried something like?
foreach ($list as $key => $data) {
echo $data[key]['url'];
echo $data[key]['author'];
echo $data[key]['timestamp '];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.