Paging working but I need help to re-order it

I have a situation where a page was working fine but my boss has asked me to change it from a table based display to a div based display and at the same time, move away from having them in lines of three, to just one line per item.

Like I said its working, but for the life of me I cant get it to just line up neatly 1 by one down the page, can somebody help me with it please.

Here is the code that I havent touched as it seems to be doing what is needed.


$mPageSize = @$HTTP_POST_VARS["txtPageSize"];
if ((!isset($mPageSize))||intval($mPageSize)==0)
{
// $mPageSize = @$HTTP_GET_VARS["pagesize"];			
$mPageSize = $pagesize;
if ((!isset($mPageSize))||intval($mPageSize)==0)
$mPageSize = 9;
}

$mUrl = $PHP_SELF."?pagesize=".$mPageSize.$mConQry_Str;

//$mAbsolutePage = @$HTTP_GET_VARS["absolutepage"];
$mAbsolutePage = $absolutepage;

if (!isset($mAbsolutePage))
{    // Set $mOffset and absolutepage if not set
        $mAbsolutePage = 1;
    $mOffset = 0;
}  else {
   $mOffset = ( $mAbsolutePage - 1 ) * $mPageSize  ;
}

   $mResult = mysql_query($mQry) or ("Wrong Select Query");
//   $mResult = mysql_query($mQry) or die(mysql_error());


   $mRecordCount = mysql_num_rows($mResult);
   $mPageCount = intval($mRecordCount / $mPageSize);
   if ($mRecordCount % $mPageSize ) $mPageCount++;

   if ($mAbsolutePage>$mPageCount) $mAbsolutePage=$mPageCount;
   $mOffset = ( $mAbsolutePage - 1 ) * $mPageSize  ;

//}

if ($mRecordCount == 0)
{

}

if($mOffset<0)
{
$mOffset=0;
}

   $mQry .= " LIMIT $mOffset, $mPageSize ";   // Get record set = $mPageSize every time

   $mRes = mysql_query($mQry);

   //$mResult = mysql_query($mQry);

   if ($mAbsolutePage == 1)
   {
$mPag1 = $mAbsolutePage;
//echo $mAbsolutePage;
   }
   else
   {
        $mPag1 = (($mAbsolutePage - 1) * $mPageSize) + 1;
   }
   $mPag2 = $mPag1 + ($mPageSize - 1);
   if ($mPag2 > $mRecordCount)
   $mPag2 = $mRecordCount;
   //echo $mAbsolutePage;
//  Page Navigator code

$result=mysql_query($mQry) or die("Wrong Query");
$records=mysql_num_rows($result);

But below is the code that at one stage was all ordered in a table, which I ripped the code out to try and order it by div’s and instead of ordering itself 3 in a row, I wont it 1 per row(line).


<div style="position:relative; width:100%; background-color:#BF1E2E; top:-9px; padding-bottom:5px;">

<?
if(($i%0)==0 || $i==0 ){ ?>

<? for($j=3; $j<=$cnt; $j++) {
$morevalue=true;
$rows=mysql_fetch_assoc($result) or $morevalue=false;
?>

<? if($morevalue){
if(is_file("./foxglove/".$rows['foto1']))
{
imgresize("./foxglove/$rows[foto1]");
?>													
<a href="hotel.php?Id_Hot=<?=$rows['hotel_id']?>&amp;Id=<?=$hlist?>&amp;selectCountry=<?=$selectCountry?>&amp;selectRegion=<?=$rows['region_id']?>" class="bodySmall1"><img class="HomeFeaturedImages" src="./foxglove/<?=$rows['foto1']?>" alt="<?=$rows['hotel_name']?> - <?=$rows['country']?> Hotels &amp; Apartments" width="155" height="155" border="0" align="bottom" style="border:#fff solid 1px;"/></a>
<? }} ?>
<span style="color:#FFF; font-size:16px; font-weight:bold;">
<? if($morevalue){ ?>
<?=$rows['hotel_name']?>
<? } ?>
</span><br/>
<? if($morevalue){ ?>
<?php $int=strlen($rows['star_rating']);
if($int>0) { $k=0; while($k<$int) {  ?>
<img src='images/Red Star.png' alt="" width="8" height="9" border='0' />
<?php   $k++; } }  ?>
<? } ?>
<br/>
<span style="color:#F95A00; top:8px; position:relative; font-size:16px; font-weight:bold;">
<? if($morevalue){ ?>
<?=$rows['country']?>
<? } ?>
</span><br/>
<span>
<? if($morevalue){ ?><br/>
<a href="hotel.php?Id_Hot=<?=$rows['hotel_id']?>&amp;Id=<?=$hlist?>&amp;selectCountry=<?=$selectCountry?>&amp;selectRegion=<?=$rows['region_id']?>" style="color:#FFFFFF;">More Info</a>
<? } ?>
</span>
<? if($morevalue){ ?>
<? } ?>
<? if(($j==1||$j==2) && $morevalue) { ?>
<? } ?>
<? } ?>
<?
}
?>

