This is a small article containing tricks and tips I aquired by reading PHP 6 Text Book.
I was used isset() function to check whether these arguements are set or not. And also I need to check this is empty or not.
Here is another function to check both of this requirement at single line.
empty()
It checks if a variable has an empty value: an empty string, 0, NULL,or FALSE.
Example
if ( !empty($_POST[‘name’]) && !empty($_POST[‘comments’]) && !empty($_POST[‘email’]) ) {
echo “Yes”;
}
The below code help you to export data from database to csv file
exporttoxls
To export a complete database, you should invoke all the tables via below code and apply the above code
$dbname = ‘mysql_dbname’;
if (!mysql_connect(‘mysql_host’, ‘mysql_user’, ‘mysql_password’)) {
echo ‘Could not connect to mysql’;
exit;
}
$sql = “SHOW TABLES FROM $dbname”;
$result = mysql_query($sql);
if (!$result) {
echo “DB Error, could not list tables\n”;
echo ‘MySQL Error: ‘ . mysql_error();
exit;
}
while ($row = mysql_fetch_row($result)) {
echo “Table: {$row[0]}\n”;
}
mysql_free_result($result);
?>
How to create a directory structure ? or
How to creata a tree structure ? or
How to design a database for a tree structure ? or
How to design a database for storing hierarchical structure ?
using single table
Create a table like this

CREATE TABLE `category` (
`id` int(11) NOT NULL auto_increment,
`name` varchar(50) default NULL,
`descr` text,
`parent` int(11) default NOT NULL,
PRIMARY KEY (`id`)
)
This table containing fields id,name,description and parent.Here all are familiar fields except parent.
Parent field is used to store the id of parent item . So that we can select the sub category by querying the database
with parent==id .
First upon we have to display main category by querying parent==’0′,
Then sub category by querying parent==1 or some thing like that
I think this information useful .
Regards,
Arun Raj R
Kadampanad