View Single Post
Old 12-27-2007, 09:11 PM   #10 (permalink)
sjaq
The Acquainted
 
sjaq's Avatar
 
Join Date: Nov 2007
Location: Netherlands
Posts: 113
Thanks: 11
sjaq is on a distinguished road
Default

So you really don't understand the use of MySQL if you don't know how to do that

But here's a basic script that does what I think you want to do..
First there is the database structure:

and the database content:


The script:
PHP Code:
<?php 

    $connection 
mysql_connect('localhost''root') or die('database connection failed: 'mysql_error());
                 @
mysql_select_db('testing'$connection);
    
    
$query mysql_query('SELECT * FROM test_row') or die(mysql_error());
    
    while(
$row mysql_fetch_object($query)) {
        print 
'<h2>'$row->name .'</h2>'"\n";
        print 
'<h3>price: $ '$row->price .'</h3>'"\n";
        print 
'<p>'$row->description .'</p>' "\n";
    }
    
    
mysql_free_result($query);
    
mysql_close($connection);

?>
Which produces:
HTML Code:
<h2>iPod nano</h2>
<h3>price: $ 400</h3>
<p>Some iPod description here</p>
<h2>MacBook Pro</h2>
<h3>price: $ 3000</h3>
<p>MacBook Pro description here</p>
<h2>Towel</h2>
<h3>price: $ 15</h3>
<p>This is a awesome towel! (it has dolphins on it!)</p>
Hope you see how to use MySQL now..
sjaq is offline  
Reply With Quote