Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 536239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T09:48:03+00:00 2026-05-13T09:48:03+00:00

I have the following prepared statement: $sql = PREPARE stmt_name FROM ‘SELECT I.item_id, I.name

  • 0

I have the following prepared statement:

$sql =
     "PREPARE stmt_name FROM 
    'SELECT I.item_id, I.name , I.price, I.discounted_price, I.thumbnail_photo
    FROM item I
    JOIN sub_category SC
    ON I.sub_category_id = SC.sub_category_id
    JOIN category C
    ON C.category_id = SC.category_id
    WHERE C.category_id = ?
    LIMIT ?,? ' ; 

    SET @p1 = categoryId;
    SET @p2 = firstItem;
    SET @p3 = items_per_page;

    EXECUTE stmt_name USING @p1,@p2,@p3; "

which i changed to the following(wihtout using prepared statement)

$sql =

    'SELECT I.item_id, I.name , I.price, I.discounted_price, I.thumbnail_photo
    FROM item I
    JOIN sub_category SC
    ON I.sub_category_id = SC.sub_category_id
    JOIN category C
    ON C.category_id = SC.category_id
    WHERE C.category_id =' . (int)$categoryId;

I want to add parameters to the LIMIT clause
Ive gone through some sites, and it seems that adding parameters to the LIMIT clause in a select statement can be done only by using prepared statements. Can I have your opinions and suggestions please?

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T09:48:04+00:00Added an answer on May 13, 2026 at 9:48 am

    It looks like you’re using concatenation, rather than parameters, to build your new SELECT query. If you’d like to continue down this road, you’d just append to your code:

    . ' LIMIT ' . (int)$start . ', ' . (int)$number;
    

    If you’d prefer to used a parameterized query, you’ll need to use PHP’s built-in PDO or mysqli extensions, or choose an abstraction layer with support for parameterized queries such as ADOdb. Parameterized queries are often viewed as safer and cleaner than simply building queries through string concatenation.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to set the result from a prepared statement into a variable?
I have a PDO prepared statement in which the bound variables are prepared dynamically
I have the following table holding virtual money for weekly tournaments: # select *
I currently have to implement a query on a postgres database using a prepared
I have code similar to the following: $data['someField'] = (isset($_POST['someField'])) ? 'Y' : 'N';
I have a table with about 1.4 billion records, with the following format: mysql>
I am using iBatis with spring framework. I want to log the sql that
I have a form which has two inputs. The first input allows a user
Greetings, I am developing an Admin Control panel and I have to use ODBC
It is said to be a good habit to close all JDBC resources after

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.