PHP Queries

Query String The first step is to put the desired query into a PHP string:
$query = "SELECT first FROM names";
$query = "INSERT INTO names (first, last) VALUES ('Bobo', 'Bobobo')";
$query = "UPDATE names SET first='Alex' WHERE first='Alexander'";
Query Function The next step is to call a function that sends the string to the database:
$one_value = db_get_value($query);
$values = db_get_values($query);
$one_row = db_get_row($query);
$rows = db_get_rows($query);
Example
$query = "SELECT first, last FROM names";
$rows = db_get_rows($query);
for ($i = 0; $i < count($rows); $i++)  {
    $row = $rows[$i];
    echo $row[first] . " " . $row[last];
    echo "<br>";
}

Home