Jump to content

Nonks

New Members
  • Posts

    6
  • Joined

  • Last visited

Nonks's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. thanks Ian and Mac...i used another Code that's different from the one at the top and it works like a charm :happy-04: :happy-04: . Thank you so much for the help
  2. I hear what you are saying. Please help me on how you would you go about fixing this code, if you can because i have done everything i know and I'm just stuck and cant figure it out on my own
  3. hey Ian, i haven't tried debugging, I'm kinda new in PHP. so please tell me, why is the code working perfectly locally?? because i have tested it using different browsers but as soon as i Upload it stops working
  4. Im using PHP this is my form: <form class="searchbox" action="display.php" method="get"> <input type="text" name="keyword" placeholder="What?..." /> <input type="text" name="Countries" placeholder="Where?..." /> <button type="submit" ></button> </form> This is what i have before my header: <?php session_start(); if(isset($_GET['keyword']) && isset ($_GET['Countries']) ) { $_SESSION['sname'] = $_GET['keyword']; $_SESSION['cname'] = $_GET['Countries']; } ?> this is my PHP code including pagination: <?php include('includes/connect.php'); $Lname = isset( $_GET['sname'] )? $_GET['sname']: false; $mname = isset( $_GET['cname'] )? $_GET['cname']: false; $Lname= $_SESSION['sname']; $mname= $_SESSION['cname']; $tableName="company_details"; $tableName1 = "access_adverts"; $targetpage = "display.php"; $limit = 4; $number = 4; $Lname = mysql_real_escape_string($Lname); $mname = mysql_real_escape_string($mname); $query = "SELECT COUNT(*) as num FROM $tableName WHERE keyword LIKE '%$Lname%' AND Countries LIKE '%$mname%' ORDER BY Cname "; $total_pages = mysql_fetch_array(mysql_query($query)); $total_pages = $total_pages['num']; $stages = 3; $page = (isset($_GET['page'])) ? intval($_GET['page']) : 1; //$page = mysql_escape_string($_GET['page']); if($page){ $start = ($page - 1) * $limit; }else{ $start = 0; } // Get page data $query1 = "SELECT * FROM $tableName WHERE keyword LIKE '%$Lname%' AND Countries LIKE '%$mname%' ORDER BY CompId DESC LIMIT $start, $limit"; if ($page == 0){$page = 1;} $prev = $page - 1; $next = $page + 1; $lastpage = ceil($total_pages/$limit); $LastPagem1 = $lastpage - 1; $paginate = ''; if($lastpage > 1) { $paginate .= "<div class='paginate'>"; // Previous if ($page > 1){ $paginate.= "<a href='$targetpage?page=$prev'>previous</a>"; }else{ $paginate.= "<span class='disabled'>previous</span>"; } // Pages if ($lastpage < 7 + ($stages * 2)) // Not enough pages to breaking it up { for ($counter = 1; $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } elseif($lastpage > 5 + ($stages * 2)) // Enough pages to hide a few? { // Beginning only hide later pages if($page < 1 + ($stages * 2)) { for ($counter = 1; $counter < 4 + ($stages * 2); $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // Middle hide some front and some back elseif($lastpage - ($stages * 2) > $page && $page > ($stages * 2)) { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= ""; for ($counter = $page - $stages; $counter <= $page + $stages; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } $paginate.= "..."; $paginate.= "<a href='$targetpage?page=$LastPagem1'>$LastPagem1</a>"; $paginate.= "<a href='$targetpage?page=$lastpage'>$lastpage</a>"; } // End only hide early pages else { $paginate.= "<a href='$targetpage?page=1'>1</a>"; $paginate.= "<a href='$targetpage?page=2'>2</a>"; $paginate.= "..."; for ($counter = $lastpage - (2 + ($stages * 2)); $counter <= $lastpage; $counter++) { if ($counter == $page){ $paginate.= "<span class='current'>$counter</span>"; }else{ $paginate.= "<a href='$targetpage?page=$counter'>$counter</a>";} } } } // Next if ($page < $counter - 1){ $paginate.= "<a href='$targetpage?page=$next'>next</a>"; }else{ $paginate.= "<span class='disabled'>next</span>"; } $paginate.= "</div>"; } $sql=mysql_query("SELECT * FROM $tableName WHERE keyword LIKE '%$Lname%' AND Countries LIKE '%$mname%' ORDER BY CompId DESC LIMIT $start, $limit") or die (mysql_error()."<br>Error: Advanced Listings Error"); $count = mysql_num_rows($sql); while($row = mysql_fetch_array($sql)) { $adv_id = $row['CompId']; $img_id = $row['CompId']; //GET LOGO details from DB // $logo=mysql_query("SELECT lo_id, lo_path, lo_link FROM $db_name.access_logo WHERE CompId='$img_id' ")or die(mysql_error()); $cnt = mysql_num_rows($logo); if ($cnt == 0) { $logo=mysql_query("SELECT lo_path, lo_link FROM $db_name.access_adverts WHERE CompId='$adv_id' ")or die(mysql_error());} while($log = mysql_fetch_array($logo)) { $link=$log['lo_link']; $imgurl=$log['lo_path']; } //LOGO CODE ENDS // echo "<div class='newsbox11'><table width=\"900\" cellpadding=\"0\" cellspacing=\"0\" valign=\"bottom\" > <tr> <td width=\"75\" rowspan=\"1\" valign=\"top\"> <div class='aligner-image'> <a href='$link' target='blank' onClick=\"return popup2(this, 'notes')\"><img src=\"$imgurl\"border=\"0\" ></a> </div> </td> <td colspan=\"2\" valign=\"bottom\"> <div class='aligner2'> <b><font size='2' face = 'arial' color='#1b7a94'><a href='display.php?id=$adv_id' onClick=\"return popup1(this, 'notes')\">{$row['Cname']}</a></font> - <font size='2' face = 'arial' color='#1b7a94'></font> <font size='2' face = 'arial' color='#333'>{$row['Ccategory']}</font></b> <b><font size='2' face = 'arial' color='#333'>({$row['prov']})</font></b><br> <b><font size='2' face = 'arial' color='#333'>Tel:</font> <font size='2' face = 'arial' color='#333'>{$row['Ctel']}</font> | <font size='2' face = 'arial' color='#333'>Fax:</font> <font size='2' face = 'arial' color='#333'>{$row['Cfax']}</font></b> <br> <i><font size='2' face = 'arial' color='#929393'>{$row['physical']}</font></i> <br> <i><font size='2' face = 'arial' color='#929393'>{$row['Postal']}</font></i> <br> </div> </td> </tr> </table> </div> "; } ?> <br /> <div class="pag"> <?php echo $paginate; ?> </div>
  5. Hey guys, i was wondering if any1 cud help me. I have a database search engine that I'm currently working on, everything seems to be working fine locally including pagination but as soon as i upload the site online, the pagination doesn't work properly. when you use the search bar the results on the first page are correct, but as soon as you click next or page 2 it automatically returns wrong data. how can i fix this since it works fine locally???
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.