| ADOdb Library for PHP Manual | ||
|---|---|---|
| Prev | MySQL and Menus | Next |
Connect to MySQL database agora, and generate a <select> menu from an SQL statement where the <option> captions are in the 1st column, and the value to send back to the server is in the 2nd column.
<?php
include('adodb.inc.php'); #
load code common to ADOdb
$conn = &ADONewConnection('mysql'); #
create a connection
$conn->PConnect('localhost','userid','','agora'); #
connect to MySQL, agora db
$sql = 'select
CustomerName, CustomerID from customers';
$rs = $conn->Execute($sql);
print $rs->GetMenu('GetCust','Mary
Rosli');
?>
Here we define a menu named GetCust, with the menu option 'Mary Rosli' selected. See GetMenu(). We also have functions that return the recordset as an array: GetArray(), and as an associative array with the key being the first column: GetAssoc().
| Prev | Home | Next |
| Debugging | Up | Connecting to Multiple Databases at once |