خب اینکه واسه کدایگنیتر نیست !!!! یه کلاس میخوام که روی فریم ورک ست شده باشه
خودم اینو نوشتم ولی زیاد کامل نیست ...
<?php
class grid extends CI_Model{
private $pageshow=10; function __construct() {parent::__construct(); } function newgrid($table,$field=array(),$url='',$style=array ()) {
##action delete
if(isset($_GET['action']) and $_GET['action']=='del') {
$this->db->delete($table,array('id'=>$_GET['id']));
}
$s=''; foreach($style as $st=>$stl) { $s .=$st.":".$stl.";"; } ?> <table style="<?php echo $s;?>;font-family: 'tahoma' !important;font-size: 11px !important; font-weight: normal !important;"> <tr style="background-color: #404040;color: #fff;">
<?php
foreach($field as $fl) {
echo "<td>".$fl."</td>";
} ?>
<td>ویرایش</td> <td>حذف</td>
</tr>
<?php if(isset($_GET['page'])) { $do=$this->db->get($table,$this->pageshow,$this->pageshow*$_GET['page']); } else { $do=$this->db->get($table); } $i=0; foreach($do->result() as $show) { if($i==2) { $i=0; } echo "<tr class=class".$i.">"; $i++; foreach($field as $key=>$fo) {
echo "<td>".$show->$key."</td>";
} $id=$show->id;
echo "<td><a href=".$url."?action=edit&id=".$id." >edit</a></td>"; ?><td><a onclick="del(); return false ;" href="<?php echo $url ;?>?action=del&id=<?php echo $id ;?>" >remove</a></td> <?php echo " </tr>"; }
?> <tr><td><?php $this->page($table,$url);?></td></tr> </table> <?php
} function page($table,$url) { $count=$this->db->count_all($table); echo"<ul class='pagination'>"; for($i=0;$i<ceil( $count/$this->pageshow);$i++) { echo "<li><a href=".$url."?page=".$i.">".$i."</a></li>"; } echo "</ul>"; }
}