//Connect to Database
$db = mysql_connect("localhost", "links-write", "Svenska257");
mysql_select_db("links",$db);
// If current page number, use it
// if not, set one!
if(!isset($_GET['page'])){
$page = 1;
} else {
$page = $_GET['page'];
}
// Define the number of results per page
$max_results = 500;
// Figure out the limit for the query based
// on the current page number.
$from = (($page * $max_results) - $max_results);
if ($sort) {
//They wanna sort the results
//$result = mysql_query("SELECT * FROM loads WHERE status=1 ORDER BY \"$sort\" LIMIT $from, $max_results",$db);
//$result = mysql_query("SELECT * FROM trucks ORDER BY \"$sort\"",$db);
} else {
//Give them the default view
$result = mysql_query("SELECT * FROM directory WHERE owner = 'kimberly' ORDER BY state,name",$db);
}
?>
New York Real Estate Index
// Figure out the total number of results in DB:
$total_results = mysql_result(mysql_query("SELECT COUNT(*) as Num FROM directory"),0);
// Figure out the total number of pages. Always round up using ceil()
$total_pages = ceil($total_results / $max_results);
?>
Add Agency
// Build the Index Page
if ($myrow = mysql_fetch_array($result)) {
echo "\n";
printf( " | Name | Town | State |
\n");
do {
printf("Edit\Delete | %s | %s | %s |
\n",$myrow["id"],$myrow["name"],$myrow["city"],$myrow["state"]);
}
while ($myrow = mysql_fetch_array($result));
echo "
\n";
} else {
echo "Sorry, No Links Were Found. | \n";
}
?>
Add Agency