php - Looping total not same in database -
hello have script looping php, , each loop 4 data/row show ads.
but have problem.. because in database have data 123 row. in show in php 92 row/data :'(
this script
<?php include "connection.php"; $i=0; $data_school=mysql_query("select * school"); while ($school=mysql_fetch_object($data_school)) { if($i%4==0) { echo "<br/><a href='#'><img src='ads.jpg' alt=''></a><br/>"; } else { echo $school->name_school"<br/>"; } $i++; } ?>
when run in browser, , ads show school show "92 row/data"
if remove script
if($i%4==0) { echo "<br/><a href='#'><img src='ads.jpg' alt=''></a><br/>"; }
then script this
<?php include "connection.php"; $i=0; $data_school=mysql_query("select * school"); while ($school=mysql_fetch_object($data_school)) { echo $school->name_school"<br/>"; $i++; } ?>
this data show 123 row/data
help me, want this
school 1
school 2
school 3
school 4
#ads
school 5
school 6
school 7
school 8
#ads
help me, thank's
try this:
<?php include "connection.php"; $i=0; $data_school=mysql_query("select * school"); while ($school=mysql_fetch_object($data_school)) { if($i%4==0) { echo "<br/><a href='#'><img src='ads.jpg' alt=''></a><br/>"; } echo $school->name_school . "<br/>"; $i++; } ?>
you want echo school name every time
also why aren't getting errors on this:
echo $school->name_school"<br/>";