Alphanav Help Needed...

  • Brian Jester
  • Beginner
  • Beginner
  • Brian Jester
  • Posts: 61
  • Loc: Bayonne, New Jersey USA

Post 3+ Months Ago

Hi Everyone, and happy new year!

I have some working php code that displays an alphabetical navigation A-z index across the top of my website, but it's intented design is to open in a new window, but now I want it to open within the same page...I have found either an iframe or 'switch' would work fine, but I can't seem to get it working right.

Here's what I mean, a url to display the issue: http://reunitemysite.com/test2/login.php

When you click on any of the links in the top alphanav, the link displays the css as well as the mysql query result in the targeted iframe, all I want to display in the iframe is the mySQL query result, not the alphanav bar css itself.

index.php
Code: [ Select ]
<html>
<head> <title> </title>
<meta name="viewport" content="initial-scale=1.0">

<link rel="stylesheet" type="text/css" href="css/breadcrumb.css" media="screen" charset="utf-8" />
<link rel="stylesheet" type="text/css" href="css/default.css" media="screen" charset="utf-8" />
<link rel="stylesheet" type="text/css" href="css/menu.css" media="screen" charset="utf-8" />

</head>

<body>

<?php include('az.php'); ?>

<div class="drop-shadow lifted" id="header"><img src="/test2/images/logo.png" alt="Reunite My Site - Company Logo" title="Reunite My Site - Company Logo"> </div>

<div id="login">Login:&nbsp;<input type="username" class="login" size="20px;">
<br />
Password:&nbsp;<input class="login" type="password" size="20px">
<br />
Remember Me? <input type="checkbox">

<a href="#">Register Now For Free!</a>

<div class="note orange rounded">Start your Advertising or Publishing Campaign Now by simply clicking the Register Now button above!</div></div>

<?php


if($GET['frame'] == 1) {

//This creates the menu at the top A-Z 
  $char = $_GET['letter']; 
  $list="num"; 
  foreach (range('A', 'Z') as $i) $list.=",$i"; 
  $list.=",Show All Ads"; 
  $a = explode(',', $list); 
  foreach ($a as $b) { 
    if (!empty($b)) { 
      if ($b=="num") { 
        if ($char=="num") echo "<a href=\"az.php?letter=num\" target=\"target\" >#</a>"; 
        else echo "<a href=\"az.php?letter=num\" target=\"target\">#</a>"; 
      } 
      elseif ($b=="Show All Ads") { 
        if (($char=="*")||(empty($char))) echo "<a href=\"az.php?letter=*\" target=\"target\">Show All Ads</a>"; 
        else echo "<a href=\"az.php?letter=*\" target=\"target\">Show All Ads</a>"; 
      } 
      elseif($b==$char) echo "<a href=\"az.php?letter=".$b."\" target=\"target\">$b</a>"; 
      else echo "<a href=\"az.php?letter=".$b."\" target=\"target\">$b</a>"; 
    } 
  }

}

?>

<iframe name="frame">Sorry, you need the newest browser to display iframes!</iframe>

</body>
</html>
  1. <html>
  2. <head> <title> </title>
  3. <meta name="viewport" content="initial-scale=1.0">
  4. <link rel="stylesheet" type="text/css" href="css/breadcrumb.css" media="screen" charset="utf-8" />
  5. <link rel="stylesheet" type="text/css" href="css/default.css" media="screen" charset="utf-8" />
  6. <link rel="stylesheet" type="text/css" href="css/menu.css" media="screen" charset="utf-8" />
  7. </head>
  8. <body>
  9. <?php include('az.php'); ?>
  10. <div class="drop-shadow lifted" id="header"><img src="/test2/images/logo.png" alt="Reunite My Site - Company Logo" title="Reunite My Site - Company Logo"> </div>
  11. <div id="login">Login:&nbsp;<input type="username" class="login" size="20px;">
  12. <br />
  13. Password:&nbsp;<input class="login" type="password" size="20px">
  14. <br />
  15. Remember Me? <input type="checkbox">
  16. <a href="#">Register Now For Free!</a>
  17. <div class="note orange rounded">Start your Advertising or Publishing Campaign Now by simply clicking the Register Now button above!</div></div>
  18. <?php
  19. if($GET['frame'] == 1) {
  20. //This creates the menu at the top A-Z 
  21.   $char = $_GET['letter']; 
  22.   $list="num"; 
  23.   foreach (range('A', 'Z') as $i) $list.=",$i"; 
  24.   $list.=",Show All Ads"; 
  25.   $a = explode(',', $list); 
  26.   foreach ($a as $b) { 
  27.     if (!empty($b)) { 
  28.       if ($b=="num") { 
  29.         if ($char=="num") echo "<a href=\"az.php?letter=num\" target=\"target\" >#</a>"; 
  30.         else echo "<a href=\"az.php?letter=num\" target=\"target\">#</a>"; 
  31.       } 
  32.       elseif ($b=="Show All Ads") { 
  33.         if (($char=="*")||(empty($char))) echo "<a href=\"az.php?letter=*\" target=\"target\">Show All Ads</a>"; 
  34.         else echo "<a href=\"az.php?letter=*\" target=\"target\">Show All Ads</a>"; 
  35.       } 
  36.       elseif($b==$char) echo "<a href=\"az.php?letter=".$b."\" target=\"target\">$b</a>"; 
  37.       else echo "<a href=\"az.php?letter=".$b."\" target=\"target\">$b</a>"; 
  38.     } 
  39.   }
  40. }
  41. ?>
  42. <iframe name="frame">Sorry, you need the newest browser to display iframes!</iframe>
  43. </body>
  44. </html>


Code: [ Select ]
<?php
 
  // How many adjacent pages should be shown on each side? 
  $adjacents = 1; //This only applies to lists that are more then 8 pages (controls the ...'s not the list) 

  //how many items to show per page 
  $limit = 10; 

  //Number of ads per row
  $rows = 3;
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
<head> 
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> 

<title>A To Z AD Navigation </title> 

<style media="screen" type="text/css"> 

html, body { }

#aznavbar a:link { 
color: #0C7FB0;
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
margin-left: 4.15px;
padding: 10px; 
text-decoration:none; 

 
#aznavbar a:visited { 
color: #0C7FB0;
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px; 
text-decoration:none; 



#aznavbar a:hover {
background-color: #FA6405;
color:#000; 
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px; 
text-decoration:none; 



#aznavbar a:active{ 
color:#FA6405; 
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px; 
text-decoration:none; 
}

#aznavbar { 
 background: #141414;
 background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
 background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
 background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
 background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
 background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
 background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
 filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#32323a', EndColorStr='#141414', GradientType=0);
 border: 1px solid #000; 
 margin: -10px 0px 0px -8px;
 padding: 10 0px 10px 80px;
 width: 94.8%;
 } 

a:hover#showall { 


#ad-wrapper{ 
  margin:0px auto 0px auto; 
  text-align:center; 
}

</style> 
</head> 

<body> 


<div id="aznavbar" class="drop-shadow raised">


<?php 
  //This creates the menu at the top A-Z 
  $char = $_GET['letter']; 
  $list="num"; 
  foreach (range('A', 'Z') as $i) $list.=",$i"; 
  $list.=",Show All Ads"; 
  $a = explode(',', $list); 
  foreach ($a as $b) { 
    if (!empty($b)) { 
      if ($b=="num") { 
        if ($char=="num") echo "<a href=\"az.php?letter=num\" target=\"frame\">#</a>"; 
        else echo "<a href=\"az.php?letter=num\" target=\"frame\">#</a>"; 
      } 
      elseif ($b=="Show All Ads") { 
        if (($char=="*")||(empty($char))) echo "<a href=\"az.php?letter=*\" target=\"frame\">Show All Ads</a>"; 
        else echo "<a href=\"az.php?letter=*\" target=\"frame\">Show All Ads</a>"; 
      } 
      elseif($b==$char) echo "<a href=\"az.php?letter=".$b."\" target=\"frame\">$b</a>"; 
      else echo "<a href=\"az.php?letter=".$b."\" target=\"frame\">$b</a>"; 
    } 
  } 
?> 
</div>

<?php 
if(!empty($char)){
  include('connect.php'); 
  $tbl_name="amp_ads";    //your table name 
   
  /* 
    First get total number of rows in data table. 
    If you have a WHERE clause in your query, make sure you mirror it here. 
  */ 
  if((empty($char))||($char=="*")) $query = "SELECT COUNT(*) as num FROM $tbl_name"; 
  elseif($char=="num") $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title REGEXP '^[0-9]'"; 
  else $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title LIKE '$char%'"; 
  $total_pages = mysql_fetch_array(mysql_query($query)); 
  $total_pages = $total_pages[num]; 
   
  /* Setup vars for query. */ 
  if(!empty($char)) $targetpage = "az.php?letter=$char&"; 
  else $targetpage = "az.php?";   //your file name (the name of this file) 
  $page = $_GET['page']; 
  if($page) 
    $start = ($page - 1) * $limit;       //first item to display on this page 
  else 
    $start = 0;                //if no page var is given, set start to 0 
   
  /* Get data. */ 
  if($char=="*") $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit"; 
  elseif($char=="num") $sql = "SELECT * FROM $tbl_name WHERE title REGEXP '^[0-9]' LIMIT $start, $limit"; 
  else $sql = "SELECT * FROM $tbl_name WHERE title LIKE '$char%' LIMIT $start, $limit"; 
  $result = mysql_query($sql); 
   
  /* Setup page vars for display. */ 
  if ($page == 0) $page = 1;          //if no page var is given, default to 1. 
  $prev = $page - 1;              //previous page is page - 1 
  $next = $page + 1;              //next page is page + 1 
  $lastpage = ceil($total_pages/$limit);    //lastpage is = total pages / items per page, rounded up. 
  $lpm1 = $lastpage - 1;            //last page minus 1 
   
  /* 
    Now we apply our rules and draw the pagination object. 
    We're actually saving the code to a variable in case we want to draw it more than once. 
  */ 
  $pagination = ""; 
  if($lastpage > 1) 
  {   
    $pagination .= "<div class=\"pagination\">"; 
    //previous button 
    if ($page > 1) 
      $pagination.= "<a href=\"$targetpage"."page=$prev\">« previous </a>"; 
    else 
      $pagination.= "<span class=\"disabled\">« previous </span>";   
     
    //pages   
    if ($lastpage < 7 + ($adjacents * 2))  //not enough pages to bother breaking it up 
    {   
      for ($counter = 1; $counter <= $lastpage; $counter++) 
      { 
        if ($counter == $page) 
          $pagination.= "<span class=\"current\">$counter</span>"; 
        else 
          $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
      } 
    } 
    elseif($lastpage > 5 + ($adjacents * 2))  //enough pages to hide some 
    { 
      //close to beginning; only hide later pages 
      if($page < 1 + ($adjacents * 2))     
      { 
        for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) 
        { 
          if ($counter == $page) 
            $pagination.= "<span class=\"current\">$counter</span>"; 
          else 
            $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
        } 
        $pagination.= "..."; 
        $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>"; 
        $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";     
      } 
      //in middle; hide some front and some back 
      elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) 
      { 
        $pagination.= "<a href=\"$targetpage"."page=1\">1</a>"; 
        $pagination.= "<a href=\"$targetpage"."page=2\">2</a>"; 
        $pagination.= "..."; 
        for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) 
        { 
          if ($counter == $page) 
            $pagination.= "<span class=\"current\">$counter</span>"; 
          else 
            $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
        } 
        $pagination.= "..."; 
        $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>"; 
        $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";     
      } 
      //close to end; only hide early pages 
      else 
      { 
        $pagination.= "<a href=\"$targetpage"."page=1\">1</a>"; 
        $pagination.= "<a href=\"$targetpage"."page=2\">2</a>"; 
        $pagination.= "..."; 
        for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) 
        { 
          if ($counter == $page) 
            $pagination.= "<span class=\"current\">$counter</span>"; 
          else 
            $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
        } 
      } 
    } 
     
    //next button 
    if ($page < $counter - 1) 
      $pagination.= "<a href=\"$targetpage"."page=$next\"> next »</a>"; 
    else 
      $pagination.= "<span class=\"disabled\"> next »</span>"; 
    $pagination.= "</div>\n";     
  } 
?> 

  <?php 
    echo '<div id="ad-wrapper">'; 
    if($total_pages==0) echo "No Results for ".$char."!";
    else{
      $c = -1;
      while($row = mysql_fetch_array($result)) 
      { 
        if($c%$rows==$rows-1) echo "<br/>";
        echo "<a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"><p /> $row[alt]";
        $c++;
        $c++;
      } 
    }
}
  ?> 

