s4salman Posted March 30, 2009 Share Posted March 30, 2009 I want to insert a 468x60 size banner after printing 2nd row using php. Currently 5 rows get printed on each page. Please help Following is the script: <?php class Pager { function getPagerData($numHits, $limit, $page) { $numHits = (int) $numHits; $limit = max((int) $limit, 1); $page = (int) $page; $numPages = ceil($numHits / $limit); $page = max($page, 1); $page = min($page, $numPages); $offset = ($page - 1) * $limit; $ret = new stdClass; $ret->offset = $offset; $ret->limit = $limit; $ret->numPages = $numPages; $ret->page = $page; return $ret; } } // get the pager input values $page = $_GET['page']; $limit = 15; $result = mysql_query("select count(*) from 3gp"); $total = mysql_result($result, 0, 0); // work out the pager values $pager = Pager::getPagerData($total, $limit, $page); $offset = $pager->offset; $limit = $pager->limit; $page = $pager->page; // use pager values to fetch data $query = "select * from 3gp order by id DESC limit $offset, $limit"; $result = mysql_query($query); // use $result here to output page content //my addition //grab all the content //Custom Table Stsrt// $cols = 3; //number of coloms $i =1; echo "<table border=\"1\" cellpadding=\"2\" cellspacing=\"2\" width=\"100%\" id=\"table1\" bordercolor=\"#E2E2E2\" bgcolor=\"#E2E2E2\">" ."<tr>"; while($r=mysql_fetch_array($result)) { //the format is $variable = $r["nameofmysqlcolumn"]; //modify these to match your mysql table columns $id=$r["id"]; $name=$r["name"]; $details=$r["details"]; $url=$r["url"]; $image=$r["image"]; $mirririmg=$r["mirrorimg"]; $mirror3gp=$r["mirror3gp"]; //display the row $mybox = "$name <br> <img src='$image' width =\"90\" height =\"90\"> <br> <a href='http://funxy.com/beta/3gp-download$id.html' class=\"classb\">Download This 3GP Video !</a> <br>"; if (is_int($i / $cols)){ echo "<td width='180' align='center' style=\"border-style: dotted; border-width: 1\">$mybox</td></tr><tr>"; }else{ echo "<td width='180' align='center' style=\"border-style: dotted; border-width: 1\">$mybox</td>"; } $i++; //end if }//end while echo "</tr></table>"; //Custom Table End// //ends my addition // output paging system (could also do it before we output the page content) if ($page == 1) // this is the first page - there is no previous page echo "Previous"; else // not the first page, link to the previous page echo "<a href=\"http://funxy.com/beta/3gp-videos-" . ($page - 1) . ".html\" id=\"navigationURL\">Previous</a>"; for ($i = 1; $i <= $pager->numPages; $i++) { echo " | "; if ($i == $pager->page) echo " $i"; else echo "<a href=\"http://funxy.com/beta/3gp-videos-$i.html\" id=\"navigationURL\"> $i</a>"; } if ($page == $pager->numPages) // this is the last page - there is no next page echo "Next"; else // not the last page, link to the next page echo " <a href=\"http://funxy.com/beta/3gp-videos-" . ($page + 1) . ".html\" id=\"navigationURL\">Next</a>"; ?> Link to comment https://forums.phpfreaks.com/topic/151713-solved-ads-after-2nd-row/ Share on other sites More sharing options...
sasa Posted March 30, 2009 Share Posted March 30, 2009 ... if (is_int($i / $cols)){ echo "<td width='180' align='center' style=\"border-style: dotted; border-width: 1\">$mybox</td></tr><tr>"; }else{ echo "<td width='180' align='center' style=\"border-style: dotted; border-width: 1\">$mybox</td>"; } if ( $i / $cols == 2) echo "<td colspan='3'>BANNER HERE</td></tr><tr>"; $i++; //end if Link to comment https://forums.phpfreaks.com/topic/151713-solved-ads-after-2nd-row/#findComment-796779 Share on other sites More sharing options...
s4salman Posted March 30, 2009 Author Share Posted March 30, 2009 thanks. now working perfect. Link to comment https://forums.phpfreaks.com/topic/151713-solved-ads-after-2nd-row/#findComment-796796 Share on other sites More sharing options...
ober Posted March 30, 2009 Share Posted March 30, 2009 Marking as solved. Link to comment https://forums.phpfreaks.com/topic/151713-solved-ads-after-2nd-row/#findComment-796803 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.