alright, i'm new to php, so please don't kill me if my error is rather blatent, but... i'm currently trying to set up a mysql database driven site. i've got the code that sends information into the database to work perfectly.. but i can't, for the life of me draw the data from the database back onto the page.. so.. here's the code: (by the way - my server doesn't require a username or password to connect, so that's not the problem)
<?php
$table_name = "news";
$dbname = "slide_away";
$id_link = @mysql_connect("localhost","","");
if (! $id_link) {
echo '<head><title>Error</title></head><body>';
echo 'Connection to PHP has failed.';
echo '</body>';
exit();
}
$str_sql_all = "
select count(*) as number_of_records
from $table_name
";
$result =
mysql_db_query($dbname, $str_sql_all, $id_link);
$record = @mysql_fetch_object($result);
$number_of_records = $record->number_of_records;
$number_records_to_display = 8;
$initial_record = $number_of_records;
$sort_field = 'key_news';
$sort_direction = 'DESC';
$str_sql = "
select *
from $table_name
order by $sort_field $sort_direction
limit $initial_record, $number_records_to_display
";
$result = mysql_db_query($dbname, $str_sql, $id_link);
$number_of_records_on_current_page =
@mysql_num_rows($result);
?>
and then in the main table this:
<?php
for ($iindex = 0; $iindex < $number_of_rows; $iindex++) {
$record = @mysql_fetch_object($result);
echo '$record->date_shown : $record->update_headline <br>';
}
?>
any help would be greatly appreciated.. thanks