<?php echo $pagination ?> 
</div></body> 
</html>
  1. <?php
  2.  
  3.   // How many adjacent pages should be shown on each side? 
  4.   $adjacents = 1; //This only applies to lists that are more then 8 pages (controls the ...'s not the list) 
  5.   //how many items to show per page 
  6.   $limit = 10; 
  7.   //Number of ads per row
  8.   $rows = 3;
  9. ?>
  10.  
  11. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd "> 
  12. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> 
  13. <head> 
  14. <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" /> 
  15. <title>A To Z AD Navigation </title> 
  16. <style media="screen" type="text/css"> 
  17. html, body { }
  18. #aznavbar a:link { 
  19. color: #0C7FB0;
  20. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  21. margin-left: 4.15px;
  22. padding: 10px; 
  23. text-decoration:none; 
  24.  
  25. #aznavbar a:visited { 
  26. color: #0C7FB0;
  27. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  28. padding: 10px; 
  29. text-decoration:none; 
  30. #aznavbar a:hover {
  31. background-color: #FA6405;
  32. color:#000; 
  33. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  34. padding: 10px; 
  35. text-decoration:none; 
  36. #aznavbar a:active{ 
  37. color:#FA6405; 
  38. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  39. padding: 10px; 
  40. text-decoration:none; 
  41. }
  42. #aznavbar { 
  43.  background: #141414;
  44.  background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
  45.  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
  46.  background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
  47.  background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
  48.  background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
  49.  background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
  50.  filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#32323a', EndColorStr='#141414', GradientType=0);
  51.  border: 1px solid #000; 
  52.  margin: -10px 0px 0px -8px;
  53.  padding: 10 0px 10px 80px;
  54.  width: 94.8%;
  55.  } 
  56. a:hover#showall { 
  57. #ad-wrapper{ 
  58.   margin:0px auto 0px auto; 
  59.   text-align:center; 
  60. }
  61. </style> 
  62. </head> 
  63. <body> 
  64. <div id="aznavbar" class="drop-shadow raised">
  65. <?php 
  66.   //This creates the menu at the top A-Z 
  67.   $char = $_GET['letter']; 
  68.   $list="num"; 
  69.   foreach (range('A', 'Z') as $i) $list.=",$i"; 
  70.   $list.=",Show All Ads"; 
  71.   $a = explode(',', $list); 
  72.   foreach ($a as $b) { 
  73.     if (!empty($b)) { 
  74.       if ($b=="num") { 
  75.         if ($char=="num") echo "<a href=\"az.php?letter=num\" target=\"frame\">#</a>"; 
  76.         else echo "<a href=\"az.php?letter=num\" target=\"frame\">#</a>"; 
  77.       } 
  78.       elseif ($b=="Show All Ads") { 
  79.         if (($char=="*")||(empty($char))) echo "<a href=\"az.php?letter=*\" target=\"frame\">Show All Ads</a>"; 
  80.         else echo "<a href=\"az.php?letter=*\" target=\"frame\">Show All Ads</a>"; 
  81.       } 
  82.       elseif($b==$char) echo "<a href=\"az.php?letter=".$b."\" target=\"frame\">$b</a>"; 
  83.       else echo "<a href=\"az.php?letter=".$b."\" target=\"frame\">$b</a>"; 
  84.     } 
  85.   } 
  86. ?> 
  87. </div>
  88. <?php 
  89. if(!empty($char)){
  90.   include('connect.php'); 
  91.   $tbl_name="amp_ads";    //your table name 
  92.    
  93.   /* 
  94.     First get total number of rows in data table. 
  95.     If you have a WHERE clause in your query, make sure you mirror it here. 
  96.   */ 
  97.   if((empty($char))||($char=="*")) $query = "SELECT COUNT(*) as num FROM $tbl_name"; 
  98.   elseif($char=="num") $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title REGEXP '^[0-9]'"; 
  99.   else $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title LIKE '$char%'"; 
  100.   $total_pages = mysql_fetch_array(mysql_query($query)); 
  101.   $total_pages = $total_pages[num]; 
  102.    
  103.   /* Setup vars for query. */ 
  104.   if(!empty($char)) $targetpage = "az.php?letter=$char&"; 
  105.   else $targetpage = "az.php?";   //your file name (the name of this file) 
  106.   $page = $_GET['page']; 
  107.   if($page) 
  108.     $start = ($page - 1) * $limit;       //first item to display on this page 
  109.   else 
  110.     $start = 0;                //if no page var is given, set start to 0 
  111.    
  112.   /* Get data. */ 
  113.   if($char=="*") $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit"; 
  114.   elseif($char=="num") $sql = "SELECT * FROM $tbl_name WHERE title REGEXP '^[0-9]' LIMIT $start, $limit"; 
  115.   else $sql = "SELECT * FROM $tbl_name WHERE title LIKE '$char%' LIMIT $start, $limit"; 
  116.   $result = mysql_query($sql); 
  117.    
  118.   /* Setup page vars for display. */ 
  119.   if ($page == 0) $page = 1;          //if no page var is given, default to 1. 
  120.   $prev = $page - 1;              //previous page is page - 1 
  121.   $next = $page + 1;              //next page is page + 1 
  122.   $lastpage = ceil($total_pages/$limit);    //lastpage is = total pages / items per page, rounded up. 
  123.   $lpm1 = $lastpage - 1;            //last page minus 1 
  124.    
  125.   /* 
  126.     Now we apply our rules and draw the pagination object. 
  127.     We're actually saving the code to a variable in case we want to draw it more than once. 
  128.   */ 
  129.   $pagination = ""; 
  130.   if($lastpage > 1) 
  131.   {   
  132.     $pagination .= "<div class=\"pagination\">"; 
  133.     //previous button 
  134.     if ($page > 1) 
  135.       $pagination.= "<a href=\"$targetpage"."page=$prev\">« previous </a>"; 
  136.     else 
  137.       $pagination.= "<span class=\"disabled\">« previous </span>";   
  138.      
  139.     //pages   
  140.     if ($lastpage < 7 + ($adjacents * 2))  //not enough pages to bother breaking it up 
  141.     {   
  142.       for ($counter = 1; $counter <= $lastpage; $counter++) 
  143.       { 
  144.         if ($counter == $page) 
  145.           $pagination.= "<span class=\"current\">$counter</span>"; 
  146.         else 
  147.           $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
  148.       } 
  149.     } 
  150.     elseif($lastpage > 5 + ($adjacents * 2))  //enough pages to hide some 
  151.     { 
  152.       //close to beginning; only hide later pages 
  153.       if($page < 1 + ($adjacents * 2))     
  154.       { 
  155.         for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) 
  156.         { 
  157.           if ($counter == $page) 
  158.             $pagination.= "<span class=\"current\">$counter</span>"; 
  159.           else 
  160.             $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
  161.         } 
  162.         $pagination.= "..."; 
  163.         $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>"; 
  164.         $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";     
  165.       } 
  166.       //in middle; hide some front and some back 
  167.       elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) 
  168.       { 
  169.         $pagination.= "<a href=\"$targetpage"."page=1\">1</a>"; 
  170.         $pagination.= "<a href=\"$targetpage"."page=2\">2</a>"; 
  171.         $pagination.= "..."; 
  172.         for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) 
  173.         { 
  174.           if ($counter == $page) 
  175.             $pagination.= "<span class=\"current\">$counter</span>"; 
  176.           else 
  177.             $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
  178.         } 
  179.         $pagination.= "..."; 
  180.         $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>"; 
  181.         $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";     
  182.       } 
  183.       //close to end; only hide early pages 
  184.       else 
  185.       { 
  186.         $pagination.= "<a href=\"$targetpage"."page=1\">1</a>"; 
  187.         $pagination.= "<a href=\"$targetpage"."page=2\">2</a>"; 
  188.         $pagination.= "..."; 
  189.         for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) 
  190.         { 
  191.           if ($counter == $page) 
  192.             $pagination.= "<span class=\"current\">$counter</span>"; 
  193.           else 
  194.             $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
  195.         } 
  196.       } 
  197.     } 
  198.      
  199.     //next button 
  200.     if ($page < $counter - 1) 
  201.       $pagination.= "<a href=\"$targetpage"."page=$next\"> next »</a>"; 
  202.     else 
  203.       $pagination.= "<span class=\"disabled\"> next »</span>"; 
  204.     $pagination.= "</div>\n";     
  205.   } 
  206. ?> 
  207.   <?php 
  208.     echo '<div id="ad-wrapper">'; 
  209.     if($total_pages==0) echo "No Results for ".$char."!";
  210.     else{
  211.       $c = -1;
  212.       while($row = mysql_fetch_array($result)) 
  213.       { 
  214.         if($c%$rows==$rows-1) echo "<br/>";
  215.         echo "<a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"><p /> $row[alt]";
  216.         $c++;
  217.         $c++;
  218.       } 
  219.     }
  220. }
  221.   ?> 
  222. <?php echo $pagination ?> 
  223. </div></body> 
  224. </html>


Note: The two php pages above work fine except for the fact that the links in the first block of code, which is the included php alphabet naviation (include az.php) the second block of code is where the code block needs to be modified -- right under the body tag in the second block of code, but I am clueless as to what needs to be changed.

I have been waiting so long for a fix to this, I hate to tell how long... :oops:

Thank you in advance!
Brian
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

do you need to get rid of the "opening in a new page" all together? if so in the code that builds the links remove to target parameter. Below is the code you provided without the target parameter. UNTESTED

index.php
PHP Code: [ Select ]
<html>
<head> <title> </title>
<meta name="viewport" content="initial-scale=1.0">
 
<link rel="stylesheet" type="text/css" href="css/breadcrumb.css" media="screen" charset="utf-8" />
<link rel="stylesheet" type="text/css" href="css/default.css" media="screen" charset="utf-8" />
<link rel="stylesheet" type="text/css" href="css/menu.css" media="screen" charset="utf-8" />
 
</head>
 
<body>
 
<?php include('az.php'); ?>
 
<div class="drop-shadow lifted" id="header"><img src="/test2/images/logo.png" alt="Reunite My Site - Company Logo" title="Reunite My Site - Company Logo"> </div>
 
<div id="login">Login:&nbsp;<input type="username" class="login" size="20px;">
<br />
Password:&nbsp;<input class="login" type="password" size="20px">
<br />
Remember Me? <input type="checkbox">
 
<a href="#">Register Now For Free!</a>
 
<div class="note orange rounded">Start your Advertising or Publishing Campaign Now by simply clicking the Register Now button above!</div></div>
 
<?php
 
 
if($GET['frame'] == 1) {
 
//This creates the menu at the top A-Z  
    $char = $_GET['letter'];  
    $list="num";  
    foreach (range('A', 'Z') as $i) $list.=",$i";  
    $list.=",Show All Ads";  
    $a = explode(',', $list);  
    foreach ($a as $b) {  
        if (!empty($b)) {  
            if ($b=="num") {  
                if ($char=="num") echo "<a href=\"az.php?letter=num\">#</a>";  
                else echo "<a href=\"az.php?letter=num\">#</a>";  
            }  
            elseif ($b=="Show All Ads") {  
                if (($char=="*")||(empty($char))) echo "<a href=\"az.php?letter=*\">Show All Ads</a>";  
                else echo "<a href=\"az.php?letter=*\">Show All Ads</a>";  
            }  
            elseif($b==$char) echo "<a href=\"az.php?letter=".$b."\">$b</a>";  
            else echo "<a href=\"az.php?letter=".$b."\">$b</a>";  
        }  
    }
 
}
 
?>
 
<iframe name="frame">Sorry, you need the newest browser to display iframes!</iframe>
 
</body>
</html>
 
  1. <html>
  2. <head> <title> </title>
  3. <meta name="viewport" content="initial-scale=1.0">
  4.  
  5. <link rel="stylesheet" type="text/css" href="css/breadcrumb.css" media="screen" charset="utf-8" />
  6. <link rel="stylesheet" type="text/css" href="css/default.css" media="screen" charset="utf-8" />
  7. <link rel="stylesheet" type="text/css" href="css/menu.css" media="screen" charset="utf-8" />
  8.  
  9. </head>
  10.  
  11. <body>
  12.  
  13. <?php include('az.php'); ?>
  14.  
  15. <div class="drop-shadow lifted" id="header"><img src="/test2/images/logo.png" alt="Reunite My Site - Company Logo" title="Reunite My Site - Company Logo"> </div>
  16.  
  17. <div id="login">Login:&nbsp;<input type="username" class="login" size="20px;">
  18. <br />
  19. Password:&nbsp;<input class="login" type="password" size="20px">
  20. <br />
  21. Remember Me? <input type="checkbox">
  22.  
  23. <a href="#">Register Now For Free!</a>
  24.  
  25. <div class="note orange rounded">Start your Advertising or Publishing Campaign Now by simply clicking the Register Now button above!</div></div>
  26.  
  27. <?php
  28.  
  29.  
  30. if($GET['frame'] == 1) {
  31.  
  32. //This creates the menu at the top A-Z  
  33.     $char = $_GET['letter'];  
  34.     $list="num";  
  35.     foreach (range('A', 'Z') as $i) $list.=",$i";  
  36.     $list.=",Show All Ads";  
  37.     $a = explode(',', $list);  
  38.     foreach ($a as $b) {  
  39.         if (!empty($b)) {  
  40.             if ($b=="num") {  
  41.                 if ($char=="num") echo "<a href=\"az.php?letter=num\">#</a>";  
  42.                 else echo "<a href=\"az.php?letter=num\">#</a>";  
  43.             }  
  44.             elseif ($b=="Show All Ads") {  
  45.                 if (($char=="*")||(empty($char))) echo "<a href=\"az.php?letter=*\">Show All Ads</a>";  
  46.                 else echo "<a href=\"az.php?letter=*\">Show All Ads</a>";  
  47.             }  
  48.             elseif($b==$char) echo "<a href=\"az.php?letter=".$b."\">$b</a>";  
  49.             else echo "<a href=\"az.php?letter=".$b."\">$b</a>";  
  50.         }  
  51.     }
  52.  
  53. }
  54.  
  55. ?>
  56.  
  57. <iframe name="frame">Sorry, you need the newest browser to display iframes!</iframe>
  58.  
  59. </body>
  60. </html>
  61.  



