Hi you can use it or u can modify it as your requirements. # i did it for my new web site http://we4tech.com/newlnf visit for this module: http://we4tech.com/newlnf/admin
# it i did as Smarty Plugin function. but u can use it as your embedding code; Hope it will helpful :D -hasan http://we4tech.com http://wap.we4tech.com <?php //------------- Code Starts function smarty_function_get_contents($params, &$smarty) { // This global variable for Database Connection // replace it by your database connection object global $getConn; // extrat parameters and request variables // so i can use locally extract($params); extract($_REQUEST); // Total approx. result $sql2='SELECT count(*) FROM site_content'; // apply sql2 $getRs2=mysql_query($sql2); // get rows $getRow=mysql_fetch_array($getRs2); // init. vars $total=$getRow[0]; // per page displayable record $per_page=10; $index=0; $next=0; $prev=0; // check is $_GET['id'] like: http://yoururl/?id=1 if(!isset($id)) { $index=0; // make next pointer $next=$index + 1; // make previous pointer $prev=$index - 1; } else { // get total data for this page $index=$id * $per_page; // make next $next=$id+1; // make previous $prev=$id-1; } // get first pointer $first=0; // get last pointer $last=round($total/$per_page); // Fetch Data // For your use just chage the column fields // And table name $sql=' SELECT id, template, user_level, date, title FROM site_content LIMIT '.$index.','.$per_page.' '; // execute query $getRs=mysql_query($sql); // output echo ' <table> <tr> <td class="td3"> </td> <td class="td3" style="text-align:center"><input type="checkbox" name="selectAll" onClick="JS_userSelectAll(this,\'select[]\');" /></td> <td class="td3">Title</td> <td class="td3">Date</td> <td class="td3">Template</td> <td class="td3">User Level</td> <td class="td3">Edit</td> </tr> '; // for style looping $arrClass=array(0=>1, 1=>2); // count for style suffix $count=0; // sl count $slCount=$index+1; // fetch while($row=mysql_fetch_array($getRs)) { // this portion is not important $styleClass="td".$arrClass[$count]; $count++; if($count>1) $count=0; // output echo ' <tr> <td class="'.$styleClass.'">'.$slCount.'</td> <td class="'.$styleClass.'" style="text-align:center"><input type="checkbox" name="select[]" value="'.$row['id'].'"/></td> <td class="'.$styleClass.'">'.$row['title'].'</td> <td class="'.$styleClass.'">'.date('d/m/y h:i:s',$row['date']).'</td> <td class="'.$styleClass.'">'.$row['template'].'</td> <td class="'.$styleClass.'" style="text-align:center">'.(($row['user_level']=='1')? 'Normal' : 'Admin').'</td> <td class="'.$styleClass.'" style="text-align:center"> <a href="?action=tpl_edit&id='.$row['id'].'">Edit</a></td> </tr> '; $slCount++; } // end table echo '</table>'; // check // is $next and $prev is valid if($next>$last) { $next=$last; } if($prev<0) { $prev=0; } // assign to template $smarty->assign("prev",$prev); $smarty->assign("next",$next); $smarty->assign("last",$last); $smarty->assign("first",$first); } //------------- Code Ends ?> --- Wade <[EMAIL PROTECTED]> wrote: > 04182005 1649 GMT-6 > > Ok. Odd thing here. I have only three records that > im testing with. But > this is actually skipping one. > > function NextAppID($currentappid) { > include ('db.php'); > > $sql ="SELECT MAX(appid) AS next FROM > application WHERE appid > > '".$currentappid."'"; > $result = mysql_query($sql); > > if ($result) { > $id = mysql_num_rows($result); > > if ($id){ > $nextAppID = > mysql_result($result,0,0); > } > } > > return $nextAppID; > } > > My first one is 1 and the next it pulls is 3. > > Wade > > Patrick Bierans wrote: > > > it uses > "higher" and < "lower" so it doesn't > matter if the exact > > matching > > row exists. > > > > ----- Original Message ----- > > From: "Wade" <[EMAIL PROTECTED]> > > To: <[email protected]> > > Sent: Monday, April 18, 2005 11:07 PM > > Subject: Re: [php-list] Next & Previous Records > > > > > > > 04182005 1606 GMT-6 > > > > > > Patrick, question on this. Im thinking that this > only will work when you > > > have consecutive numbering of application id's > like, 1, 2, 3, 4, and so > > > on. What if you have deleted a number = 1, 4, 5, > 8,9,10 = would this > > > still work? > > > > > > Wade > > > > > > > > > > > > Patrick Bierans wrote: > > > > > >> I think it's a wrapping thing. If reaching the > end start from > > beginning. > > >> > > >> ----- Original Message ----- > > >> From: "Wade" <[EMAIL PROTECTED]> > > >> To: <[email protected]> > > >> Sent: Monday, April 18, 2005 10:57 PM > > >> Subject: [php-list] Next & Previous Records > > >> > > >> > > >> > 04182005 1551 GMT-6 > > >> > > > >> > I want to find the next and previous records > in a list of records. I > > >> > did > > >> > a search and found this code: > > >> > > > >> > $q1 = "SELECT Max(clrId ) As prev from > tblcolorpattern Where clrId < > > >> > $id"; > > >> > $res = mysql_query($q1); > > >> > if($res) > > >> > { > > >> > $num = mysql_num_rows($res); > > >> > if($num) > > >> > { > > >> > $prev = mysql_result($res,0,0); > > >> > } > > >> > } > > >> > > > >> > this code give me id before the current id in > DB > > >> > > > >> > > /************************************************/ > > >> > > > >> > $q2 = "SELECT Min(clrId ) As next from > tblcolorpattern Where clrId > > > >> > $id"; > > >> > $res = mysql_query($q2); > > >> > if($res) > > >> > { > > >> > $num = mysql_num_rows($res); > > >> > if($num) > > >> > { > > >> > $next = mysql_result($res,0,0); > > >> > } > > >> > } > > >> > this code give me id after the current id in > DB > > >> > > > >> > But Im a but unsure of it all so I would like > some help with it. Im > > >> > going to change it to what I think I would > write: > > >> > > > >> > $query = "$SELECT MAX(appid) AS prev FROM > Application WHERE appid < > > >> > '".$appid."'"; > > >> > > > >> > $result = mysql_query($query); > > >> > > > >> > if($result) { > > >> > $num = mysql_num_rows($result); > > >> > > > >> > if($num) { > > >> > $next = mysql_result($result,0,0); > > >> > } > > >> > } > > >> > > > >> > Ok. Im selecting the next larger appid > (application id) and > > assigning > > >> > it > > >> > to 'prev'. > > >> > > > >> > Then, im assigning the appid to $num. > > >> > I dont understand the next part at all = > ($result,0,0); > > >> > > > >> > Wade > > >> > > > >> > > > >> > [Non-text portions of this message have been > removed] > > >> > > > >> > > > >> > > > >> > Community email addresses: > > >> > Post message: [email protected] > > >> > Subscribe: > [EMAIL PROTECTED] > > >> > Unsubscribe: > [EMAIL PROTECTED] > > >> > List owner: [EMAIL PROTECTED] > > >> > > > >> > Shortcut URL to this page: > > >> > http://groups.yahoo.com/group/php-list > > >> > > > >> > > > >> > > > >> > > > >> > > > -------------------------------------------------------------------------------- > > >> > Yahoo! Groups Links > > >> > > > >> > a.. To visit your group on the web, go to: > > >> > http://groups.yahoo.com/group/php-list/ > > >> > > > >> > b.. To unsubscribe from this group, send an > email to: > > >> > [EMAIL PROTECTED] > > >> > > > >> > c.. Your use of Yahoo! Groups is subject to > the Yahoo! Terms of > > >> Service. > > >> > > > >> > > > >> > > >> > > >> > > >> Community email addresses: > > >> Post message: [email protected] > > >> Subscribe: > [EMAIL PROTECTED] > > >> Unsubscribe: > [EMAIL PROTECTED] > > >> List owner: [EMAIL PROTECTED] > > >> > > >> Shortcut URL to this page: > > >> http://groups.yahoo.com/group/php-list > > >> > > >> > > >> > > > ------------------------------------------------------------------------ > > >> *Yahoo! Groups Links* > > >> > > >> * To visit your group on the web, go to: > > >> http://groups.yahoo.com/group/php-list/ > > >> > > >> * To unsubscribe from this group, send an > email to: > > >> [EMAIL PROTECTED] > > >> > <mailto:[EMAIL PROTECTED]> > > >> > > >> * Your use of Yahoo! Groups is subject to > the Yahoo! Terms of > > >> Service > <http://docs.yahoo.com/info/terms/>. > > >> > > >> > > > >>------------------------------------------------------------------------ > > >> > > >>No virus found in this incoming message. > > >>Checked by AVG Anti-Virus. > > >>Version: 7.0.308 / Virus Database: 266.9.16 - > Release Date: 4/18/2005 > > >> > > >> > > > > > > > > > [Non-text portions of this message have been > removed] > > > > > > > > > > > > Community email addresses: > > > Post message: [email protected] > > > Subscribe: > [EMAIL PROTECTED] > > > Unsubscribe: > [EMAIL PROTECTED] > > > List owner: [EMAIL PROTECTED] > > > > > > Shortcut URL to this page: > > > http://groups.yahoo.com/group/php-list > > > > > > > > > > > > > > > -------------------------------------------------------------------------------- > > > Yahoo! Groups Links > > > > > > a.. To visit your group on the web, go to: > > > http://groups.yahoo.com/group/php-list/ > > > > > > b.. To unsubscribe from this group, send an > email to: > > > [EMAIL PROTECTED] > > > > > > c.. Your use of Yahoo! Groups is subject to the > Yahoo! Terms of > > Service. > > > > > > > > > > > > > > Community email addresses: > > Post message: [email protected] > > Subscribe: [EMAIL PROTECTED] > > Unsubscribe: > [EMAIL PROTECTED] > > List owner: [EMAIL PROTECTED] > > > > Shortcut URL to this page: > > http://groups.yahoo.com/group/php-list > > > > > > > ------------------------------------------------------------------------ > > *Yahoo! Groups Links* > > > > * To visit your group on the web, go to: > > http://groups.yahoo.com/group/php-list/ > > > > * To unsubscribe from this group, send an > email to: > > [EMAIL PROTECTED] > > > <mailto:[EMAIL PROTECTED]> > > > > * Your use of Yahoo! Groups is subject to the > Yahoo! Terms of > > Service <http://docs.yahoo.com/info/terms/>. > > > > > >------------------------------------------------------------------------ > > > >No virus found in this incoming message. > >Checked by AVG Anti-Virus. > >Version: 7.0.308 / Virus Database: 266.9.16 - > Release Date: 4/18/2005 > > > > > > > [Non-text portions of this message have been > removed] > > __________________________________ Do you Yahoo!? Plan great trips with Yahoo! Travel: Now over 17,000 guides! http://travel.yahoo.com/p-travelguide Community email addresses: Post message: [email protected] Subscribe: [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] List owner: [EMAIL PROTECTED] Shortcut URL to this page: http://groups.yahoo.com/group/php-list Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/php-list/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
