Solved

MYQSLI help with limit

Posted on 2014-11-10
3
104 Views
Last Modified: 2014-11-10
Hi,

Im using Mysqli and im trying to limit the results by 10 and order them from last to first from the database.

$sqlhorses = "SELECT Place FROM `*` WHERE `Horse` ='".$db->real_escape_string($row['horse']). "'";

Open in new window


the above works but when i added the limit 6 to the end it shows errors.

Can anyone help?
0
Comment
Question by:runnerjp2005
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 110

Accepted Solution

by:
Ray Paseur earned 500 total points
ID: 40432457
Is this the table name? `*`

It's usually easier to get query strings right if you avoid compound statements and use HEREDOC notation (search PHP.net for that) or if you use double quotes.  Maybe something like this:

$horse = $db->real_escape_string($row['horse']);
$sqlhorses = "SELECT * FROM Place WHERE  HORSE = '$horse' ";
// OR...
$sqlhorses = "SELECT * FROM Place WHERE  HORSE = '$horse' LIMIT 10";

Open in new window

0
 

Author Closing Comment

by:runnerjp2005
ID: 40432480
Perfect thanks.... i just added * to limit the amount of my table structure im sharing
0
 
LVL 110

Expert Comment

by:Ray Paseur
ID: 40432746
Thanks for the points - glad you've got it pointed in the right direction! ~Ray
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
This article discusses how to create an extensible mechanism for linked drop downs.
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

696 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question