Clarkinator
Clarkinator

Reputation: 79

Select 1 row from select statement php

$query = "SELECT questionid, surveyid, question, responsetype, imageid FROM questions WHERE surveyid = " . $_POST['survey'] .";";
$result = $mysqli->query($query);
$row = $result->fetch_array(3);

I'm trying to get the 3rd row of this select statement. The last line didn't work and returns the first line and I've been trying for an hour looking around StackOverflow and the PHP website and can't find anything. Is there any way to do this?

Upvotes: 0

Views: 54

Answers (1)

John Conde
John Conde

Reputation: 219924

Just use a LIMIT clause in your SQL statement:

$query = "SELECT questionid, surveyid, question, responsetype, imageid 
FROM questions WHERE surveyid = " . $_POST['survey'] ." LIMIT 2,1;";

The 2 means start at the third row (remember we start counting at zero) and the 1 means return one row.

Upvotes: 2

Related Questions