and I'm assuming az.php
PHP Code: [ Select ]
<?php
 
    // How many adjacent pages should be shown on each side?  
    $adjacents = 1; //This only applies to lists that are more then 8 pages (controls the ...'s not the list)  
 
    //how many items to show per page  
    $limit = 10;  
 
    //Number of ads per row
    $rows = 3;
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
<head>  
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />  
 
<title>A To Z AD Navigation </title>  
 
<style media="screen" type="text/css">  
 
html, body { }
 
#aznavbar a:link {  
color: #0C7FB0;
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
margin-left: 4.15px;
padding: 10px;  
text-decoration:none;  
}  
   
#aznavbar a:visited {  
color: #0C7FB0;
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px;  
text-decoration:none;  
}  
 
 
#aznavbar a:hover {
background-color: #FA6405;
color:#000;  
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px;  
text-decoration:none;  
}  
 
 
#aznavbar a:active{  
color:#FA6405;  
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px;  
text-decoration:none;  
}
 
#aznavbar {  
  background: #141414;
  background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
  background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
  background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
  background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
  background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
  filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#32323a', EndColorStr='#141414', GradientType=0);
  border: 1px solid #000;  
  margin: -10px 0px 0px -8px;
  padding: 10 0px 10px 80px;
  width: 94.8%;
  }  
 
a:hover#showall {  
}  
 
#ad-wrapper{  
    margin:0px auto 0px auto;  
    text-align:center;  
}
 
</style>  
</head>  
 
<body>  
 
 
<div id="aznavbar" class="drop-shadow raised">
 
 
<?php  
    //This creates the menu at the top A-Z  
    $char = $_GET['letter'];  
    $list="num";  
    foreach (range('A', 'Z') as $i) $list.=",$i";  
    $list.=",Show All Ads";  
    $a = explode(',', $list);  
    foreach ($a as $b) {  
        if (!empty($b)) {  
            if ($b=="num") {  
                if ($char=="num") echo "<a href=\"az.php?letter=num\">#</a>";  
                else echo "<a href=\"az.php?letter=num\">#</a>";  
            }  
            elseif ($b=="Show All Ads") {  
                if (($char=="*")||(empty($char))) echo "<a href=\"az.php?letter=*\">Show All Ads</a>";  
                else echo "<a href=\"az.php?letter=*\">Show All Ads</a>";  
            }  
            elseif($b==$char) echo "<a href=\"az.php?letter=".$b."\">$b</a>";  
            else echo "<a href=\"az.php?letter=".$b."\">$b</a>";  
        }  
    }  
?>  
</div>
 
<?php  
if(!empty($char)){
    include('connect.php');  
    $tbl_name="amp_ads";        //your table name  
     
    /*  
       First get total number of rows in data table.  
       If you have a WHERE clause in your query, make sure you mirror it here.  
    */  
    if((empty($char))||($char=="*")) $query = "SELECT COUNT(*) as num FROM $tbl_name";  
    elseif($char=="num") $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title REGEXP '^[0-9]'";  
    else $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title LIKE '$char%'";  
    $total_pages = mysql_fetch_array(mysql_query($query));  
    $total_pages = $total_pages[num];  
     
    /* Setup vars for query. */  
    if(!empty($char)) $targetpage = "az.php?letter=$char&";  
    else $targetpage = "az.php?";     //your file name  (the name of this file)  
    $page = $_GET['page'];  
    if($page)  
        $start = ($page - 1) * $limit;             //first item to display on this page  
    else  
        $start = 0;                                //if no page var is given, set start to 0  
     
    /* Get data. */  
    if($char=="*") $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit";  
    elseif($char=="num") $sql = "SELECT * FROM $tbl_name WHERE title REGEXP '^[0-9]' LIMIT $start, $limit";  
    else $sql = "SELECT * FROM $tbl_name  WHERE title LIKE '$char%' LIMIT $start, $limit";  
    $result = mysql_query($sql);  
     
    /* Setup page vars for display. */  
    if ($page == 0) $page = 1;                    //if no page var is given, default to 1.  
    $prev = $page - 1;                            //previous page is page - 1  
    $next = $page + 1;                            //next page is page + 1  
    $lastpage = ceil($total_pages/$limit);        //lastpage is = total pages / items per page, rounded up.  
    $lpm1 = $lastpage - 1;                        //last page minus 1  
     
    /*  
        Now we apply our rules and draw the pagination object.  
        We're actually saving the code to a variable in case we want to draw it more than once.  
    */  
    $pagination = "";  
    if($lastpage > 1)  
    {      
        $pagination .= "<div class=\"pagination\">";  
        //previous button  
        if ($page > 1)  
            $pagination.= "<a href=\"$targetpage"."page=$prev\">« previous </a>";  
        else  
            $pagination.= "<span class=\"disabled\">« previous </span>";      
         
        //pages      
        if ($lastpage < 7 + ($adjacents * 2))    //not enough pages to bother breaking it up  
        {      
            for ($counter = 1; $counter <= $lastpage; $counter++)  
            {  
                if ($counter == $page)  
                    $pagination.= "<span class=\"current\">$counter</span>";  
                else  
                    $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
            }  
        }  
        elseif($lastpage > 5 + ($adjacents * 2))    //enough pages to hide some  
        {  
            //close to beginning; only hide later pages  
            if($page < 1 + ($adjacents * 2))          
            {  
                for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)  
                {  
                    if ($counter == $page)  
                        $pagination.= "<span class=\"current\">$counter</span>";  
                    else  
                        $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
                }  
                $pagination.= "...";  
                $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>";  
                $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";          
            }  
            //in middle; hide some front and some back  
            elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))  
            {  
                $pagination.= "<a href=\"$targetpage"."page=1\">1</a>";  
                $pagination.= "<a href=\"$targetpage"."page=2\">2</a>";  
                $pagination.= "...";  
                for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)  
                {  
                    if ($counter == $page)  
                        $pagination.= "<span class=\"current\">$counter</span>";  
                    else  
                        $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
                }  
                $pagination.= "...";  
                $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>";  
                $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";          
            }  
            //close to end; only hide early pages  
            else  
            {  
                $pagination.= "<a href=\"$targetpage"."page=1\">1</a>";  
                $pagination.= "<a href=\"$targetpage"."page=2\">2</a>";  
                $pagination.= "...";  
                for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)  
                {  
                    if ($counter == $page)  
                        $pagination.= "<span class=\"current\">$counter</span>";  
                    else  
                        $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
                }  
            }  
        }  
         
        //next button  
        if ($page < $counter - 1)  
            $pagination.= "<a href=\"$targetpage"."page=$next\"> next »</a>";  
        else  
            $pagination.= "<span class=\"disabled\"> next »</span>";  
        $pagination.= "</div>\n";          
    }  
?>  
 
    <?php  
        echo '<div id="ad-wrapper">';  
        if($total_pages==0) echo "No Results for ".$char."!";
        else{
            $c = -1;
            while($row = mysql_fetch_array($result))  
            {  
                if($c%$rows==$rows-1) echo "<br/>";
                echo "<a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"><p /> $row[alt]";
                $c++;
                $c++;
            }  
        }
}
    ?>  
 
<?php echo $pagination ?>  
</div></body>  
</html>
 
  1. <?php
  2.  
  3.     // How many adjacent pages should be shown on each side?  
  4.     $adjacents = 1; //This only applies to lists that are more then 8 pages (controls the ...'s not the list)  
  5.  
  6.     //how many items to show per page  
  7.     $limit = 10;  
  8.  
  9.     //Number of ads per row
  10.     $rows = 3;
  11. ?>
  12.  
  13. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  
  14. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
  15. <head>  
  16. <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />  
  17.  
  18. <title>A To Z AD Navigation </title>  
  19.  
  20. <style media="screen" type="text/css">  
  21.  
  22. html, body { }
  23.  
  24. #aznavbar a:link {  
  25. color: #0C7FB0;
  26. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  27. margin-left: 4.15px;
  28. padding: 10px;  
  29. text-decoration:none;  
  30. }  
  31.    
  32. #aznavbar a:visited {  
  33. color: #0C7FB0;
  34. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  35. padding: 10px;  
  36. text-decoration:none;  
  37. }  
  38.  
  39.  
  40. #aznavbar a:hover {
  41. background-color: #FA6405;
  42. color:#000;  
  43. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  44. padding: 10px;  
  45. text-decoration:none;  
  46. }  
  47.  
  48.  
  49. #aznavbar a:active{  
  50. color:#FA6405;  
  51. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  52. padding: 10px;  
  53. text-decoration:none;  
  54. }
  55.  
  56. #aznavbar {  
  57.   background: #141414;
  58.   background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
  59.   background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
  60.   background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
  61.   background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
  62.   background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
  63.   background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
  64.   filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#32323a', EndColorStr='#141414', GradientType=0);
  65.   border: 1px solid #000;  
  66.   margin: -10px 0px 0px -8px;
  67.   padding: 10 0px 10px 80px;
  68.   width: 94.8%;
  69.   }  
  70.  
  71. a:hover#showall {  
  72. }  
  73.  
  74. #ad-wrapper{  
  75.     margin:0px auto 0px auto;  
  76.     text-align:center;  
  77. }
  78.  
  79. </style>  
  80. </head>  
  81.  
  82. <body>  
  83.  
  84.  
  85. <div id="aznavbar" class="drop-shadow raised">
  86.  
  87.  
  88. <?php  
  89.     //This creates the menu at the top A-Z  
  90.     $char = $_GET['letter'];  
  91.     $list="num";  
  92.     foreach (range('A', 'Z') as $i) $list.=",$i";  
  93.     $list.=",Show All Ads";  
  94.     $a = explode(',', $list);  
  95.     foreach ($a as $b) {  
  96.         if (!empty($b)) {  
  97.             if ($b=="num") {  
  98.                 if ($char=="num") echo "<a href=\"az.php?letter=num\">#</a>";  
  99.                 else echo "<a href=\"az.php?letter=num\">#</a>";  
  100.             }  
  101.             elseif ($b=="Show All Ads") {  
  102.                 if (($char=="*")||(empty($char))) echo "<a href=\"az.php?letter=*\">Show All Ads</a>";  
  103.                 else echo "<a href=\"az.php?letter=*\">Show All Ads</a>";  
  104.             }  
  105.             elseif($b==$char) echo "<a href=\"az.php?letter=".$b."\">$b</a>";  
  106.             else echo "<a href=\"az.php?letter=".$b."\">$b</a>";  
  107.         }  
  108.     }  
  109. ?>  
  110. </div>
  111.  
  112. <?php  
  113. if(!empty($char)){
  114.     include('connect.php');  
  115.     $tbl_name="amp_ads";        //your table name  
  116.      
  117.     /*  
  118.        First get total number of rows in data table.  
  119.        If you have a WHERE clause in your query, make sure you mirror it here.  
  120.     */  
  121.     if((empty($char))||($char=="*")) $query = "SELECT COUNT(*) as num FROM $tbl_name";  
  122.     elseif($char=="num") $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title REGEXP '^[0-9]'";  
  123.     else $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title LIKE '$char%'";  
  124.     $total_pages = mysql_fetch_array(mysql_query($query));  
  125.     $total_pages = $total_pages[num];  
  126.      
  127.     /* Setup vars for query. */  
  128.     if(!empty($char)) $targetpage = "az.php?letter=$char&";  
  129.     else $targetpage = "az.php?";     //your file name  (the name of this file)  
  130.     $page = $_GET['page'];  
  131.     if($page)  
  132.         $start = ($page - 1) * $limit;             //first item to display on this page  
  133.     else  
  134.         $start = 0;                                //if no page var is given, set start to 0  
  135.      
  136.     /* Get data. */  
  137.     if($char=="*") $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit";  
  138.     elseif($char=="num") $sql = "SELECT * FROM $tbl_name WHERE title REGEXP '^[0-9]' LIMIT $start, $limit";  
  139.     else $sql = "SELECT * FROM $tbl_name  WHERE title LIKE '$char%' LIMIT $start, $limit";  
  140.     $result = mysql_query($sql);  
  141.      
  142.     /* Setup page vars for display. */  
  143.     if ($page == 0) $page = 1;                    //if no page var is given, default to 1.  
  144.     $prev = $page - 1;                            //previous page is page - 1  
  145.     $next = $page + 1;                            //next page is page + 1  
  146.     $lastpage = ceil($total_pages/$limit);        //lastpage is = total pages / items per page, rounded up.  
  147.     $lpm1 = $lastpage - 1;                        //last page minus 1  
  148.      
  149.     /*  
  150.         Now we apply our rules and draw the pagination object.  
  151.         We're actually saving the code to a variable in case we want to draw it more than once.  
  152.     */  
  153.     $pagination = "";  
  154.     if($lastpage > 1)  
  155.     {      
  156.         $pagination .= "<div class=\"pagination\">";  
  157.         //previous button  
  158.         if ($page > 1)  
  159.             $pagination.= "<a href=\"$targetpage"."page=$prev\">« previous </a>";  
  160.         else  
  161.             $pagination.= "<span class=\"disabled\">« previous </span>";      
  162.          
  163.         //pages      
  164.         if ($lastpage < 7 + ($adjacents * 2))    //not enough pages to bother breaking it up  
  165.         {      
  166.             for ($counter = 1; $counter <= $lastpage; $counter++)  
  167.             {  
  168.                 if ($counter == $page)  
  169.                     $pagination.= "<span class=\"current\">$counter</span>";  
  170.                 else  
  171.                     $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
  172.             }  
  173.         }  
  174.         elseif($lastpage > 5 + ($adjacents * 2))    //enough pages to hide some  
  175.         {  
  176.             //close to beginning; only hide later pages  
  177.             if($page < 1 + ($adjacents * 2))          
  178.             {  
  179.                 for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)  
  180.                 {  
  181.                     if ($counter == $page)  
  182.                         $pagination.= "<span class=\"current\">$counter</span>";  
  183.                     else  
  184.                         $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
  185.                 }  
  186.                 $pagination.= "...";  
  187.                 $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>";  
  188.                 $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";          
  189.             }  
  190.             //in middle; hide some front and some back  
  191.             elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))  
  192.             {  
  193.                 $pagination.= "<a href=\"$targetpage"."page=1\">1</a>";  
  194.                 $pagination.= "<a href=\"$targetpage"."page=2\">2</a>";  
  195.                 $pagination.= "...";  
  196.                 for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)  
  197.                 {  
  198.                     if ($counter == $page)  
  199.                         $pagination.= "<span class=\"current\">$counter</span>";  
  200.                     else  
  201.                         $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
  202.                 }  
  203.                 $pagination.= "...";  
  204.                 $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>";  
  205.                 $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";          
  206.             }  
  207.             //close to end; only hide early pages  
  208.             else  
  209.             {  
  210.                 $pagination.= "<a href=\"$targetpage"."page=1\">1</a>";  
  211.                 $pagination.= "<a href=\"$targetpage"."page=2\">2</a>";  
  212.                 $pagination.= "...";  
  213.                 for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)  
  214.                 {  
  215.                     if ($counter == $page)  
  216.                         $pagination.= "<span class=\"current\">$counter</span>";  
  217.                     else  
  218.                         $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
  219.                 }  
  220.             }  
  221.         }  
  222.          
  223.         //next button  
  224.         if ($page < $counter - 1)  
  225.             $pagination.= "<a href=\"$targetpage"."page=$next\"> next »</a>";  
  226.         else  
  227.             $pagination.= "<span class=\"disabled\"> next »</span>";  
  228.         $pagination.= "</div>\n";          
  229.     }  
  230. ?>  
  231.  
  232.     <?php  
  233.         echo '<div id="ad-wrapper">';  
  234.         if($total_pages==0) echo "No Results for ".$char."!";
  235.         else{
  236.             $c = -1;
  237.             while($row = mysql_fetch_array($result))  
  238.             {  
  239.                 if($c%$rows==$rows-1) echo "<br/>";
  240.                 echo "<a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"><p /> $row[alt]";
  241.                 $c++;
  242.                 $c++;
  243.             }  
  244.         }
  245. }
  246.     ?>  
  247.  
  248. <?php echo $pagination ?>  
  249. </div></body>  
  250. </html>
  251.  
  • Brian Jester
  • Beginner
  • Beginner
  • Brian Jester
  • Posts: 61
  • Loc: Bayonne, New Jersey USA

