Jump to content


Photo

Help with centering paging in IE..


  • Please log in to reply
2 replies to this topic

#1 dannel77

dannel77
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 31 March 2006 - 09:09 AM

Hi,

I'm having a small problem with this paging script I'm using, it looks alright in Firefox but IE tilts it to the left, could anyone please tell me how to get it centered in Internet Explorer as well.. Pasting only the part of the script where (I guess) I need to make the changes:

// Hämta länk till förstasidan och föregående sida
if ($start > 0) {
$numlink = '<a href="?start=0&maingroup='.$maingroup.'&secondgroup='.$secondgroup.'">««</a> ';
$numlink .= '<a href="?start='.($start - $limit).'&maingroup='.$maingroup.'&secondgroup='.$secondgroup.'">«</a> ';
} else {
$numlink = '«« ';
$numlink .= '« ';
}

// Hämta sidonummer
for ($i = 1; $i <= $pages; $i++) {
$newoffset = $limit*($i-1);
if ($start == $newoffset)
$numlink .= '['.$i.'] ';
else
$numlink .= '<a href="?start='.$newoffset.'&maingroup='.$maingroup.'&secondgroup='.$secondgroup.'">'.$i.'</a> ';
}

// Hämta länk till nästa sida
if ($numrows > ($start + $limit))
$numlink .= '<a href="?start='.($start + $limit).'&maingroup='.$maingroup.'&secondgroup='.$secondgroup.'">»</a> ';
else
$numlink .= '» ';

// Hämta sista sidan
if ($start != $newoffset)
$numlink .= '<a href="?start='.$newoffset.'&maingroup='.$maingroup.'&secondgroup='.$secondgroup.'">»»</a> ';
else
$numlink .= '»» ';

Any help really appreciated! :)

#2 shortj75

shortj75
  • Members
  • PipPipPip
  • Advanced Member
  • 118 posts
  • LocationPort Huron,mi

Posted 01 April 2006 - 08:38 AM

put this at the top of your code
echo "<center>";
put this at the bottom of your code
echo "</center>";
and that should center you page
The Short One

hopfully this helps if it doesn't sorry
i won't write the code for you!!! you don't learn that way

#3 dannel77

dannel77
  • Members
  • PipPip
  • Member
  • 22 posts

Posted 01 April 2006 - 09:47 AM

Thanks alot man! I couldn't just cut and paste, but eventually it worked out.. Here is how it looks now:

&nbsp;<center>
<?php

// database connection
mysql_connect("$host","$user","$pass");

// database selection
mysql_select_db("$database");

// Nu bestämmer vi antal per sida och kollar vi upp totala antalet
$limit = 30; // Antal per sida
$result = @mysql_query("SELECT count(*) as count FROM products WHERE maingroup = '$maingroup' AND secondgroup = '$secondgroup'")

or die("Error fetching number in DB<br>".mysql_error());
$row = @mysql_fetch_array($result);
$numrows = $row['count']; // Antal i databasen

// Sedan kollar vi om startvariabeln är satt
if (!isset($_GET['start']) || $_GET['start'] == "")
$start = 0;
else
$start = $_GET['start'];

// Då räknar vi ut hur många sidor det blev
$pages = intval($numrows/$limit);
if ($numrows%$limit)
$pages++;

// Hämta länk till förstasidan och föregående sida
if ($start > 0) {
$numlink = '<a href="?start=0&maingroup='.$maingroup.'&secondgroup='.$secondgroup.'">««</a> ';
$numlink .= '<a href="?start='.($start - $limit).'&maingroup='.$maingroup.'&secondgroup='.$secondgroup.'">«</a> ';
} else {
$numlink = '«« ';
$numlink .= '« ';
}

// Hämta sidonummer
for ($i = 1; $i <= $pages; $i++) {
$newoffset = $limit*($i-1);
if ($start == $newoffset)
$numlink .= '['.$i.'] ';
else
$numlink .= '<a href="?start='.$newoffset.'&maingroup='.$maingroup.'&secondgroup='.$secondgroup.'">'.$i.'</a> ';
}

// Hämta länk till nästa sida
if ($numrows > ($start + $limit))
$numlink .= '<a href="?start='.($start + $limit).'&maingroup='.$maingroup.'&secondgroup='.$secondgroup.'">»</a> ';
else
$numlink .= '» ';

// Hämta sista sidan
if ($start != $newoffset)
$numlink .= '<a href="?start='.$newoffset.'&maingroup='.$maingroup.'&secondgroup='.$secondgroup.'">»»</a> ';
else
$numlink .= '»» ';

// Skriv ut sidorna
echo $numlink;

// Nu kan vi hämta datan från databasen och skriva ut den
$result = @mysql_query("SELECT * FROM products WHERE maingroup = '$maingroup' AND secondgroup = '$secondgroup' ORDER BY item ASC LIMIT $start, $limit")
or die("Error fetching data<br>".mysql_error());

while ($row = @mysql_fetch_array($result)){
$color = ($coloralternator++ %2 ? "D5E2EC" : "EBF1F5");
echo "<TR BGCOLOR=\"#$color\"><TD ALIGN=\"middle\"><a href=\"item_show.php?code_no=$row[2]\" TARGET=\"main\"><IMG SRC=\"thumbs/$row[6]\" BORDER=\"0\"></a></TD>";
echo "<TD ALIGN=\"left\"><font style=\"font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif;\"><a href=\"item_show.php?code_no=$row[2]\" TARGET=\"main\"> $row[2] </FONT></TD>";
echo "<TD ALIGN=\"left\"></a><font style=\"font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif;\"><a href=\"item_show.php?code_no=$row[2]\" TARGET=\"main\"> $row[3] </FONT></TD>";
echo "<TD ALIGN=\"right\"></a><font style=\"font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif;\"> $row[5] </font></TD>";
echo "<TD ALIGN=\"middle\"> <INPUT TYPE=\"hidden\" NAME=\"id$row[2]quant\" VALUE=\"1\">
<a href=\"Javascript:top.center.cart.addItem('$row[3]','$row[5]', document.itemsform.id$row[2]quant.value, '$row[2]', '$row[7]')\"><img src=\"images/buy.gif\" border=\"0\"></a> </TD></TR>";
}
"</center>"
?>




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users