</div>

     <? } ?>
    <? }  else { ?>

<p class="style6">
<?php
if($hlist==4 or $hlist==10 or $hlist==11 or $hlist==12 or $hlist==13 or $hlist==14){
?>
<span class="style9">Sorry, there are currently no VIA Cristal properties that match your search criteria.</span>
<?php
}else{
?>
<span class="style9">Sorry, there are currently no Hotels that match your search criteria.</span>
<?
}
?>
</p>

    <? } ?>

	<div align="center" style="background-image:url(images/result_Bottom_Orange.jpg); position:relative; width:960px; height:81px;" >
	<font face="tahoma" class="style5">
	<img src="images/Orange arrow.png" alt="Link Arrow" width="20" height="20" style="position:relative; margin-top:30px; vertical-align:bottom;" />
	<a href="index.php" style="color:#FFFFFF; text-decoration:none;">&nbsp;Back to search</a>
    <br/>
    <br/>
    <br/>
	</font>
	</div>

	</div>

I didnt write or design this stuff, this was given to me to sort out, but its all over the pkace and i cant get my head around it.

You have too many closing </div> tags. I could 2 open <div> tags and 3 closing </div> tags. Figure out which one doesn’t belong and it may help resolve it.

Also, if you can view-source after your script runs and provide the HTML output that is generated, it may help too, as you will quickly see where your HTML syntax is wrong/broken/invalid.

Hi cpradio,

Ye good tip with the view source, and have got it somewhere close now, but as you will see from the link below, there something wrong with the code in that it is for some reason duplicating the div but without any content in there.

http://www.room-check.com/result2.php?pagesize=9&hlist=0&selectCountry=0&selectRegion=0&ratings=0&hotname=&absolutepage=1