Post 3+ Months Ago

Code still does the same thing...I have put the target="frame" part into the az.php page in the links located in this area:

Quote:
//This creates the menu at the top A-Z


and when I click on the links in the az navbar, I am still getting the css part (#, a-z, show all links) in the iframe, I don't want that, JUST the MySQL results part...

I *think* (unless I am over thinking this whole thing) the part that creates the az menu (links) in the az.php page needs to be removed, and I would need to create a whole new navbar (basically in html and css, no php) in the index.php page, but the rest of the code in the az.php would need to be updated to reflect those changes.

Hope you understand!
Thanks again!
Brian
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

Maybe i don't understand what your trying to accomplish. i ran the code i put in my last post and besides the mysql errors (since i don't have that part of the code) it opened the az.php in the same window as index (total page switch).


Are you trying to target just the iframe with the navigation and load just the results into the iframe?
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

If that is the case however using the same page to do the result set and the navigation is going to give you a headache. Split them up into two different files.

index.php
PHP Code: [ Select ]
<html>
<head> <title> </title>
<meta name="viewport" content="initial-scale=1.0">
 
<link rel="stylesheet" type="text/css" href="css/breadcrumb.css" media="screen" charset="utf-8" />
<link rel="stylesheet" type="text/css" href="css/default.css" media="screen" charset="utf-8" />
<link rel="stylesheet" type="text/css" href="css/menu.css" media="screen" charset="utf-8" />
<style media="screen" type="text/css">  
 
html, body { }
 
#aznavbar a:link {  
color: #0C7FB0;
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
margin-left: 4.15px;
padding: 10px;  
text-decoration:none;  
}  
   
#aznavbar a:visited {  
color: #0C7FB0;
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px;  
text-decoration:none;  
}  
 
 
#aznavbar a:hover {
background-color: #FA6405;
color:#000;  
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px;  
text-decoration:none;  
}  
 
 
#aznavbar a:active{  
color:#FA6405;  
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px;  
text-decoration:none;  
}
 
#aznavbar {  
  background: #141414;
  background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
  background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
  background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
  background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
  background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
  filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#32323a', EndColorStr='#141414', GradientType=0);
  border: 1px solid #000;  
  margin: -10px 0px 0px -8px;
  padding: 10 0px 10px 80px;
  width: 94.8%;
  }  
 
a:hover#showall {  
}  
 
#ad-wrapper{  
    margin:0px auto 0px auto;  
    text-align:center;  
}
 
</style>  
</head>
 
<body>
 
<?php include('az.php'); ?>
 
<div class="drop-shadow lifted" id="header"><img src="/test2/images/logo.png" alt="Reunite My Site - Company Logo" title="Reunite My Site - Company Logo"> </div>
 
<div id="login">Login:&nbsp;<input type="username" class="login" size="20px;">
<br />
Password:&nbsp;<input class="login" type="password" size="20px">
<br />
Remember Me? <input type="checkbox">
 
<a href="#">Register Now For Free!</a>
 
<div class="note orange rounded">Start your Advertising or Publishing Campaign Now by simply clicking the Register Now button above!</div></div>
 
<iframe name="frame">Sorry, you need the newest browser to display iframes!</iframe>
 
</body>
</html>
 
  1. <html>
  2. <head> <title> </title>
  3. <meta name="viewport" content="initial-scale=1.0">
  4.  
  5. <link rel="stylesheet" type="text/css" href="css/breadcrumb.css" media="screen" charset="utf-8" />
  6. <link rel="stylesheet" type="text/css" href="css/default.css" media="screen" charset="utf-8" />
  7. <link rel="stylesheet" type="text/css" href="css/menu.css" media="screen" charset="utf-8" />
  8. <style media="screen" type="text/css">  
  9.  
  10. html, body { }
  11.  
  12. #aznavbar a:link {  
  13. color: #0C7FB0;
  14. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  15. margin-left: 4.15px;
  16. padding: 10px;  
  17. text-decoration:none;  
  18. }  
  19.    
  20. #aznavbar a:visited {  
  21. color: #0C7FB0;
  22. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  23. padding: 10px;  
  24. text-decoration:none;  
  25. }  
  26.  
  27.  
  28. #aznavbar a:hover {
  29. background-color: #FA6405;
  30. color:#000;  
  31. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  32. padding: 10px;  
  33. text-decoration:none;  
  34. }  
  35.  
  36.  
  37. #aznavbar a:active{  
  38. color:#FA6405;  
  39. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  40. padding: 10px;  
  41. text-decoration:none;  
  42. }
  43.  
  44. #aznavbar {  
  45.   background: #141414;
  46.   background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
  47.   background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
  48.   background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
  49.   background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
  50.   background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
  51.   background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
  52.   filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#32323a', EndColorStr='#141414', GradientType=0);
  53.   border: 1px solid #000;  
  54.   margin: -10px 0px 0px -8px;
  55.   padding: 10 0px 10px 80px;
  56.   width: 94.8%;
  57.   }  
  58.  
  59. a:hover#showall {  
  60. }  
  61.  
  62. #ad-wrapper{  
  63.     margin:0px auto 0px auto;  
  64.     text-align:center;  
  65. }
  66.  
  67. </style>  
  68. </head>
  69.  
  70. <body>
  71.  
  72. <?php include('az.php'); ?>
  73.  
  74. <div class="drop-shadow lifted" id="header"><img src="/test2/images/logo.png" alt="Reunite My Site - Company Logo" title="Reunite My Site - Company Logo"> </div>
  75.  
  76. <div id="login">Login:&nbsp;<input type="username" class="login" size="20px;">
  77. <br />
  78. Password:&nbsp;<input class="login" type="password" size="20px">
  79. <br />
  80. Remember Me? <input type="checkbox">
  81.  
  82. <a href="#">Register Now For Free!</a>
  83.  
  84. <div class="note orange rounded">Start your Advertising or Publishing Campaign Now by simply clicking the Register Now button above!</div></div>
  85.  
  86. <iframe name="frame">Sorry, you need the newest browser to display iframes!</iframe>
  87.  
  88. </body>
  89. </html>
  90.  


az.php
PHP Code: [ Select ]
<div id="aznavbar" class="drop-shadow raised">
<?php  
    //This creates the menu at the top A-Z  
    $char = $_GET['letter'];  
    $list="num";  
    foreach (range('A', 'Z') as $i) $list.=",$i";  
    $list.=",Show All Ads";  
    $a = explode(',', $list);  
    foreach ($a as $b) {  
        if (!empty($b)) {  
            if ($b=="num") {  
                if ($char=="num") echo "<a href=\"results.php?letter=num\" target=\"frame\">#</a>";  
                else echo "<a href=\"results.php?letter=num\" target=\"frame\">#</a>";  
            }  
            elseif ($b=="Show All Ads") {  
                if (($char=="*")||(empty($char))) echo "<a href=\"results.php?letter=*\" target=\"frame\">Show All Ads</a>";  
                else echo "<a href=\"results.php?letter=*\" target=\"frame\">Show All Ads</a>";  
            }  
            elseif($b==$char) echo "<a href=\"results.php?letter=".$b."\" target=\"frame\">$b</a>";  
            else echo "<a href=\"results.php?letter=".$b."\" target=\"frame\">$b</a>";  
        }  
    }  
?>  
</div>
 
  1. <div id="aznavbar" class="drop-shadow raised">
  2. <?php  
  3.     //This creates the menu at the top A-Z  
  4.     $char = $_GET['letter'];  
  5.     $list="num";  
  6.     foreach (range('A', 'Z') as $i) $list.=",$i";  
  7.     $list.=",Show All Ads";  
  8.     $a = explode(',', $list);  
  9.     foreach ($a as $b) {  
  10.         if (!empty($b)) {  
  11.             if ($b=="num") {  
  12.                 if ($char=="num") echo "<a href=\"results.php?letter=num\" target=\"frame\">#</a>";  
  13.                 else echo "<a href=\"results.php?letter=num\" target=\"frame\">#</a>";  
  14.             }  
  15.             elseif ($b=="Show All Ads") {  
  16.                 if (($char=="*")||(empty($char))) echo "<a href=\"results.php?letter=*\" target=\"frame\">Show All Ads</a>";  
  17.                 else echo "<a href=\"results.php?letter=*\" target=\"frame\">Show All Ads</a>";  
  18.             }  
  19.             elseif($b==$char) echo "<a href=\"results.php?letter=".$b."\" target=\"frame\">$b</a>";  
  20.             else echo "<a href=\"results.php?letter=".$b."\" target=\"frame\">$b</a>";  
  21.         }  
  22.     }  
  23. ?>  
  24. </div>
  25.  


