(The database i have) & insert data into fields on my webpages. So I can edit the site from a mysql database.
As far as I think understand, I have commented the code below...
Q-0= Please help explain what I have left un-defined with comment of "???". (also posted in its own code section at the bottom)
Please break down those 3 lines for me...
Please also correct where I am wrong... I know I have errors in my code, I always do :(
Q-1= Why the echo's? What do they do for me here?
Q-2= How do I seperate the database connection in a different file?
// this begins the php section
<?
//this connects to the database or dies with error
mysql_connect('localhost', 'user', 'pass', 'database') or die(mysql_error());
//this defines the database query to selecting everything from table blah, prior to filtering.
$query = mysql_query('SELECT * FROM blah');
//this opens a css div-id & div-class @ same time
echo '<div id="column_2" class="columnB-area">';
//this defines, stuff, as the variable to be used below, to define what to filter from query above.
while($stuff = mysql_fetch_array($query)) {
//this ???
echo '<h2>' . $stuff['heading] . '</h2>';
//this ???
echo '<img src="' . $stuff['image'] . '" alt="' . $stuff['title'] . '" />';
//this ???
echo '<p>' . $stuff['info'] . '</p>';
//this ends the php section
}
//this closes the open css div-id & div-class @ same time
echo '</div>';
The following code... I need broken down and explained, as to what each part is on each line. Im sure their pretty much the same, and there is a syntax being followed. For me, it kinda looks like Chinese right now though.
//this defines, stuff, as the variable to be used below, to define what to filter from query above.
while($stuff = mysql_fetch_array($query)) {
//this ???
echo '<h2>' . $stuff['heading] . '</h2>';
//this ???
echo '<img src="' . $stuff['image'] . '" alt="' . $stuff['title'] . '" />';
//this ???
echo '<p>' . $stuff['info'] . '</p>';
Thanks in Advance ;)