Posted on 2008 under PHP |
8
Oct
After connect php website and database,we will try to get the content from the database,we can create a page which is called content.php.
And we just need to put this code in the <body> </body> part.
<?php
$query_subjects = “SELECT * FROM subjects”;
$query = mysql_query($query_subjects);
if(!$query) {
die(”Database selection failed: ” . mysql_error() );
}
//so we just have get the content from the database subjects table,now we need to display the content on the website.
while($ subject_row = mysql_fetch_array($query)) {
echo $row[menu_name] ;
}
?>
It will get all the meun_name from the database and it will display on your website.
Posted on 2008 under PHP |
8
Oct
We just need to create a file config.php
and have the code
<?php
//Database Constants
define(”DB_SERVER”, “localhost”);
define(”DB_USER”, “english_wefri”);
define(”DB_PASS”, “winnerlabel”);
define(”DB_NAME”, “english_wefriend”);
?>
then create a file which is called connection.php
and put the code in the file.
<?php
require(”constants.php”);
// 1.Create a database connection
$connection = mysql_connect(DB_SERVER,DB_USER,DB_PASS);
if(!$connection){
die(”Database connection failed:” . mysql_error());
}
// 2.Select a database
$db_select = mysql_select_db(DB_NAME,$connection);
if(!$db_select){
die(”Database selection failed: ” . mysql_error());
}
?>
Then we just connect the our site to the database.
And we can put different kinds of code after that in the <head> & </head> as well as <body> </body> party.
After finish that we shall close the database,we just need to create another file which is called footer.php
we just need to put the code
</div>
<div id=”footer”>Copyright 2007,Widget Corp</div>
</body>
</html>
<?php
if(isset($connection)){
mysql_close($connection);
}
?>
within the footer.php
so this three files help us with create a connection the our database and disconnect ourdatabase.
Posted on 2008 under PHP |
5
Oct
First,I’d like to post a small php script,
<?php
phpinfo();
?>
This script can help you know the php installed in your servers.You can put this script between the <body> </body>,and save your file in .php,then upload that file to your hosting.
visit that file,then you can get the information of php script of your hosting.