This option will reset the home page of this site. Restoring any closed widgets or categories.

Reset

Database Connection And Pagination In PHP Using Symfony Framework

After creating the project then the application and at last the module we want using symfony framework.Go to the module folder(HERE MY MODULE NAME IS PLAYLIST)

we will have the action.class.php and indexSuccess.php

First Take The Action.class.php file in dreamweaver or any editor you want and add the following codes

HERE PLAYLIST IS THE NAME OF MY MODULE


<?php
class playlistActions extends sfActions
{
public function executeIndex(){//FTYPE is the table name//Audio Filed Name

//We are then itializing the pager to the criteria c

//We are going to display 10 results per page

$c = new Criteria();
$c->add(FilePeer::FTYPE,’AUDIO’);
$c->add(FilePeer::USERID,0,Criteria::GREATER_THAN);
$this->data = FilePeer::doSelect($c);
//another criteria

$pager = new sfPropelPager(’File’,10);
$pager->setCriteria($c);
$pager->setPage($this->getRequestParameter(’page’, 1));

//$pager->setPage($page,”1″);
$pager->init();
$this->pager = $pager;

}
}

?>


Now we are going to use the success page of the action page indexSuccess.php <body bgcolor=”#000000″>
<?php use_helper(’Javascript’) ?><table border=”1″>
<?php $i=($pager->getPage()*10)-10+1; ?>
<?php foreach ($pager->getResults() as $user): ?><?php // echo $dat->getId();

$image = $user->getUserid();

$author = $user->getCaption();
$date =$user->getDate();
$mainid =$user->getId();

?>
<?php
//echo link_to(image_tag(’http://s3.amazonaws.com/mobusers/100×100/’.$image), ‘article/read?title=Finance_in_France’) ?>

<td align=left><tr align=left>
<td width=’1%’><input type=’checkbox’ name=’mob$balu’ id=’box’ value=’$mainid’ ><img alt=’Select This Song’ width=90 src=’http://s3.amazonaws.com/tutorialz/100×100/<?php echo $image;?>’ ></td>
<td >
<b> <font color=#000000><?php echo $author;?></b>
<div class=’desc’><i>Page: <?php echo $image?></i></div>
<span class=’postdetails’>Date Added:<?php echo $date;?></font><br><a href=’javascript:void(0)’ onClick=”window.open(’http://audio.balu.in/audio/player.php?id=<?php echo $mainid ;?>’,'mobplayer’,'height=226, width=555,toolbar=no,scrollbars=no,menubar=no,location=no,status=0,resizable=0,left=400,top=400′ )”>

<?php echo image_tag(’play.jpg’);?> </a></span>

</table>

<table border=”1″>

<?php $i=$i+1; ?>
<?php endforeach ?>

<?php if ($pager->haveToPaginate()): ?>
<table width=”61%” border=”0″ cellpadding=”0″ cellspacing=”0″>
<tr>
<td width=”10%” height=”24″ align=”center” valign=”middle” class=”formText”><a href=”<?php echo url_for(’playlist/index?page=’.$pager->getFirstPage()); ?>” class=”Heading6″>FIRST</a></td>
<td width=”8%” height=”24″ align=”center” class=”formText”><strong><a href=”<?php echo url_for(’playlist/index?page=’.$pager->getPreviousPage()); ?>” class=”Heading6″><</a></strong></td>

<?php $links = $pager->getLinks(); foreach ($links as $page): ?>
<td width=”9%” align=”center” valign=”middle” class=”formText”><?php echo ($page == $pager->getPage()) ? $page : link_to($page, ‘playlist/index?page=’.$page) ?>
</td>
<?php endforeach ?>

<td width=”13%” height=”24″ align=”center” valign=”middle” class=”formText”><a href=”<?php echo url_for(’playlist/index?page=’.$pager->getNextPage()); ?>”>></a></td>
<td width=”18%” height=”24″ align=”center” valign=”middle” class=”formText”><a href=”<?php echo url_for(’playlist/index?page=’.$pager->getLastPage()); ?>” class=”Heading6″>LAST</a></td>
</tr>
</table>
<?php endif ?>


Thats it the pagination is completed…..Please not that SYMFONY uses MVC architecture…..Any Doubts Mail Me To : balumohanv@gmail.comThis e-mail address is being protected from spam bots, you need JavaScript enabled to view it

VN:F [1.5.7_846]
Rating: 0.0/10 (0 votes cast)
VN:F [1.5.7_846]
Rating: 0 (from 0 votes)

Related posts:

  1. Get Method and Array Manipulation In Symfony
  2. Simple Pagination Using PHP Script
  3. Adding apache handlers in cpanel
  4. Get browser version and details using javascript
  5. File System Reference In PHP
  6. How to run a SQL query in phpMyAdmin
  7. “Header already sent” in php error and other use of Header function in PHP

Leave a Reply

Comments (required)

Spam Protected