TalkPHP

TalkPHP (http://www.talkphp.com/forums.php)
-   Absolute Beginners (http://www.talkphp.com/absolute-beginners/)
-   -   Show database to HTML multy columm (http://www.talkphp.com/absolute-beginners/3504-show-database-html-multy-columm.html)

hacku 10-21-2008 07:04 AM

Show database to HTML multy columm
 
Hi Pro

I have a database. I want to show it to HTML with multi columm.

It like a gallery with image.

Please show me method to make columm like this.

Thks :'-(

Wildhoney 10-21-2008 09:28 PM

Like this layout?

html4strict Code:
<table>
    <tr>
        <td>Image 1</td>
        <td>Image 2</td>
        <td>Image 3</td>
    </tr>
    <tr>
        <td>Image 4</td>
        <td>Image 5</td>
        <td>Image 6</td>
    </tr>
</table>

9three 10-21-2008 11:16 PM

You can use mysql_fetch_object function to show your information in specific columns. They will be displayed in an array(a list) format. Here is an example:

PHP Code:

<?php

//Initial MySQL connection
$dbcnx = @mysql_connect('localhost''user''password');
if (!
dbcnx){
exit(
'<p>Error: Unable to connect</p>');
}

//Connecting the proper database
if (!@mysql_select_db('database_name')){
exit(
'<p>Error: Unable to connect to your data base</p>');
}

//Requesting our table
$result = @mysql_query('SELECT  from table_name');
if (!
$result){
exit(
'<p>Error: Unable to query: ' .mysql_error(). ' </p>');
}

//Display table
while ($row mysql_fetch_object('$result')){
echo 
$row->info1;
echo 
$row->info2;
}

Now all you have to do is wherever you want to display a column use $row->info1 depending on the names you used in your database to display it in an array.


All times are GMT. The time now is 05:23 AM.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0