Jump to content

[SOLVED] Need to limit returns


WebGuyRI

Recommended Posts

Using new code picked up here from a previous problem I was having. This code is really working fine and gives me what I need. The issue is I need to limit the number of rows returned.

 

Thanks in advance

 

$query = "SELECT CONCAT('',name,name2,name3,name4,name5,name6,name7,name8,name9,name10) as n FROM $usertable HAVING n LIKE '%$name%'";

 

$result = mysql_query($query) or DIE("Could not Execute Query on table $usertable");

if ($result) {

 

    print "Query successful on table $usertable<br><br>";

    print "Your Query returned:<br>";

    while ($row = mysql_fetch_array($result)) {

    print $row['n'] . "<br/>";

Link to comment
https://forums.phpfreaks.com/topic/168432-solved-need-to-limit-returns/
Share on other sites

just add to your while loop a and expression

 

$query = "SELECT CONCAT('',name,name2,name3,name4,name5,name6,name7,name8,name9,name10) as n FROM $usertable HAVING n LIKE '%$name%'";

$result = mysql_query($query) or DIE("Could not Execute Query on table $usertable");
$i = 0;
if ($result) {
    
    print "Query successful on table $usertable<br><br>";
    print "Your Query returned:<br>";
    while ($row = mysql_fetch_array($result)&& $i != $maxrows) {
             $i++;
             print $row['n'] . "<br/>";
             }
}

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.