Solved

MYQSLI help with limit

Posted on 2014-11-10
3
100 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
  • 2
3 Comments
 
LVL 109

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 109

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
This article discusses how to create an extensible mechanism for linked drop downs.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
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 …

777 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