I’m quite new with PHP, basically I want to get two values from a database from the same field but different rows. The database has the following values:
----SetupId----DayHalf-----StartTime------
--------1------------1------------07:00----------
--------2------------2------------23:00----------
In textbox 1 I want to display the value ‘07:00’ In textbox 2 I want to display the value ‘23:00’
The code I have at the moment is as follows:
[php]class OptionsController {
Functions
public static function getOptionsInfo() {
$pdo = new SQL();
$dbh = $pdo->connect(Database::$serverIP, Database::$serverPort, Database::$dbName, Database::$user, Database::$pass);
try {
$query = "SELECT StartTime FROM tbldaysetup";
$stmt = $dbh->prepare($query);
$stmt->execute();
$row = $stmt->fetch(PDO::FETCH_BOTH);
DaySetup::set_daytime($row['StartTime']);
$stmt->closeCursor();
}
catch (PDOException $pe) {
die("Error: " .$pe->getMessage(). " Query: ".$stmt->queryString);
}
$dbh = null;
}
}
?>[/php]
I then use the code below to output ‘07:00’ into the first textbox:
[php] <? echo DaySetup::get_daytime(); ?>[/php]
So how would I go about querying the database for the second value and outputting this value in a textbox. Any help to help me understand this would be much appreciated!