You connect to the database using PHP.
Start with a creating a connector like this, call it db.php;
$dbType = "mysql";
$dbUser = "UNAME";
$dbPass = "PWORD";
$dbServer = "SERVERNAME";
$dbName = "DBNAME";
$db_object = DB::connect("$dbType://$dbUser:$dbPass@$dbServer/$dbName");
if(DB::isError($db__object))
{
die($db__object->getMessage());
}
$db_object->setFetchMode(DB_FETCHMODE_ASSOC);
Now at the top of each page you create that needs to connect to the db you will need to include a line like this;
So in your code you would have whatever input method you choose (I prefer
FCKeditorFKeditor for news and content) and then the output displayed on another page.
news.php
[/quote]
require('../db.php')
$query = ("
SELECT news, date, username, story_id
FROM news
WHERE active='Y'
ORDER BY story_id DESC");
$result = $db_object->query($query);
if (DB::isError($result)) {
die($result->getMessage());
}
$num_results = $result->numRows();
echo '<h1> Latest Headlines </h1>';
for ($i=0; $i <$num_results; $i++) {
$row = $result->fetchRow(DB_FETCHMODE_ASSOC);
echo '<table cellpadding="0" cellspacing="0" border="1" style="text-align: left; width: 99%; background-color: rgb(204, 204, 204);">';
echo '<tbody>';
echo '<tr>';
echo '<td style="vertical-align: center; background-color: rgb(102, 51, 102);" rowspan="1" colspan="13"><font color="#ffffff"><b><div style="text-align: left;">';
echo '<span style="font-weight: bold;">Story posted by '.$row[username].' on '.$row[date].'</div></span></b></font>';
echo '</td>';
echo '</tr>';
echo '<tr>';
echo '<td style="vertical-align: top;"><small>';
echo $row[news];
echo '</small><br></td>';
echo '</tr>';
echo '<br>';
}
echo '</tbody>';
echo '</table>';
echo '<br>';
?>
<p align="center">
<button type="button" onclick="window.location='
http://www.mydomain.com/logout.php'">Logout</button><button
type="button"
onclick="window.location='
http://www.mydomain.com/home.php'">Back</button></p>
</body>
</html>[/quote]
There are many howto's on this out there. Also I recommend a couple of books;
PHP and MySQl Web Development Second Edition / Welling Thompson
MySQL/PHP Database Applications Greenspan & Bulger
SHUX