results.php
PHP Code: [ Select ]
<?php
 
    // How many adjacent pages should be shown on each side?  
    $adjacents = 1; //This only applies to lists that are more then 8 pages (controls the ...'s not the list)  
 
    //how many items to show per page  
    $limit = 10;  
 
    //Number of ads per row
    $rows = 3;
?>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
<head>  
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />  
 
<title>A To Z AD Navigation </title>  
 
<style media="screen" type="text/css">  
 
html, body { }
 
#aznavbar a:link {  
color: #0C7FB0;
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
margin-left: 4.15px;
padding: 10px;  
text-decoration:none;  
}  
   
#aznavbar a:visited {  
color: #0C7FB0;
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px;  
text-decoration:none;  
}  
 
 
#aznavbar a:hover {
background-color: #FA6405;
color:#000;  
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px;  
text-decoration:none;  
}  
 
 
#aznavbar a:active{  
color:#FA6405;  
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px;  
text-decoration:none;  
}
 
#aznavbar {  
  background: #141414;
  background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
  background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
  background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
  background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
  background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
  filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#32323a', EndColorStr='#141414', GradientType=0);
  border: 1px solid #000;  
  margin: -10px 0px 0px -8px;
  padding: 10 0px 10px 80px;
  width: 94.8%;
  }  
 
a:hover#showall {  
}  
 
#ad-wrapper{  
    margin:0px auto 0px auto;  
    text-align:center;  
}
 
</style>  
</head>  
 
<body>
 
<?php  
//This creates the menu at the top A-Z  
$char = $_GET['letter'];  
$list="num";
   
if(!empty($char)){
    include('connect.php');  
    $tbl_name="amp_ads";        //your table name  
     
    /*  
       First get total number of rows in data table.  
       If you have a WHERE clause in your query, make sure you mirror it here.  
    */  
    if((empty($char))||($char=="*")) $query = "SELECT COUNT(*) as num FROM $tbl_name";  
    elseif($char=="num") $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title REGEXP '^[0-9]'";  
    else $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title LIKE '$char%'";  
    $total_pages = mysql_fetch_array(mysql_query($query));  
    $total_pages = $total_pages[num];  
     
    /* Setup vars for query. */  
    if(!empty($char)) $targetpage = "results.php?letter=$char&";  
    else $targetpage = "az.php?";     //your file name  (the name of this file)  
    $page = $_GET['page'];  
    if($page)  
        $start = ($page - 1) * $limit;             //first item to display on this page  
    else  
        $start = 0;                                //if no page var is given, set start to 0  
     
    /* Get data. */  
    if($char=="*") $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit";  
    elseif($char=="num") $sql = "SELECT * FROM $tbl_name WHERE title REGEXP '^[0-9]' LIMIT $start, $limit";  
    else $sql = "SELECT * FROM $tbl_name  WHERE title LIKE '$char%' LIMIT $start, $limit";  
    $result = mysql_query($sql);  
     
    /* Setup page vars for display. */  
    if ($page == 0) $page = 1;                    //if no page var is given, default to 1.  
    $prev = $page - 1;                            //previous page is page - 1  
    $next = $page + 1;                            //next page is page + 1  
    $lastpage = ceil($total_pages/$limit);        //lastpage is = total pages / items per page, rounded up.  
    $lpm1 = $lastpage - 1;                        //last page minus 1  
     
    /*  
        Now we apply our rules and draw the pagination object.  
        We're actually saving the code to a variable in case we want to draw it more than once.  
    */  
    $pagination = "";  
    if($lastpage > 1)  
    {      
        $pagination .= "<div class=\"pagination\">";  
        //previous button  
        if ($page > 1)  
            $pagination.= "<a href=\"$targetpage"."page=$prev\">« previous </a>";  
        else  
            $pagination.= "<span class=\"disabled\">« previous </span>";      
         
        //pages      
        if ($lastpage < 7 + ($adjacents * 2))    //not enough pages to bother breaking it up  
        {      
            for ($counter = 1; $counter <= $lastpage; $counter++)  
            {  
                if ($counter == $page)  
                    $pagination.= "<span class=\"current\">$counter</span>";  
                else  
                    $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
            }  
        }  
        elseif($lastpage > 5 + ($adjacents * 2))    //enough pages to hide some  
        {  
            //close to beginning; only hide later pages  
            if($page < 1 + ($adjacents * 2))          
            {  
                for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)  
                {  
                    if ($counter == $page)  
                        $pagination.= "<span class=\"current\">$counter</span>";  
                    else  
                        $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
                }  
                $pagination.= "...";  
                $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>";  
                $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";          
            }  
            //in middle; hide some front and some back  
            elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))  
            {  
                $pagination.= "<a href=\"$targetpage"."page=1\">1</a>";  
                $pagination.= "<a href=\"$targetpage"."page=2\">2</a>";  
                $pagination.= "...";  
                for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)  
                {  
                    if ($counter == $page)  
                        $pagination.= "<span class=\"current\">$counter</span>";  
                    else  
                        $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
                }  
                $pagination.= "...";  
                $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>";  
                $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";          
            }  
            //close to end; only hide early pages  
            else  
            {  
                $pagination.= "<a href=\"$targetpage"."page=1\">1</a>";  
                $pagination.= "<a href=\"$targetpage"."page=2\">2</a>";  
                $pagination.= "...";  
                for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)  
                {  
                    if ($counter == $page)  
                        $pagination.= "<span class=\"current\">$counter</span>";  
                    else  
                        $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
                }  
            }  
        }  
         
        //next button  
        if ($page < $counter - 1)  
            $pagination.= "<a href=\"$targetpage"."page=$next\"> next »</a>";  
        else  
            $pagination.= "<span class=\"disabled\"> next »</span>";  
        $pagination.= "</div>\n";          
    }  
?>  
 
    <?php  
        echo '<div id="ad-wrapper">';  
        if($total_pages==0) echo "No Results for ".$char."!";
        else{
            $c = -1;
            while($row = mysql_fetch_array($result))  
            {  
                if($c%$rows==$rows-1) echo "<br/>";
                echo "<a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"><p /> $row[alt]";
                $c++;
                $c++;
            }  
        }
}
    ?>  
 
<?php echo $pagination ?>  
</body>  
</html>
 
  1. <?php
  2.  
  3.     // How many adjacent pages should be shown on each side?  
  4.     $adjacents = 1; //This only applies to lists that are more then 8 pages (controls the ...'s not the list)  
  5.  
  6.     //how many items to show per page  
  7.     $limit = 10;  
  8.  
  9.     //Number of ads per row
  10.     $rows = 3;
  11. ?>
  12.  
  13. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">  
  14. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">  
  15. <head>  
  16. <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />  
  17.  
  18. <title>A To Z AD Navigation </title>  
  19.  
  20. <style media="screen" type="text/css">  
  21.  
  22. html, body { }
  23.  
  24. #aznavbar a:link {  
  25. color: #0C7FB0;
  26. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  27. margin-left: 4.15px;
  28. padding: 10px;  
  29. text-decoration:none;  
  30. }  
  31.    
  32. #aznavbar a:visited {  
  33. color: #0C7FB0;
  34. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  35. padding: 10px;  
  36. text-decoration:none;  
  37. }  
  38.  
  39.  
  40. #aznavbar a:hover {
  41. background-color: #FA6405;
  42. color:#000;  
  43. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  44. padding: 10px;  
  45. text-decoration:none;  
  46. }  
  47.  
  48.  
  49. #aznavbar a:active{  
  50. color:#FA6405;  
  51. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  52. padding: 10px;  
  53. text-decoration:none;  
  54. }
  55.  
  56. #aznavbar {  
  57.   background: #141414;
  58.   background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
  59.   background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
  60.   background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
  61.   background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
  62.   background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
  63.   background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
  64.   filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#32323a', EndColorStr='#141414', GradientType=0);
  65.   border: 1px solid #000;  
  66.   margin: -10px 0px 0px -8px;
  67.   padding: 10 0px 10px 80px;
  68.   width: 94.8%;
  69.   }  
  70.  
  71. a:hover#showall {  
  72. }  
  73.  
  74. #ad-wrapper{  
  75.     margin:0px auto 0px auto;  
  76.     text-align:center;  
  77. }
  78.  
  79. </style>  
  80. </head>  
  81.  
  82. <body>
  83.  
  84. <?php  
  85. //This creates the menu at the top A-Z  
  86. $char = $_GET['letter'];  
  87. $list="num";
  88.    
  89. if(!empty($char)){
  90.     include('connect.php');  
  91.     $tbl_name="amp_ads";        //your table name  
  92.      
  93.     /*  
  94.        First get total number of rows in data table.  
  95.        If you have a WHERE clause in your query, make sure you mirror it here.  
  96.     */  
  97.     if((empty($char))||($char=="*")) $query = "SELECT COUNT(*) as num FROM $tbl_name";  
  98.     elseif($char=="num") $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title REGEXP '^[0-9]'";  
  99.     else $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title LIKE '$char%'";  
  100.     $total_pages = mysql_fetch_array(mysql_query($query));  
  101.     $total_pages = $total_pages[num];  
  102.      
  103.     /* Setup vars for query. */  
  104.     if(!empty($char)) $targetpage = "results.php?letter=$char&";  
  105.     else $targetpage = "az.php?";     //your file name  (the name of this file)  
  106.     $page = $_GET['page'];  
  107.     if($page)  
  108.         $start = ($page - 1) * $limit;             //first item to display on this page  
  109.     else  
  110.         $start = 0;                                //if no page var is given, set start to 0  
  111.      
  112.     /* Get data. */  
  113.     if($char=="*") $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit";  
  114.     elseif($char=="num") $sql = "SELECT * FROM $tbl_name WHERE title REGEXP '^[0-9]' LIMIT $start, $limit";  
  115.     else $sql = "SELECT * FROM $tbl_name  WHERE title LIKE '$char%' LIMIT $start, $limit";  
  116.     $result = mysql_query($sql);  
  117.      
  118.     /* Setup page vars for display. */  
  119.     if ($page == 0) $page = 1;                    //if no page var is given, default to 1.  
  120.     $prev = $page - 1;                            //previous page is page - 1  
  121.     $next = $page + 1;                            //next page is page + 1  
  122.     $lastpage = ceil($total_pages/$limit);        //lastpage is = total pages / items per page, rounded up.  
  123.     $lpm1 = $lastpage - 1;                        //last page minus 1  
  124.      
  125.     /*  
  126.         Now we apply our rules and draw the pagination object.  
  127.         We're actually saving the code to a variable in case we want to draw it more than once.  
  128.     */  
  129.     $pagination = "";  
  130.     if($lastpage > 1)  
  131.     {      
  132.         $pagination .= "<div class=\"pagination\">";  
  133.         //previous button  
  134.         if ($page > 1)  
  135.             $pagination.= "<a href=\"$targetpage"."page=$prev\">« previous </a>";  
  136.         else  
  137.             $pagination.= "<span class=\"disabled\">« previous </span>";      
  138.          
  139.         //pages      
  140.         if ($lastpage < 7 + ($adjacents * 2))    //not enough pages to bother breaking it up  
  141.         {      
  142.             for ($counter = 1; $counter <= $lastpage; $counter++)  
  143.             {  
  144.                 if ($counter == $page)  
  145.                     $pagination.= "<span class=\"current\">$counter</span>";  
  146.                 else  
  147.                     $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
  148.             }  
  149.         }  
  150.         elseif($lastpage > 5 + ($adjacents * 2))    //enough pages to hide some  
  151.         {  
  152.             //close to beginning; only hide later pages  
  153.             if($page < 1 + ($adjacents * 2))          
  154.             {  
  155.                 for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)  
  156.                 {  
  157.                     if ($counter == $page)  
  158.                         $pagination.= "<span class=\"current\">$counter</span>";  
  159.                     else  
  160.                         $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
  161.                 }  
  162.                 $pagination.= "...";  
  163.                 $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>";  
  164.                 $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";          
  165.             }  
  166.             //in middle; hide some front and some back  
  167.             elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))  
  168.             {  
  169.                 $pagination.= "<a href=\"$targetpage"."page=1\">1</a>";  
  170.                 $pagination.= "<a href=\"$targetpage"."page=2\">2</a>";  
  171.                 $pagination.= "...";  
  172.                 for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)  
  173.                 {  
  174.                     if ($counter == $page)  
  175.                         $pagination.= "<span class=\"current\">$counter</span>";  
  176.                     else  
  177.                         $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
  178.                 }  
  179.                 $pagination.= "...";  
  180.                 $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>";  
  181.                 $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";          
  182.             }  
  183.             //close to end; only hide early pages  
  184.             else  
  185.             {  
  186.                 $pagination.= "<a href=\"$targetpage"."page=1\">1</a>";  
  187.                 $pagination.= "<a href=\"$targetpage"."page=2\">2</a>";  
  188.                 $pagination.= "...";  
  189.                 for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)  
  190.                 {  
  191.                     if ($counter == $page)  
  192.                         $pagination.= "<span class=\"current\">$counter</span>";  
  193.                     else  
  194.                         $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
  195.                 }  
  196.             }  
  197.         }  
  198.          
  199.         //next button  
  200.         if ($page < $counter - 1)  
  201.             $pagination.= "<a href=\"$targetpage"."page=$next\"> next »</a>";  
  202.         else  
  203.             $pagination.= "<span class=\"disabled\"> next »</span>";  
  204.         $pagination.= "</div>\n";          
  205.     }  
  206. ?>  
  207.  
  208.     <?php  
  209.         echo '<div id="ad-wrapper">';  
  210.         if($total_pages==0) echo "No Results for ".$char."!";
  211.         else{
  212.             $c = -1;
  213.             while($row = mysql_fetch_array($result))  
  214.             {  
  215.                 if($c%$rows==$rows-1) echo "<br/>";
  216.                 echo "<a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"><p /> $row[alt]";
  217.                 $c++;
  218.                 $c++;
  219.             }  
  220.         }
  221. }
  222.     ?>  
  223.  
  224. <?php echo $pagination ?>  
  225. </body>  
  226. </html>
  227.  
  • Brian Jester
  • Beginner
  • Beginner
  • Brian Jester
  • Posts: 61
  • Loc: Bayonne, New Jersey USA

