Hello,
I wondered if anyone could offer some guidance, I trying to write a
php script to connect to a database, and display the records in a
table.
I found the code here in a php4 text, and when I run this directly
through the php intrupeter, the line Successfully connected is display
and 4 as the number of rows.
The database table we connect to, has three field username, firstname,
surname.
When I tried a while loop, to display the data in a table. No values
were displayed.
Could anyone possibly demonstrate how to display the username,
firstname, surname values in a basic table?
Thank you
<?php
function db_connect(){
global $MYSQL_ERRNO, $MYSQL_ERROR;
$link_id = mysql_connect(" localhost","use r04", "password04 ");
if(!$link_id){
$MYSQL_ERROR = "Connection failed";
return 0;
}
else if(empty($dbnam e) && !mysql_select_d b("database04") ){
$MYSQL_ERROR = mysql_error();
return 0;
} else return $link_id;
}
!$link_id = db_connect();
if(!$link_id) die(error_messa ge('Error connecting'));
$result = mysql_query("SE LECT * FROM users");
if(!$result) error_message(' Error in selection');
else echo "Successful ly connected. ";
$query_data = mysql_fetch_arr ay($result);
$total_records = $query_data[0];
if(!$total_reco rds) error_message(' No records');
else echo "$total_records .";
?>
I wondered if anyone could offer some guidance, I trying to write a
php script to connect to a database, and display the records in a
table.
I found the code here in a php4 text, and when I run this directly
through the php intrupeter, the line Successfully connected is display
and 4 as the number of rows.
The database table we connect to, has three field username, firstname,
surname.
When I tried a while loop, to display the data in a table. No values
were displayed.
Could anyone possibly demonstrate how to display the username,
firstname, surname values in a basic table?
Thank you
<?php
function db_connect(){
global $MYSQL_ERRNO, $MYSQL_ERROR;
$link_id = mysql_connect(" localhost","use r04", "password04 ");
if(!$link_id){
$MYSQL_ERROR = "Connection failed";
return 0;
}
else if(empty($dbnam e) && !mysql_select_d b("database04") ){
$MYSQL_ERROR = mysql_error();
return 0;
} else return $link_id;
}
!$link_id = db_connect();
if(!$link_id) die(error_messa ge('Error connecting'));
$result = mysql_query("SE LECT * FROM users");
if(!$result) error_message(' Error in selection');
else echo "Successful ly connected. ";
$query_data = mysql_fetch_arr ay($result);
$total_records = $query_data[0];
if(!$total_reco rds) error_message(' No records');
else echo "$total_records .";
?>
Comment