|
|
|
<?
//MyDB represents the name of your database.
//MyTable represents the name of your table inside the database.
mysql_connect("localhost","","") or die("Unable to connect to SQL server");
@mysql_select_db("MyDB") or die("Unable to select database");
$result = mysql_query("select * from MyTable limit 100");
?>
<table border="1">
<tr>
<?
while ($field=mysql_fetch_field($result)) {
echo "<th>";
echo "$field->name";
echo "</th>";
}
echo "</tr>";
while ($row = mysql_fetch_row($result)) {
echo "<tr>";
for ($i=0; $i<mysql_num_fields($result); $i++) {
echo "<td>";
echo "$row[$i]";
echo "</td>";
}
echo "</tr>\n";
}
echo "</table>";
?>
|
|
| html split bar used to split in multiple pages a database result Categories : HTML and PHP, Databases, MySQL, PHP | | | Message of the Day - Random Message (Needs MySQL!) Categories : Databases, HTML and PHP, PHP, MySQL | | | Alternating background color for HTML table rows Categories : PHP, Databases, MySQL, HTML and PHP | | | A very simple way to build and do a hierarchical html categories browser without javascript , just using html php and mySql
Categories : HTML and PHP, Databases, Algorithms, PHP, MySQL | | | Pull Down Surfing - Surf on Change Categories : Java Script, MySQL, HTML and PHP, PHP, Databases | | | Dynamically generated pop-ups (Select items) Categories : PHP, HTML and PHP, MySQL, Databases | | | Creating thumbnails from MySQL Blobs online Categories : PHP, MySQL, Graphics, HTML and PHP, Databases | | | Record Set Paging with PHP (RSP) Categories : PHP, MySQL, Navigation, Databases, HTML and PHP | | | Functions for loading images into a MySQL database and displaying them. Categories : Graphics, HTML and PHP, MySQL, PHP, Databases | | | dynamic table columns Categories : PHP, HTML and PHP, Arrays, Databases, MySQL | | | Editing the virtusertable and sendmail.cw via PHP3.0 and Mysql Categories : MySQL, HTML and PHP, PHP, Databases | | | This function will populate the options in a drop down HTML select list
in a form from a database query.
Categories : MySQL, General SQL, PHP, HTML and PHP, Databases | | | How can i Preload a 'SELECT MULTIPLE'? Categories : HTML and PHP, PHP, MySQL, Databases | | | Paginating the mySQL data Categories : PHP, Algorithms, Databases, MySQL, HTML and PHP | | | PHP and MySQL scripting for Muyltiple CheckBoxes Categories : HTML and PHP, MySQL, Databases, PHP | |
| | | | Jerry Freeman wrote : 70
Are you sure this works?
I`ve tried substituing my login and table name and got
the error
Warning: 0 is not a MySQL result index in
/mnt/web/guide/clipartgallery/www/print.php3 on line 9
Warning: 0 is not a MySQL result index in
/mnt/web/guide/clipartgallery/www/print.php3 on line 16
I`m a novice and I`m confused.
| | | | Boaz Yahav wrote : 71
This works alright :)
What you got only means that you didn`t get any
results from the sql query.
Check your connection, and make sure that your query
did not return empty.
berber
| | | | Gerd Klingenspor wrote : 331
No, it doesn´t work!
You have to change the following:
@mysql_select_db("php3") or die("Unable to select
database");
!!! This "php3" is the name of the database!!!
$result = mysql_query("select * from php3 limit 100");
!!!And this "php3" has to be the name of the table you
want to look at!!!
And after you make the above changes it will work fine.
Gerd
| | | | Boaz Yahav wrote : 332
I saw the misunderstandings to i simply replaces the
php3 in the connection line to "MyDB" and the php3 in
the query to "MyTable".
| | | | Ray smith wrote : 805
Thank you for this script!!! It worked for me :)
| | | | Dimitrios Zinas wrote :829
Thank you... It works just perfect.
| |
|
|
|