Post 3+ Months Ago

Hi Scott,

It works!!

Thank you so much, if I can offer you a few bucks by paypal, send me a message.

Thanks again,
and Happy New Year!

-Brian
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

No need .... I'm glad to help and you have a happy new year as well.
  • Brian Jester
  • Beginner
  • Beginner
  • Brian Jester
  • Posts: 61
  • Loc: Bayonne, New Jersey USA

Post 3+ Months Ago

Hi Scott,

Hate to bother you, and I don't *think* it's that big of a deal to do, but instead of opening into iframe, can you help me open it into the php 'switch' div? Reason: The height of the iframe, I think you know the rest...Don't like to use javascript for something like that. :|

Here's a bit of 'switch' code that works:

Code: [ Select ]

<style type="text/css">

#target {
width: 300px;
height: 300px;
background-color: #00FFCC;
border: 1px solid #000;
text-align: center;
vertical-align:middle;
margin: 0 auto;
padding: 10px; }

</style>

<body>

<a href="index.php?page=main">page1</a>
<a href="index.php?page=2"><br />page2</a>
<a href="index.php?page=3"><br />page3</a>
<p />

<div id="target">

<?php

switch ($_GET['page'])

{
case "main": include '1.php'; break;
case "2": include '2.php'; break;
case "3": include '3.php'; break;

default: include '1.php';
}

?>
</div>

</body>
</html>
  1. <style type="text/css">
  2. #target {
  3. width: 300px;
  4. height: 300px;
  5. background-color: #00FFCC;
  6. border: 1px solid #000;
  7. text-align: center;
  8. vertical-align:middle;
  9. margin: 0 auto;
  10. padding: 10px; }
  11. </style>
  12. <body>
  13. <a href="index.php?page=main">page1</a>
  14. <a href="index.php?page=2"><br />page2</a>
  15. <a href="index.php?page=3"><br />page3</a>
  16. <p />
  17. <div id="target">
  18. <?php
  19. switch ($_GET['page'])
  20. {
  21. case "main": include '1.php'; break;
  22. case "2": include '2.php'; break;
  23. case "3": include '3.php'; break;
  24. default: include '1.php';
  25. }
  26. ?>
  27. </div>
  28. </body>
  29. </html>
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

You should be able to change the results.php to this

PHP Code: [ Select ]
<?php
 
// How many adjacent pages should be shown on each side?  
$adjacents = 1; //This only applies to lists that are more then 8 pages (controls the ...'s not the list)  
 
//how many items to show per page  
$limit = 10;  
 
//Number of ads per row
$rows = 3;
 
//This creates the menu at the top A-Z  
$char = $_GET['letter'];  
$list="num";
   
if(!empty($char)){
    include('connect.php');  
    $tbl_name="amp_ads";        //your table name  
     
    /*  
       First get total number of rows in data table.  
       If you have a WHERE clause in your query, make sure you mirror it here.  
    */  
    if((empty($char))||($char=="*")) $query = "SELECT COUNT(*) as num FROM $tbl_name";  
    elseif($char=="num") $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title REGEXP '^[0-9]'";  
    else $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title LIKE '$char%'";  
    $total_pages = mysql_fetch_array(mysql_query($query));  
    $total_pages = $total_pages[num];  
     
    /* Setup vars for query. */  
    if(!empty($char)) $targetpage = "results.php?letter=$char&";  
    else $targetpage = "az.php?";     //your file name  (the name of this file)  
    $page = $_GET['page'];  
    if($page)  
        $start = ($page - 1) * $limit;             //first item to display on this page  
    else  
        $start = 0;                                //if no page var is given, set start to 0  
     
    /* Get data. */  
    if($char=="*") $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit";  
    elseif($char=="num") $sql = "SELECT * FROM $tbl_name WHERE title REGEXP '^[0-9]' LIMIT $start, $limit";  
    else $sql = "SELECT * FROM $tbl_name  WHERE title LIKE '$char%' LIMIT $start, $limit";  
    $result = mysql_query($sql);  
     
    /* Setup page vars for display. */  
    if ($page == 0) $page = 1;                    //if no page var is given, default to 1.  
    $prev = $page - 1;                            //previous page is page - 1  
    $next = $page + 1;                            //next page is page + 1  
    $lastpage = ceil($total_pages/$limit);        //lastpage is = total pages / items per page, rounded up.  
    $lpm1 = $lastpage - 1;                        //last page minus 1  
     
    /*  
        Now we apply our rules and draw the pagination object.  
        We're actually saving the code to a variable in case we want to draw it more than once.  
    */  
    $pagination = "";  
    if($lastpage > 1)  
    {      
        $pagination .= "<div class=\"pagination\">";  
        //previous button  
        if ($page > 1)  
            $pagination.= "<a href=\"$targetpage"."page=$prev\">« previous </a>";  
        else  
            $pagination.= "<span class=\"disabled\">« previous </span>";      
         
        //pages      
        if ($lastpage < 7 + ($adjacents * 2))    //not enough pages to bother breaking it up  
        {      
            for ($counter = 1; $counter <= $lastpage; $counter++)  
            {  
                if ($counter == $page)  
                    $pagination.= "<span class=\"current\">$counter</span>";  
                else  
                    $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
            }  
        }  
        elseif($lastpage > 5 + ($adjacents * 2))    //enough pages to hide some  
        {  
            //close to beginning; only hide later pages  
            if($page < 1 + ($adjacents * 2))          
            {  
                for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)  
                {  
                    if ($counter == $page)  
                        $pagination.= "<span class=\"current\">$counter</span>";  
                    else  
                        $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
                }  
                $pagination.= "...";  
                $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>";  
                $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";          
            }  
            //in middle; hide some front and some back  
            elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))  
            {  
                $pagination.= "<a href=\"$targetpage"."page=1\">1</a>";  
                $pagination.= "<a href=\"$targetpage"."page=2\">2</a>";  
                $pagination.= "...";  
                for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)  
                {  
                    if ($counter == $page)  
                        $pagination.= "<span class=\"current\">$counter</span>";  
                    else  
                        $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
                }  
                $pagination.= "...";  
                $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>";  
                $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";          
            }  
            //close to end; only hide early pages  
            else  
            {  
                $pagination.= "<a href=\"$targetpage"."page=1\">1</a>";  
                $pagination.= "<a href=\"$targetpage"."page=2\">2</a>";  
                $pagination.= "...";  
                for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)  
                {  
                    if ($counter == $page)  
                        $pagination.= "<span class=\"current\">$counter</span>";  
                    else  
                        $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
                }  
            }  
        }  
         
        //next button  
        if ($page < $counter - 1)  
            $pagination.= "<a href=\"$targetpage"."page=$next\"> next »</a>";  
        else  
            $pagination.= "<span class=\"disabled\"> next »</span>";  
        $pagination.= "</div>\n";          
    }  
   
        echo '<div id="ad-wrapper">';  
        if($total_pages==0) echo "No Results for ".$char."!";
        else{
            $c = -1;
            while($row = mysql_fetch_array($result))  
            {  
                if($c%$rows==$rows-1) echo "<br/>";
                echo "<a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"><p /> $row[alt]";
                $c++;
                $c++;
            }  
        }
}
 
echo $pagination;
 
?>
 
  1. <?php
  2.  
  3. // How many adjacent pages should be shown on each side?  
  4. $adjacents = 1; //This only applies to lists that are more then 8 pages (controls the ...'s not the list)  
  5.  
  6. //how many items to show per page  
  7. $limit = 10;  
  8.  
  9. //Number of ads per row
  10. $rows = 3;
  11.  
  12. //This creates the menu at the top A-Z  
  13. $char = $_GET['letter'];  
  14. $list="num";
  15.    
  16. if(!empty($char)){
  17.     include('connect.php');  
  18.     $tbl_name="amp_ads";        //your table name  
  19.      
  20.     /*  
  21.        First get total number of rows in data table.  
  22.        If you have a WHERE clause in your query, make sure you mirror it here.  
  23.     */  
  24.     if((empty($char))||($char=="*")) $query = "SELECT COUNT(*) as num FROM $tbl_name";  
  25.     elseif($char=="num") $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title REGEXP '^[0-9]'";  
  26.     else $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title LIKE '$char%'";  
  27.     $total_pages = mysql_fetch_array(mysql_query($query));  
  28.     $total_pages = $total_pages[num];  
  29.      
  30.     /* Setup vars for query. */  
  31.     if(!empty($char)) $targetpage = "results.php?letter=$char&";  
  32.     else $targetpage = "az.php?";     //your file name  (the name of this file)  
  33.     $page = $_GET['page'];  
  34.     if($page)  
  35.         $start = ($page - 1) * $limit;             //first item to display on this page  
  36.     else  
  37.         $start = 0;                                //if no page var is given, set start to 0  
  38.      
  39.     /* Get data. */  
  40.     if($char=="*") $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit";  
  41.     elseif($char=="num") $sql = "SELECT * FROM $tbl_name WHERE title REGEXP '^[0-9]' LIMIT $start, $limit";  
  42.     else $sql = "SELECT * FROM $tbl_name  WHERE title LIKE '$char%' LIMIT $start, $limit";  
  43.     $result = mysql_query($sql);  
  44.      
  45.     /* Setup page vars for display. */  
  46.     if ($page == 0) $page = 1;                    //if no page var is given, default to 1.  
  47.     $prev = $page - 1;                            //previous page is page - 1  
  48.     $next = $page + 1;                            //next page is page + 1  
  49.     $lastpage = ceil($total_pages/$limit);        //lastpage is = total pages / items per page, rounded up.  
  50.     $lpm1 = $lastpage - 1;                        //last page minus 1  
  51.      
  52.     /*  
  53.         Now we apply our rules and draw the pagination object.  
  54.         We're actually saving the code to a variable in case we want to draw it more than once.  
  55.     */  
  56.     $pagination = "";  
  57.     if($lastpage > 1)  
  58.     {      
  59.         $pagination .= "<div class=\"pagination\">";  
  60.         //previous button  
  61.         if ($page > 1)  
  62.             $pagination.= "<a href=\"$targetpage"."page=$prev\">« previous </a>";  
  63.         else  
  64.             $pagination.= "<span class=\"disabled\">« previous </span>";      
  65.          
  66.         //pages      
  67.         if ($lastpage < 7 + ($adjacents * 2))    //not enough pages to bother breaking it up  
  68.         {      
  69.             for ($counter = 1; $counter <= $lastpage; $counter++)  
  70.             {  
  71.                 if ($counter == $page)  
  72.                     $pagination.= "<span class=\"current\">$counter</span>";  
  73.                 else  
  74.                     $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
  75.             }  
  76.         }  
  77.         elseif($lastpage > 5 + ($adjacents * 2))    //enough pages to hide some  
  78.         {  
  79.             //close to beginning; only hide later pages  
  80.             if($page < 1 + ($adjacents * 2))          
  81.             {  
  82.                 for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++)  
  83.                 {  
  84.                     if ($counter == $page)  
  85.                         $pagination.= "<span class=\"current\">$counter</span>";  
  86.                     else  
  87.                         $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
  88.                 }  
  89.                 $pagination.= "...";  
  90.                 $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>";  
  91.                 $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";          
  92.             }  
  93.             //in middle; hide some front and some back  
  94.             elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2))  
  95.             {  
  96.                 $pagination.= "<a href=\"$targetpage"."page=1\">1</a>";  
  97.                 $pagination.= "<a href=\"$targetpage"."page=2\">2</a>";  
  98.                 $pagination.= "...";  
  99.                 for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++)  
  100.                 {  
  101.                     if ($counter == $page)  
  102.                         $pagination.= "<span class=\"current\">$counter</span>";  
  103.                     else  
  104.                         $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
  105.                 }  
  106.                 $pagination.= "...";  
  107.                 $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>";  
  108.                 $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";          
  109.             }  
  110.             //close to end; only hide early pages  
  111.             else  
  112.             {  
  113.                 $pagination.= "<a href=\"$targetpage"."page=1\">1</a>";  
  114.                 $pagination.= "<a href=\"$targetpage"."page=2\">2</a>";  
  115.                 $pagination.= "...";  
  116.                 for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++)  
  117.                 {  
  118.                     if ($counter == $page)  
  119.                         $pagination.= "<span class=\"current\">$counter</span>";  
  120.                     else  
  121.                         $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";                      
  122.                 }  
  123.             }  
  124.         }  
  125.          
  126.         //next button  
  127.         if ($page < $counter - 1)  
  128.             $pagination.= "<a href=\"$targetpage"."page=$next\"> next »</a>";  
  129.         else  
  130.             $pagination.= "<span class=\"disabled\"> next »</span>";  
  131.         $pagination.= "</div>\n";          
  132.     }  
  133.    
  134.         echo '<div id="ad-wrapper">';  
  135.         if($total_pages==0) echo "No Results for ".$char."!";
  136.         else{
  137.             $c = -1;
  138.             while($row = mysql_fetch_array($result))  
  139.             {  
  140.                 if($c%$rows==$rows-1) echo "<br/>";
  141.                 echo "<a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"><p /> $row[alt]";
  142.                 $c++;
  143.                 $c++;
  144.             }  
  145.         }
  146. }
  147.  
  148. echo $pagination;
  149.  
  150. ?>
  151.  


