누군가가 도울 수 있기를 바랍니다.배열 배열을 반복하는 방법
나는 그저 단순한 것으로서 나는 어떤 이유로 든 운동 할 수 없다고 확신한다.
기본적으로 모든 데이터베이스 기능 (연결, 선택, 삽입, 업데이트)을 처리하는 클래스가 있습니다.
select 함수에서 배열을 반환합니다.
public function getAll($table, $cols, $where, $limit, $order) {
// Set the query variables
if($cols == '') {
$cols = '*';
}
if($where!='') {
$where = ' WHERE '.$where;
}
if($limit!= '') {
$limit = ' LIMIT '.$limit;
}
if($order!='') {
$order = ' ORDER BY '.$order;
}
// Make the query string
$sql = 'SELECT '.$cols.' FROM '.$table.$where.$order.$limit;
//echo $sql;
// Set the query
$news_qry = mysql_query($sql);
// Set the array
$rows = array();
// Run a loop through the results
while($item = mysql_fetch_object($news_qry))
{
// Add each row to an array.
$rows[] = $item;
}
return $rows;
}
이 기능은 배열을 인쇄 할 수 있도록 작동합니다. 난 단지 데이터베이스에서 결과의 첫 글자를 얻을 각 루프의 내
$arr_GalleryInfo = $dataObj->getAll('tbl_Gallery', '', '', '', '');
(아래 참조) -
Array ([Gallery_id] => 1 [Gallery_Name] => Test [Gallery_FolderName] => Test Folder)
을하지만 객체를 사용하는 갈 때 : 아래를 참조하십시오.
<?php
foreach ($arr_GalleryInfo[0] as $arrGallery)
{
?>
<tr>
<td>
<?php echo $arrGallery['Gallery_Name']; ?>
</td>
<td>
<?php echo $arrGallery; ?>
</td>
<td>
<?php echo $arrGallery; ?>
</td>
</tr>
<?php
}
?>
도움이 될 것입니다.
감사합니다.
도움 주셔서 감사합니다. 나는 그것을 시도하지 않았다는 것을 믿을 수 없다. –