jaxdevil Posted April 18, 2008 Share Posted April 18, 2008 Well, there is my code below. I use the same code (with modification of the gooey HTML center) on another site, changing the sql connection settings of course, the results come up, it paginates, but it only shows 1 single result per page. I can't figure it out. Anyone see what I am doing wrong? <?php $result = mysql_query("SELECT count(*) FROM `equip` WHERE drop1 LIKE '%$searcht%' OR drop2 LIKE '%$searcht%' OR dtitle LIKE '%$searcht%'"); $num_records = mysql_result($result,0,0); // Set maximum number of rows and columns $max_num_rows = 3; $max_num_columns = 1; $per_page = $max_num_columns * $max_num_rows; // Work out how many pages there are $total_pages = ceil($num_records / $per_page); // Get the current page number if (isset($_GET['page'])) $page = $_GET['page']; else $page = 1; // Work out the limit offset $start = ($page - 1) * $per_page; // Select the results we want including limit and offset $brand = mysql_query("SELECT `brand` FROM `equip` WHERE drop1 LIKE '%$searcht%' OR drop2 LIKE '%$searcht%' OR dtitle LIKE '%$searcht%' ORDER BY `ID` ASC LIMIT $start, $per_page"); $modelo = mysql_query("SELECT `model` FROM `equip` WHERE drop1 LIKE '%$searcht%' OR drop2 LIKE '%$searcht%' OR dtitle LIKE '%$searcht%' ORDER BY `ID` ASC LIMIT $start, $per_page"); $dtitle = mysql_query("SELECT `dtitle` FROM `equip` WHERE drop1 LIKE '%$searcht%' OR drop2 LIKE '%$searcht%' OR dtitle LIKE '%$searcht%' ORDER BY `ID` ASC LIMIT $start, $per_page"); $ad_descrip = mysql_query("SELECT `ad_descrip` FROM `equip` WHERE drop1 LIKE '%$searcht%' OR drop2 LIKE '%$searcht%' OR dtitle LIKE '%$searcht%' ORDER BY `ID` ASC LIMIT $start, $per_page"); $price2 = mysql_query("SELECT `price2` FROM `equip` WHERE drop1 LIKE '%$searcht%' OR drop2 LIKE '%$searcht%' OR dtitle LIKE '%$searcht%' ORDER BY `ID` ASC LIMIT $start, $per_page"); $model = mysql_query("SELECT `model` FROM `equip` WHERE drop1 LIKE '%$searcht%' OR drop2 LIKE '%$searcht%' OR dtitle LIKE '%$searcht%' ORDER BY `ID` ASC LIMIT $start, $per_page"); $num_columns = ceil(mysql_num_rows($result)/$max_num_rows); $num_rows = ceil(mysql_num_rows($result)/$num_columns); echo "<center><table>\n"; for ($r = 0; $r < $max_num_rows; $r++){ echo "<tr align=\"center\">\n"; for ($c = 0; $c < $max_num_columns; $c++){ // 1 $x = $r * $max_num_columns + $c; if ($x < mysql_num_rows($result)){ // $y = mysql_result($result, $x, 0); // Commented out so I could show your example $brand = mysql_result($brand, $x, 0); $modelo = mysql_result($modelo, $x, 0); $dtitle = mysql_result($dtitle, $x, 0); $ad_descrip = mysql_result($ad_descrip, $x, 0); $price2 = mysql_result($price2, $x, 0); $model = mysql_result($model, $x, 0); $unformated_price = $price2; $price = number_format($unformated_price, 2, '.', ','); $y = <<<HTML <table> <tr> <td width="400"> <div style="padding-left:80px; padding-right:70px; "> <font face="Tahoma" color="000000" size="2"> <b>Brand:</b> {$brand} <br> </font> <font face="Tahoma" color="000000" size="2"> <b>Model:</b> {$model} <br> </font> <font face="Tahoma" color="000000" size="2"> <b>Description:</b> {$dtitle} <br> </font> <font face="Tahoma" color="000000" size="1"> {$ad_descrip} <br> </font> <font face="Tahoma" color="000000" size="2"> <b>Price:</b> {$price2} <br> </font> </div> </td> <td width="100"> <img src="inventory/tn_{$model}.jpg" border="0"> </td> </tr> </table> <hr> HTML; } else { $y = '<table align="center" border="0" cellpadding="0" cellspacing="0" width="400"> <tr> <td width="16" align="center"><center></center></td> </tr> </table>'; } echo "<td>"; echo "$y"; echo "</td>"; } echo "</tr>\n"; } // Echo page numbers echo "</table></center>\n"; ?> <? // Echo the results for ($i=1;$i <= $total_pages;$i++) { if ($i == $page) echo " $i "; else echo " <a href=\"?gs_cat=$gs_cat&page=$i\">$i</a> ";} ?> Link to comment https://forums.phpfreaks.com/topic/101642-multiple-result-pagination-paginates-but-shows-only-one-result/ Share on other sites More sharing options...
sasa Posted April 18, 2008 Share Posted April 18, 2008 wher you setup variable $searcht Link to comment https://forums.phpfreaks.com/topic/101642-multiple-result-pagination-paginates-but-shows-only-one-result/#findComment-520081 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.