and just include it in the div

Code: [ Select ]
<div id="target">
<?php
include 'results.php';
?>
</div>
  1. <div id="target">
  2. <?php
  3. include 'results.php';
  4. ?>
  5. </div>


If I'm not mistaken the results page returns nothing if the variables are not setup.
  • Brian Jester
  • Beginner
  • Beginner
  • Brian Jester
  • Posts: 61
  • Loc: Bayonne, New Jersey USA

Post 3+ Months Ago

I tried that and the results open in the parent window (not new window)...I am trying for the <div id="target"> </div>

Another try?
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

Sorry I sent that out untested I forgot to add a few things

I missed something in the results.php
Code: [ Select ]
<?php
 
// How many adjacent pages should be shown on each side? 
$adjacents = 1; //This only applies to lists that are more then 8 pages (controls the ...'s not the list) 

//how many items to show per page 
$limit = 10; 

//Number of ads per row
$rows = 3;

//This creates the menu at the top A-Z 
$char = $_GET['letter']; 
$list="num";
    
if(!empty($char)){
  include('connect.php'); 
  $tbl_name="amp_ads";    //your table name 
   
  /* 
    First get total number of rows in data table. 
    If you have a WHERE clause in your query, make sure you mirror it here. 
  */ 
  if((empty($char))||($char=="*")) $query = "SELECT COUNT(*) as num FROM $tbl_name"; 
  elseif($char=="num") $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title REGEXP '^[0-9]'"; 
  else $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title LIKE '$char%'"; 
  $total_pages = mysql_fetch_array(mysql_query($query)); 
  $total_pages = $total_pages[num]; 
   
  /* Setup vars for query. */ 
  if(!empty($char)) $targetpage = $_SERVER['PHP_SELF'] . "?letter=$char&"; 
  else $targetpage = "az.php?";   //your file name (the name of this file) 
  $page = $_GET['page']; 
  if($page) 
    $start = ($page - 1) * $limit;       //first item to display on this page 
  else 
    $start = 0;                //if no page var is given, set start to 0 
   
  /* Get data. */ 
  if($char=="*") $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit"; 
  elseif($char=="num") $sql = "SELECT * FROM $tbl_name WHERE title REGEXP '^[0-9]' LIMIT $start, $limit"; 
  else $sql = "SELECT * FROM $tbl_name WHERE title LIKE '$char%' LIMIT $start, $limit"; 
  $result = mysql_query($sql); 
   
  /* Setup page vars for display. */ 
  if ($page == 0) $page = 1;          //if no page var is given, default to 1. 
  $prev = $page - 1;              //previous page is page - 1 
  $next = $page + 1;              //next page is page + 1 
  $lastpage = ceil($total_pages/$limit);    //lastpage is = total pages / items per page, rounded up. 
  $lpm1 = $lastpage - 1;            //last page minus 1 
   
  /* 
    Now we apply our rules and draw the pagination object. 
    We're actually saving the code to a variable in case we want to draw it more than once. 
  */ 
  $pagination = ""; 
  if($lastpage > 1) 
  {   
    $pagination .= "<div class=\"pagination\">"; 
    //previous button 
    if ($page > 1) 
      $pagination.= "<a href=\"$targetpage"."page=$prev\">« previous </a>"; 
    else 
      $pagination.= "<span class=\"disabled\">« previous </span>";   
     
    //pages   
    if ($lastpage < 7 + ($adjacents * 2))  //not enough pages to bother breaking it up 
    {   
      for ($counter = 1; $counter <= $lastpage; $counter++) 
      { 
        if ($counter == $page) 
          $pagination.= "<span class=\"current\">$counter</span>"; 
        else 
          $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
      } 
    } 
    elseif($lastpage > 5 + ($adjacents * 2))  //enough pages to hide some 
    { 
      //close to beginning; only hide later pages 
      if($page < 1 + ($adjacents * 2))     
      { 
        for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) 
        { 
          if ($counter == $page) 
            $pagination.= "<span class=\"current\">$counter</span>"; 
          else 
            $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
        } 
        $pagination.= "..."; 
        $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>"; 
        $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";     
      } 
      //in middle; hide some front and some back 
      elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) 
      { 
        $pagination.= "<a href=\"$targetpage"."page=1\">1</a>"; 
        $pagination.= "<a href=\"$targetpage"."page=2\">2</a>"; 
        $pagination.= "..."; 
        for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) 
        { 
          if ($counter == $page) 
            $pagination.= "<span class=\"current\">$counter</span>"; 
          else 
            $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
        } 
        $pagination.= "..."; 
        $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>"; 
        $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";     
      } 
      //close to end; only hide early pages 
      else 
      { 
        $pagination.= "<a href=\"$targetpage"."page=1\">1</a>"; 
        $pagination.= "<a href=\"$targetpage"."page=2\">2</a>"; 
        $pagination.= "..."; 
        for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) 
        { 
          if ($counter == $page) 
            $pagination.= "<span class=\"current\">$counter</span>"; 
          else 
            $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
        } 
      } 
    } 
     
    //next button 
    if ($page < $counter - 1) 
      $pagination.= "<a href=\"$targetpage"."page=$next\"> next »</a>"; 
    else 
      $pagination.= "<span class=\"disabled\"> next »</span>"; 
    $pagination.= "</div>\n";     
  } 
    
    echo '<div id="ad-wrapper">'; 
    if($total_pages==0) echo "No Results for ".$char."!";
    else{
      $c = -1;
      while($row = mysql_fetch_array($result)) 
      { 
        if($c%$rows==$rows-1) echo "<br/>";
        echo "<a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"><p /> $row[alt]";
        $c++;
        $c++;
      } 
    }
}

echo $pagination;

?> 
  1. <?php
  2.  
  3. // How many adjacent pages should be shown on each side? 
  4. $adjacents = 1; //This only applies to lists that are more then 8 pages (controls the ...'s not the list) 
  5. //how many items to show per page 
  6. $limit = 10; 
  7. //Number of ads per row
  8. $rows = 3;
  9. //This creates the menu at the top A-Z 
  10. $char = $_GET['letter']; 
  11. $list="num";
  12.     
  13. if(!empty($char)){
  14.   include('connect.php'); 
  15.   $tbl_name="amp_ads";    //your table name 
  16.    
  17.   /* 
  18.     First get total number of rows in data table. 
  19.     If you have a WHERE clause in your query, make sure you mirror it here. 
  20.   */ 
  21.   if((empty($char))||($char=="*")) $query = "SELECT COUNT(*) as num FROM $tbl_name"; 
  22.   elseif($char=="num") $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title REGEXP '^[0-9]'"; 
  23.   else $query = "SELECT COUNT(*) as num FROM $tbl_name WHERE title LIKE '$char%'"; 
  24.   $total_pages = mysql_fetch_array(mysql_query($query)); 
  25.   $total_pages = $total_pages[num]; 
  26.    
  27.   /* Setup vars for query. */ 
  28.   if(!empty($char)) $targetpage = $_SERVER['PHP_SELF'] . "?letter=$char&"; 
  29.   else $targetpage = "az.php?";   //your file name (the name of this file) 
  30.   $page = $_GET['page']; 
  31.   if($page) 
  32.     $start = ($page - 1) * $limit;       //first item to display on this page 
  33.   else 
  34.     $start = 0;                //if no page var is given, set start to 0 
  35.    
  36.   /* Get data. */ 
  37.   if($char=="*") $sql = "SELECT * FROM $tbl_name LIMIT $start, $limit"; 
  38.   elseif($char=="num") $sql = "SELECT * FROM $tbl_name WHERE title REGEXP '^[0-9]' LIMIT $start, $limit"; 
  39.   else $sql = "SELECT * FROM $tbl_name WHERE title LIKE '$char%' LIMIT $start, $limit"; 
  40.   $result = mysql_query($sql); 
  41.    
  42.   /* Setup page vars for display. */ 
  43.   if ($page == 0) $page = 1;          //if no page var is given, default to 1. 
  44.   $prev = $page - 1;              //previous page is page - 1 
  45.   $next = $page + 1;              //next page is page + 1 
  46.   $lastpage = ceil($total_pages/$limit);    //lastpage is = total pages / items per page, rounded up. 
  47.   $lpm1 = $lastpage - 1;            //last page minus 1 
  48.    
  49.   /* 
  50.     Now we apply our rules and draw the pagination object. 
  51.     We're actually saving the code to a variable in case we want to draw it more than once. 
  52.   */ 
  53.   $pagination = ""; 
  54.   if($lastpage > 1) 
  55.   {   
  56.     $pagination .= "<div class=\"pagination\">"; 
  57.     //previous button 
  58.     if ($page > 1) 
  59.       $pagination.= "<a href=\"$targetpage"."page=$prev\">« previous </a>"; 
  60.     else 
  61.       $pagination.= "<span class=\"disabled\">« previous </span>";   
  62.      
  63.     //pages   
  64.     if ($lastpage < 7 + ($adjacents * 2))  //not enough pages to bother breaking it up 
  65.     {   
  66.       for ($counter = 1; $counter <= $lastpage; $counter++) 
  67.       { 
  68.         if ($counter == $page) 
  69.           $pagination.= "<span class=\"current\">$counter</span>"; 
  70.         else 
  71.           $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
  72.       } 
  73.     } 
  74.     elseif($lastpage > 5 + ($adjacents * 2))  //enough pages to hide some 
  75.     { 
  76.       //close to beginning; only hide later pages 
  77.       if($page < 1 + ($adjacents * 2))     
  78.       { 
  79.         for ($counter = 1; $counter < 4 + ($adjacents * 2); $counter++) 
  80.         { 
  81.           if ($counter == $page) 
  82.             $pagination.= "<span class=\"current\">$counter</span>"; 
  83.           else 
  84.             $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
  85.         } 
  86.         $pagination.= "..."; 
  87.         $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>"; 
  88.         $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";     
  89.       } 
  90.       //in middle; hide some front and some back 
  91.       elseif($lastpage - ($adjacents * 2) > $page && $page > ($adjacents * 2)) 
  92.       { 
  93.         $pagination.= "<a href=\"$targetpage"."page=1\">1</a>"; 
  94.         $pagination.= "<a href=\"$targetpage"."page=2\">2</a>"; 
  95.         $pagination.= "..."; 
  96.         for ($counter = $page - $adjacents; $counter <= $page + $adjacents; $counter++) 
  97.         { 
  98.           if ($counter == $page) 
  99.             $pagination.= "<span class=\"current\">$counter</span>"; 
  100.           else 
  101.             $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
  102.         } 
  103.         $pagination.= "..."; 
  104.         $pagination.= "<a href=\"$targetpage"."page=$lpm1\">$lpm1</a>"; 
  105.         $pagination.= "<a href=\"$targetpage"."page=$lastpage\">$lastpage</a>";     
  106.       } 
  107.       //close to end; only hide early pages 
  108.       else 
  109.       { 
  110.         $pagination.= "<a href=\"$targetpage"."page=1\">1</a>"; 
  111.         $pagination.= "<a href=\"$targetpage"."page=2\">2</a>"; 
  112.         $pagination.= "..."; 
  113.         for ($counter = $lastpage - (2 + ($adjacents * 2)); $counter <= $lastpage; $counter++) 
  114.         { 
  115.           if ($counter == $page) 
  116.             $pagination.= "<span class=\"current\">$counter</span>"; 
  117.           else 
  118.             $pagination.= "<a href=\"$targetpage"."page=$counter\">$counter</a>";           
  119.         } 
  120.       } 
  121.     } 
  122.      
  123.     //next button 
  124.     if ($page < $counter - 1) 
  125.       $pagination.= "<a href=\"$targetpage"."page=$next\"> next »</a>"; 
  126.     else 
  127.       $pagination.= "<span class=\"disabled\"> next »</span>"; 
  128.     $pagination.= "</div>\n";     
  129.   } 
  130.     
  131.     echo '<div id="ad-wrapper">'; 
  132.     if($total_pages==0) echo "No Results for ".$char."!";
  133.     else{
  134.       $c = -1;
  135.       while($row = mysql_fetch_array($result)) 
  136.       { 
  137.         if($c%$rows==$rows-1) echo "<br/>";
  138.         echo "<a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"><p /> $row[alt]";
  139.         $c++;
  140.         $c++;
  141.       } 
  142.     }
  143. }
  144. echo $pagination;
  145. ?> 


