dannel77 Posted April 10, 2006 Share Posted April 10, 2006 Hi, could someone tell me why this search script with paging isn't working:<?php// database connectionmysql_connect("$host","$user","$pass");// database selectionmysql_select_db("$database");// Nu bestämmer vi antal per sida och kollar vi upp totala antalet$limit = 30; // Antal per sida $result = mysql_query("SELECT COUNT(*) FROM products WHERE $chose LIKE '%$searchstring%'") or die("Error fetching number in DB<br>".mysql_error());$row = @mysql_fetch_array($result);$numrows = $row['count']; // Antal i databasen // Sedan kollar vi om startvariabeln är sattif (!isset($_GET['start']) || $_GET['start'] == "") $start = 0;else $start = $_GET['start']; // Då räknar vi ut hur många sidor det blev$pages = intval($numrows/$limit);if ($numrows%$limit) $pages++;// Hämta sidonummerfor ($i = 1; $i <= $pages; $i++) { $newoffset = $limit*($i-1); if ($start == $newoffset) $numlink .= '<font color="#000000" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;">| <b>'.$i.'</b></font> '; else $numlink .= '<font color="#000000" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;">| </font><a href="?start='.$newoffset.'&maingroup='.$maingroup.'&secondgroup='.$secondgroup.'"><font color="#2B65EC" style="font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10px;">'.$i.'</font></a> ';} // Nu kan vi hämta datan från databasen och skriva ut den$result = mysql_query("SELECT * FROM products WHERE $chose LIKE '%$searchstring%' ORDER BY 'maingroup', 'secondgroup', 'item' LIMIT $start, $limit") or die("Error fetching data<br>".mysql_error());while ($row = @mysql_fetch_array($result)){$color = ($coloralternator++ %2 ? "D5E2EC" : "EBF1F5"); echo "<TR BGCOLOR=\"#$color\"><TD ALIGN=\"middle\"><a href=\"item_show.php?code_no=$row[2]\" TARGET=\"main\"><IMG SRC=\"thumbs/$row[6]\" BORDER=\"0\"></a></TD>";echo "<TD ALIGN=\"left\"><font style=\"font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif;\"><a href=\"item_show.php?code_no=$row[2]\" TARGET=\"main\"> $row[2] </FONT></TD>";echo "<TD ALIGN=\"left\"></a><font style=\"font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif;\"><a href=\"item_show.php?code_no=$row[2]\" TARGET=\"main\"> $row[3] </FONT></TD>";echo "<TD ALIGN=\"right\"></a><font style=\"font-size: 10px; font-family: Verdana, Arial, Helvetica, sans-serif;\"> $row[5] </font></TD>";echo "<TD ALIGN=\"middle\"> <INPUT TYPE=\"hidden\" NAME=\"id$row[2]quant\" VALUE=\"1\"><a href=\"Javascript:top.center.cart.addItem('$row[3]','$row[5]', document.itemsform.id$row[2]quant.value, '$row[2]', '$row[7]')\"><img src=\"images/buy.gif\" border=\"0\"></a> </TD></TR>";}"</center>"?>Any help appreciated! Link to comment https://forums.phpfreaks.com/topic/7022-help-with-search-scriptplease/ Share on other sites More sharing options...
trq Posted April 10, 2006 Share Posted April 10, 2006 Not unless you tell us what you meen by [i]isn't working[/i].Are you getting any errors? What are they? Link to comment https://forums.phpfreaks.com/topic/7022-help-with-search-scriptplease/#findComment-25495 Share on other sites More sharing options...
dannel77 Posted April 16, 2006 Author Share Posted April 16, 2006 The search works, but the paging of the results does not...[!--quoteo(post=363294:date=Apr 10 2006, 08:53 AM:name=thorpe)--][div class=\'quotetop\']QUOTE(thorpe @ Apr 10 2006, 08:53 AM) [snapback]363294[/snapback][/div][div class=\'quotemain\'][!--quotec--]Not unless you tell us what you meen by [i]isn't working[/i].Are you getting any errors? What are they?[/quote] Link to comment https://forums.phpfreaks.com/topic/7022-help-with-search-scriptplease/#findComment-27451 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.