Jump to content

Dynamic LIMIT for recordsets


Recommended Posts

Hi all,

 

I'm still very novice when it comes to PHP/mySQL.

Here's what i'm trying to do.....I think the way that DW inserts the code is making it hard for me to figure out myself

 

I need to somehow limit the output of a recordset using dynamic values - I don't know if it's easier to do this when defining the recordset (using LIMIT) or when ECHOing the results on the page in a different way

 

Any pointers would be VERY much appreciated

 

Cheers

 

 

Link to comment
Share on other sites

Myself I always use a mysql statement as much as I can to filter the data. It's a lot more efficient than selecting a whole table and filtering it yourself with php.

 

just incorporate the values as variables into your query

 

$query = "SELECT * FROM my_table WHERE this=that LIMIT $row_offset, $rows";

OR you can only select certain fields as well

$query = "SELECT column1, column2, column4 FROM my_table WHERE this=that LIMIT $row_offset, $rows";

AND you may also skip the offset if you just want the first x rows

 

moving on...

 

then store the result

$result = mysql_query($query);

 

then do whatever with the result set

 

Hopefully thats what you were talking about :P

Link to comment
Share on other sites

LIMIT works, but if you require pagination you will need a more suitable arrangement. Check phpfreaks pagination tutorial to find out more.

 

As you posted in the Dreamweaver forum I assume you are using dreaweaver. Use the behaviours in the application panel. You can dynamically limit the recors returned from there. F1 launches the manual.

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.