Writing Data from a MySQL DB Into a Table
Moderator: General Moderators
Writing Data from a MySQL DB Into a Table
I saw a tutorial on this somewhere, but can't seem to find it again. If anyone knows where I can find a tutorial like this, please tell me. Thanks a lot for your help!
It works the same way though.
HTML is HTML. PHP doesn't care, doesn't even now that you are sticking it into a table.
Take this:
And make it this:
That code is from the tutorial.
I don't see how much more of a tutorial you need. However, if you feel their is more to talk about, let me know what specifically you would want to know. Otherwise, I don't see the need for a tutorial specifically covering how to display variables in a table. Whether those variables come from a MySQL query or someplace else isn't important. Makes no difference.
HTML is HTML. PHP doesn't care, doesn't even now that you are sticking it into a table.
Take this:
Code: Select all
$dbconn = mysql_connect("localhost", "username", "password");
$result = mysql_select_db("database_name", $dbconn);
if ( $result == false )
{
echo mysql_error();
} else {
$sql = "SELECT fname, lname, email FROM friends";
$result = mysql_query( $sql );
if ( $result != false )
{
while ( $data = mysql_fetch_assoc( $result ) )
{
echo 'Name: '.
$dataї'fname'].' '.
$dataї'lname'].' (<a href="mailto:'.
$dataї'email'].'">'.
$dataї'email'].'</a> )<br />';
}
} else {
echo mysql_error();
}
}Code: Select all
$dbconn = mysql_connect("localhost", "username", "password");
$result = mysql_select_db("database_name", $dbconn);
if ( $result == false )
{
echo mysql_error();
} else {
$sql = "SELECT fname, lname, email FROM friends";
$result = mysql_query( $sql );
if ( $result != false )
{
echo '<table border="1">';
while ( $data = mysql_fetch_assoc( $result ) )
{
echo '<tr><td>';
echo 'Name: '.
$dataї'fname'].' '.
$dataї'lname'].' (<a href="mailto:'.
$dataї'email'].'">'.
$dataї'email'].'</a> )<br />';
echo '</td></tr>
}
echo '</table>';
} else {
echo mysql_error();
}
}I don't see how much more of a tutorial you need. However, if you feel their is more to talk about, let me know what specifically you would want to know. Otherwise, I don't see the need for a tutorial specifically covering how to display variables in a table. Whether those variables come from a MySQL query or someplace else isn't important. Makes no difference.