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
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/>";
             }
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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