Home
   About Me
   Rene's Resume
   Presentations
   Services
   Rates & Contracts
   Portfolio / Clients
   Demo Apps
   White Papers & Tips
   Tutorials
   Contact Me
 

Displaying: select_code.php


Deprecated: Function ereg_replace() is deprecated in /home/astute/www/html/tutorials/mysql/display.php on line 14 Deprecated: Function ereg_replace() is deprecated in /home/astute/www/html/tutorials/mysql/display.php on line 20

Deprecated: Function ereg_replace() is deprecated in /home/astute/www/html/tutorials/mysql/display.php on line 31

Deprecated: Function ereg_replace() is deprecated in /home/astute/www/html/tutorials/mysql/display.php on line 32

Deprecated: Function ereg_replace() is deprecated in /home/astute/www/html/tutorials/mysql/display.php on line 33
<?php
require_once $_SERVER['DOCUMENT_ROOT'].'/util.php';
printHeader('Astute Computing - Internet/Database/IT Consultant','');

$sql = new MySQL_class;
$sql->Create("churchil_demo");

#
# Selecting a single item
#
echo("<h3>Selecting a single item:</h3>\n");
$name = $sql->QueryItem("select Name from TEST where ID = 4");
echo("<ul>Name is: $name</ul>\n");

#
# Selecting a single row
#
echo("<h3>Selecting a single row:</h3>\n");
$sql->QueryRow("select * from TEST where ID = 4");
$row = $sql->data;
echo("<ul><p>Referencing by array numbers:<ul>\n");
echo("row[0] = $row[0]<br>\n");
echo("row[1] = $row[1]<br>\n");
echo("row[2] = $row[2]<br>\n");
echo("row[3] = $row[3]</ul>\n");

echo("<p>Referencing by column names:<ul>\n");
echo("row[ID] = $row[ID]<br>\n");
echo("row[Name] = $row[Name]<br>\n");
echo("row[Age] = $row[Age]<br>\n");
echo("row[Salary] = $row[Salary]</ul></ul>\n");

#
# Selecting Multiple Rows
#
echo("<h3>Selecting multiple rows</h3>\n");
echo("<p><ul><table border=1 cellpadding=4>\n");
echo("<tr><th>Name</th><th>Age</th></tr>\n");
$sql->Query("Select Name, Age from TEST order by Age");
for ($i = 0; $i < $sql->rows; $i++) {
    $sql->Fetch($i);
    $name = $sql->data[0];
    $age = $sql->data[1];
    echo("<tr><td>$name</td><td>$age</td></tr>\n");
}
echo("</table></ul>\n");

echo("\n");
echo("<a href=\"display.php?file=select_code.php\">Display\n");
echo("the code for this file</a>\n");
?>

<a href="JavaScript:window.history.back()">Back to the Demo</a>
<?php printFooter(); ?>
Back
 

This page was generated in 0.0044 seconds.
Website content © 2024