php tut

Example of PHP code.

Moderator: Moderators

php tut

Postby blacksheepradio on Wed Feb 09, 2005 4:09 am

yes some on... site content that changes automatically from a database
blacksheepradio
Registered User
Registered User
 
Posts: 2
Joined: Wed Feb 09, 2005 4:05 am

Postby robbie on Tue Feb 15, 2005 4:57 am

please elaborate... that's simple enough but what kind of site content do you want to change automatically etc?

connecting and displaying database stored content:
Code: Select all
<?php
mysql_connect("localhost", "user" , "pass");
mysql_select_db("databasename");

$query = mysql_query("SELECT Data FROM SiteContent WHERE Page = 'index' LIMIT 1");
$row = mysql_fetch_array($query);

$info = stripslashes( nl2br( $row['Data'] ) );

echo $info;

mysql_close();
?>


simply connecting to server/database, retrieving row where column "Page" has value "index" and getting the Data column's contents (the index page content).
next taking out escape slashes that are added when posted, and automatically dropping a line where necessary with nl2br. then lastly outputting the content and closing the connection.

hope thats what you wanted
User avatar
robbie
Coder
Coder
 
Posts: 67
Joined: Fri Mar 12, 2004 4:40 am
Location: New Zealand

Postby blacksheepradio on Tue Feb 15, 2005 12:26 pm

could be..... it hasn't sunk in yet (newbie)

some thing like a new "quote" or it loads different pics in particular spots.
blacksheepradio
Registered User
Registered User
 
Posts: 2
Joined: Wed Feb 09, 2005 4:05 am

Postby robbie on Thu Feb 24, 2005 9:02 am

www.hotscripts.com have an excellent range of free and commercial web scripts, including quote randomization and display scripts. check them out
User avatar
robbie
Coder
Coder
 
Posts: 67
Joined: Fri Mar 12, 2004 4:40 am
Location: New Zealand


Return to PHP Tutorials

Who is online

Users browsing this forum: No registered users and 1 guest