az.php
Code: [ Select ]
<div id="aznavbar" class="drop-shadow raised">
<?php 
  //This creates the menu at the top A-Z 
  $char = $_GET['letter']; 
  $list="num"; 
  foreach (range('A', 'Z') as $i) $list.=",$i"; 
  $list.=",Show All Ads"; 
  $a = explode(',', $list); 
  foreach ($a as $b) { 
    if (!empty($b)) { 
      if ($b=="num") { 
        if ($char=="num") echo "<a href=\"" .$_SERVER['PHP_SELF'] . "?letter=num\">#</a>"; 
        else echo "<a href=\"" .$_SERVER['PHP_SELF'] . "?letter=num\">#</a>"; 
      } 
      elseif ($b=="Show All Ads") { 
        if (($char=="*")||(empty($char))) echo "<a href=\"" .$_SERVER['PHP_SELF'] . "?letter=*\">Show All Ads</a>"; 
        else echo "<a href=\"" .$_SERVER['PHP_SELF'] . "?letter=*\">Show All Ads</a>"; 
      } 
      elseif($b==$char) echo "<a href=\"" .$_SERVER['PHP_SELF'] . "?letter=".$b."\">$b</a>"; 
      else echo "<a href=\"" .$_SERVER['PHP_SELF'] . "?letter=".$b."\">$b</a>"; 
    } 
  } 
?> 
</div>
  1. <div id="aznavbar" class="drop-shadow raised">
  2. <?php 
  3.   //This creates the menu at the top A-Z 
  4.   $char = $_GET['letter']; 
  5.   $list="num"; 
  6.   foreach (range('A', 'Z') as $i) $list.=",$i"; 
  7.   $list.=",Show All Ads"; 
  8.   $a = explode(',', $list); 
  9.   foreach ($a as $b) { 
  10.     if (!empty($b)) { 
  11.       if ($b=="num") { 
  12.         if ($char=="num") echo "<a href=\"" .$_SERVER['PHP_SELF'] . "?letter=num\">#</a>"; 
  13.         else echo "<a href=\"" .$_SERVER['PHP_SELF'] . "?letter=num\">#</a>"; 
  14.       } 
  15.       elseif ($b=="Show All Ads") { 
  16.         if (($char=="*")||(empty($char))) echo "<a href=\"" .$_SERVER['PHP_SELF'] . "?letter=*\">Show All Ads</a>"; 
  17.         else echo "<a href=\"" .$_SERVER['PHP_SELF'] . "?letter=*\">Show All Ads</a>"; 
  18.       } 
  19.       elseif($b==$char) echo "<a href=\"" .$_SERVER['PHP_SELF'] . "?letter=".$b."\">$b</a>"; 
  20.       else echo "<a href=\"" .$_SERVER['PHP_SELF'] . "?letter=".$b."\">$b</a>"; 
  21.     } 
  22.   } 
  23. ?> 
  24. </div>


index.php
Code: [ Select ]
<html>
<head> <title> </title>
<meta name="viewport" content="initial-scale=1.0">

<link rel="stylesheet" type="text/css" href="css/breadcrumb.css" media="screen" charset="utf-8" />
<link rel="stylesheet" type="text/css" href="css/default.css" media="screen" charset="utf-8" />
<link rel="stylesheet" type="text/css" href="css/menu.css" media="screen" charset="utf-8" />
<style media="screen" type="text/css"> 

html, body { }

#aznavbar a:link { 
color: #0C7FB0;
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
margin-left: 4.15px;
padding: 10px; 
text-decoration:none; 

 
#aznavbar a:visited { 
color: #0C7FB0;
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px; 
text-decoration:none; 



#aznavbar a:hover {
background-color: #FA6405;
color:#000; 
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px; 
text-decoration:none; 



#aznavbar a:active{ 
color:#FA6405; 
font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
padding: 10px; 
text-decoration:none; 
}

#aznavbar { 
 background: #141414;
 background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
 background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
 background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
 background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
 background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
 background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
 filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#32323a', EndColorStr='#141414', GradientType=0);
 border: 1px solid #000; 
 margin: -10px 0px 0px -8px;
 padding: 10 0px 10px 80px;
 width: 94.8%;
 } 

a:hover#showall { 


#ad-wrapper{ 
  margin:0px auto 0px auto; 
  text-align:center; 
}

</style> 
</head>

<body>

<?php include('az.php'); ?>

<div class="drop-shadow lifted" id="header"><img src="/test2/images/logo.png" alt="Reunite My Site - Company Logo" title="Reunite My Site - Company Logo"> </div>

<div id="login">Login:&nbsp;<input type="username" class="login" size="20px;">
<br />
Password:&nbsp;<input class="login" type="password" size="20px">
<br />
Remember Me? <input type="checkbox">

<a href="#">Register Now For Free!</a>

<div class="note orange rounded">Start your Advertising or Publishing Campaign Now by simply clicking the Register Now button above!</div></div>

<div name="target" id="target"><?php include 'results.php'; ?></div>

</body>
</html>
  1. <html>
  2. <head> <title> </title>
  3. <meta name="viewport" content="initial-scale=1.0">
  4. <link rel="stylesheet" type="text/css" href="css/breadcrumb.css" media="screen" charset="utf-8" />
  5. <link rel="stylesheet" type="text/css" href="css/default.css" media="screen" charset="utf-8" />
  6. <link rel="stylesheet" type="text/css" href="css/menu.css" media="screen" charset="utf-8" />
  7. <style media="screen" type="text/css"> 
  8. html, body { }
  9. #aznavbar a:link { 
  10. color: #0C7FB0;
  11. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  12. margin-left: 4.15px;
  13. padding: 10px; 
  14. text-decoration:none; 
  15.  
  16. #aznavbar a:visited { 
  17. color: #0C7FB0;
  18. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  19. padding: 10px; 
  20. text-decoration:none; 
  21. #aznavbar a:hover {
  22. background-color: #FA6405;
  23. color:#000; 
  24. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  25. padding: 10px; 
  26. text-decoration:none; 
  27. #aznavbar a:active{ 
  28. color:#FA6405; 
  29. font-family:Verdana,Geneva,'DejaVu Sans',sans-serif;
  30. padding: 10px; 
  31. text-decoration:none; 
  32. }
  33. #aznavbar { 
  34.  background: #141414;
  35.  background: -moz-linear-gradient(top, #32323a 0%, #141414 100%);
  36.  background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, #32323a), color-stop(100%, #141414));
  37.  background: -webkit-linear-gradient(top, #32323a 0%, #141414 100%);
  38.  background: -o-linear-gradient(top, #32323a 0%, #141414 100%);
  39.  background: -ms-linear-gradient(top, #32323a 0%, #141414 100%);
  40.  background: linear-gradient(to bottom, #32323a 0%, #141414 100%);
  41.  filter: progid:DXImageTransform.Microsoft.Gradient(StartColorStr='#32323a', EndColorStr='#141414', GradientType=0);
  42.  border: 1px solid #000; 
  43.  margin: -10px 0px 0px -8px;
  44.  padding: 10 0px 10px 80px;
  45.  width: 94.8%;
  46.  } 
  47. a:hover#showall { 
  48. #ad-wrapper{ 
  49.   margin:0px auto 0px auto; 
  50.   text-align:center; 
  51. }
  52. </style> 
  53. </head>
  54. <body>
  55. <?php include('az.php'); ?>
  56. <div class="drop-shadow lifted" id="header"><img src="/test2/images/logo.png" alt="Reunite My Site - Company Logo" title="Reunite My Site - Company Logo"> </div>
  57. <div id="login">Login:&nbsp;<input type="username" class="login" size="20px;">
  58. <br />
  59. Password:&nbsp;<input class="login" type="password" size="20px">
  60. <br />
  61. Remember Me? <input type="checkbox">
  62. <a href="#">Register Now For Free!</a>
  63. <div class="note orange rounded">Start your Advertising or Publishing Campaign Now by simply clicking the Register Now button above!</div></div>
  64. <div name="target" id="target"><?php include 'results.php'; ?></div>
  65. </body>
  66. </html>


EDIT:: I typed slower than I was thinking just now so I fixed what i was saying at the top as well as the code tags that I messed up. This is a working example minus Mysql stuff. This will reload the parent page however it will load the contents into the target div.
  • Brian Jester
  • Beginner
  • Beginner
  • Brian Jester
  • Posts: 61
  • Loc: Bayonne, New Jersey USA

Post 3+ Months Ago

Hi Scott,

Thank you so much! That's exactly what I was trying to accomplish!

-Brian
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

No problem
  • Brian Jester
  • Beginner
  • Beginner
  • Brian Jester
  • Posts: 61
  • Loc: Bayonne, New Jersey USA

Post 3+ Months Ago

I hope I am not too late...

I need to output the results in multiple columns, something like a variable like: $cols = 4 will allow 4 records to display across the page, then automatically break to the next row. As it stands now, the output shows ads in a single column (several rows down the page).

Thank you in advance Scott!
Brian
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

Ok a couple things I've found.

First the when you build out the links (bottom of results.php page). In the while loop the link Isn't being closed with an </a> tag also in between the image and the text there is a random <p />. So in the test I put together I took out the < p /> And added an </a> to the end of the text.

This happened to make the script kind of work the next thing I noticed was (also in the while loop at the bottom) you had a c++; followed by another c++; which was messing with your $rows variable. Taking out one of these variables will make your script work correctly.

See the quoted text for reference

Quote:
while($row = mysql_fetch_array($result))
{
if($c%$rows==$rows-1) echo "<br/>";
echo "<a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"><p /> $row[alt]";
$c++;
$c++;
}


Here is an altered while loop that should work for you
PHP Code: [ Select ]
while($row = mysql_fetch_array($result))
            {  
                if($c%$rows==$rows-1) echo "<br/>";
                echo "<a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"> $row[alt]</a>";
                $c++;
            }
 
  1. while($row = mysql_fetch_array($result))
  2.             {  
  3.                 if($c%$rows==$rows-1) echo "<br/>";
  4.                 echo "<a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"> $row[alt]</a>";
  5.                 $c++;
  6.             }
  7.  


I am going to attach the test info I have as well. Warning Using this will not help you as I force fake database information to give me results I am providing it as a reference material only. This will give you an idea if the resulting changes are the desired effect.
Attachments:
test.zip

(193.52 KiB) Downloaded 63 times

  • Brian Jester
  • Beginner
  • Beginner
  • Brian Jester
  • Posts: 61
  • Loc: Bayonne, New Jersey USA

Post 3+ Months Ago

Hi Scott,

I want to put text under the banner such as the title of the ad, and some other info...Can you make it so that the text $row[alt] (the last one in the loop, cause the first and second are for alt and title text over the ad) shows under the banners? I tried a <br /> tag, but that affects all the banners displayed, I am guessing some table code, but I haven't worked with table code in who knows how long...Especially with php.

Thank you.
Brian
  • ScottG
  • Proficient
  • Proficient
  • ScottG
  • Posts: 477

Post 3+ Months Ago

Besides redoing the results page you could do something like this.
PHP Code: [ Select ]
while($row = mysql_fetch_array($result)) {  
     if($c%$rows==$rows-1) echo "<div style=\"clear: both;\">";
     echo "<div style=\"float:left;\"><a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"></a><br />$row[alt]</div>";
     $c++;
}
 
  1. while($row = mysql_fetch_array($result)) {  
  2.      if($c%$rows==$rows-1) echo "<div style=\"clear: both;\">";
  3.      echo "<div style=\"float:left;\"><a href=\"details.php?id=$row[n] \"><img class=\"ads\" alt=\"$row[alt]\" title=\"$row[alt]\" src=\"$row[banner]\"></a><br />$row[alt]</div>";
  4.      $c++;
  5. }
  6.  
  • Brian Jester
  • Beginner
  • Beginner
  • Brian Jester
  • Posts: 61
  • Loc: Bayonne, New Jersey USA

Post 3+ Months Ago

Thanks again Scot, you are very good help!

Brian

Post Information

  • Total Posts in this topic: 18 posts
  • Users browsing this forum: No registered users and 64 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.