<div id="mainHomeResults">
<div style="position:relative; clear:both;">
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<?php if(!$mRecordCount == 0) { ?>
<tr> 
    <td class="bodySmall1">
	<table width="92%" border="0" align="left" cellpadding="0" cellspacing="0">
    <tr> 
    <td>
<div id="hotel_Title_Area_Result" style="position:relative; margin-bottom:15px; top:-1px;">
<div style="position:relative; float:right; width:150px; height:23px; margin-top:9px; color:#FFF; text-align:right; font-weight:normal; right:10px;">
<?=PagNav($mPageSize, $mPageCount, $mAbsolutePage, $mRecordCount, $mQry, $mUrl);?>
</div>
<div style="position:relative; float:right; width:250px; height:23px; margin-top:7px; color:#FFF; text-align:right; font-weight:normal; top:30px; left:140px;">
Records <?=$mPag1?> to <?=$mPag2?> (of <?=$mRecordCount?>)
</div>
</div>
	</td>
	</tr>
    </table>
	</td>
    </tr>
<? } ?>
<? 
if($records>0)
{ 
$cnt=$records+(4-$records%5);
/*was changed by lee too - $cnt=$records+(3-$records%5);*/
/*echo $records;*/
/*echo $cnt;*/
/*echo $mRecordCount;*/
$i=1;
for($i=1;$i<$cnt;$i++) 
{ ?>
</table>
</div>
<div style="position:relative; width:100%; background-color:#BF1E2E; top:-9px; padding-bottom:5px; height:auto;">
<? 
if(($i%0)==0 || $i==0 ){ ?>
<? for($j=1; $j<=$cnt; $j++) { 
$morevalue=true;
$rows=mysql_fetch_assoc($result) or $morevalue=false;
?>
<div style="position:relative; width:100%; height:auto; border:#FFF solid 1px; margin-bottom:20px;">	
<? if($morevalue){ 
if(is_file("./foxglove/".$rows['foto1']))
{
imgresize("./foxglove/$rows[foto1]");
?>
										  
<a href="hotel.php?Id_Hot=<?=$rows['hotel_id']?>&amp;Id=<?=$hlist?>&amp;selectCountry=<?=$selectCountry?>&amp;selectRegion=<?=$rows['region_id']?>" class="bodySmall1"><img class="HomeFeaturedImages" src="./foxglove/<?=$rows['foto1']?>" alt="<?=$rows['hotel_name']?> - <?=$rows['country']?> Hotels &amp; Apartments" width="155" height="155" border="0" align="bottom" style="border:#fff solid 1px;"/></a>
<? } } ?>

<span style="color:#FFF; font-size:16px; font-weight:bold;"> 
<? if($morevalue){ ?>
<?=$rows['hotel_name']?>
<? } ?>
</span>

<? if($morevalue){ ?>
<?php $int=strlen($rows['star_rating']); 
if($int>0) { $k=0; while($k<$int) {  ?>
<img src='images/Red Star.png' alt="" width="8" height="9" border='0' />
<?php   $k++; } }  ?>
<? } ?>

<span style="color:#F95A00; top:8px; position:relative; font-size:16px; font-weight:bold;"> 
<? if($morevalue){ ?>
<?=$rows['country']?>
<? } ?>
</span>

<? if($morevalue){ ?>
<a href="hotel.php?Id_Hot=<?=$rows['hotel_id']?>&amp;Id=<?=$hlist?>&amp;selectCountry=<?=$selectCountry?>&amp;selectRegion=<?=$rows['region_id']?>" style="color:#FFFFFF;">More Info</a> 
<? } ?>
</div>
<? } ?>
<? } ?>

<? } ?>
<? } else { 
if($hlist==4 or $hlist==10 or $hlist==11 or $hlist==12 or $hlist==13 or $hlist==14){
?>
	<p class="style6">
	<span class="style9">Sorry, there are currently no VIA Cristal properties that match your search criteria.</span>
	</p>
<?php } else { ?>
	<p class="style6">
	<span class="style9">Sorry, there are currently no Hotels that match your search criteria.</span>
	</p>
	<? } ?>
<? } ?>
</div>
</div>

<div align="center" style="background-image:url(images/result_Bottom_Orange.jpg); position:relative; width:960px; height:81px;" >
<font face="tahoma" class="style5">
<img src="images/Orange arrow.png" alt="Link Arrow" width="20" height="20" style="position:relative; margin-top:30px; vertical-align:bottom;" />
<a href="index.php" style="color:#FFFFFF; text-decoration:none;">&nbsp;Back to search</a>
</font>
</div>

<div id="footer" style="position:relative; margin-left:auto; margin-right:auto; margin-top:10px">
<h3 style="position:relative; margin-left:20px; top:15px; margin-bottom:32px;">Contact</h3>
<p style="position:relative; margin-left:20px; color:#FFFFFF; font-size:12px; line-height:12px;"></p>
<p style="position:relative; margin-left:20px; color:#FFFFFF; font-size:12px; line-height:12px;"></p>
<p style="position:relative; margin-left:20px; color:#FFFFFF; font-size:12px; line-height:12px;"><p>
</div>

I’d look at why you have two for loops doing the same thing:

for($i=1;$i<$cnt;$i++) 
{ ?>
</table>
</div>
<div style="position:relative; width:100%; background-color:#BF1E2E; top:-9px; padding-bottom:5px; height:auto;">
<? 
if(($i%0)==0 || $i==0 ){ ?>
<? for($j=1; $j<=$cnt; $j++) { 

Hi cpradio,

Thanks again mate, spot on and I had to change a few things around, but all is good and works well.

Thanks