s4salman Posted June 9, 2009 Share Posted June 9, 2009 Hi i want to ad 336x280 adsense banner code after 2nd row and 6th row. Currently this ad code displays 30 records from mysql , one at a row. Please help <?php if (!ini_get("register_globals")) { import_request_variables('GPC'); } //E?C?? ??I C?E? CEO E? $phpver = phpversion(); if ($phpver < '4.1.0') { $_GET = $HTTP_GET_VARS; $_POST = $HTTP_POST_VARS; $_SERVER = $HTTP_SERVER_VARS; } $phpver = explode(".", $phpver); $phpver = "$phpver[0]$phpver[1]"; if ($phpver >= 41) { $PHP_SELF = $_SERVER['PHP_SELF']; } $db="hesla_xone"; $c1 = mysql_connect("localhost","hesla_v2073","alpha123"); @mysql_select_db($db) or die( "Unable to select database, Please contact your administrator"); 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 = 30; $result = mysql_query("select count(*) from sms where cat_id='$cat_id'"); $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 sms where cat_id='$cat_id' order by id DESC limit $offset, $limit"; $result = mysql_query($query); // use $result here to output page content //my addition //grab all the content while($r=mysql_fetch_array($result)) { //the format is $variable = $r["nameofmysqlcolumn"]; //modify these to match your mysql table columns $id=$r["id"]; $cat_id=$r["cat_id"]; $name=$r["name"]; $sms=$r["sms"]; //display the row echo "<table border =\"2\" bordercolor=\"#C3C8CD\" cellspacing=\"8\" cellpadding=\"8\">"; while ( $row = mysql_fetch_array($result)) { $bgcolor = $bgcolor == "#FADF00" ? "#4760A2" : "#4760A2"; echo "<tr><td bgcolor=\"$bgcolor\">" . $row['sms'] . "</td></tr>"; //end if }//end while echo "</table>"; } // 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=\"sms.php?cat_id=$cat_id&page=" . ($page - 1) . "\" id=\"navigationURL\">Previous</a>"; for ($i = 1; $i <= $pager->numPages; $i++) { echo " | "; if ($i == $pager->page) echo " $i"; else echo "<a href=\"sms.php?cat_id=$cat_id&page=$i\" 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=\"sms.php?cat_id=$cat_id&page=" . ($page + 1) . "\" id=\"navigationURL\">Next</a>"; mysql_close($c1); ?> Link to comment https://forums.phpfreaks.com/topic/161485-adsense-after-2nd-rown-and-6th-row/ Share on other sites More sharing options...
phpdragon Posted June 9, 2009 Share Posted June 9, 2009 do a count in your while loop and advance it for each loop assigning it to a variable, then use an array to check if the count matches your specified rows numbers and if it does display your add. Link to comment https://forums.phpfreaks.com/topic/161485-adsense-after-2nd-rown-and-6th-row/#findComment-852160 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.