Get Adobe Flash player

Build An XML File Using PHP

August 6th, 2010 | Comments Off
category: Software

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
<?php
// first create a new database. in this example it will be 'vidgallery'

// second, connect to that database
$dbhost="localhost";  Database Hostname (Most is: localhost)
$dbusername="root";   Database  Username
$dbpassword="******";   Database  Password
$dbname="vidgallery"; Database Name

// Connect to MySQL
$connect = mysql_connect($dbhost,$dbusername,$dbpassword);

//Select the correct database.
$db = mysql_select_db($dbname,$connect) or die(mysql_error());

?>
1
2
3
4
5
6
7
8
9
10
11
12
-- third we will create a table in sql

CREATE TABLE IF NOT EXISTS `theVideo` (
  `vidTitle` varchar(255) NOT NULL,
  `vidProject` varchar(255) NOT NULL,
  `vidClient` varchar(255) NOT NULL,
  `vidRole` varchar(255) NOT NULL,
  `vidPath` varchar(255) NOT NULL,
  `vidCover` varchar(255) NOT NULL,
  `id` int(11) NOT NULL AUTO_INCREMENT,
  PRIMARY KEY (`id`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=11 ;
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
// fourth we will echo an xml file with the information from our data base

$result = mysql_query("SELECT * FROM theVideo ORDER BY id",$connect);

// open the xml file
echo "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n"; // backslash escapes the double qoute
echo "<videos>\n";

// iterate through results
while($myrow = mysql_fetch_assoc($result))
{
    echo "<videoData>\n";
    echo "<index>".$myrow["id"]."</index>\n";
    echo "<video_title>".$myrow["vidTitle"]."</video_title>\n";
    echo "<video_project>".$myrow["vidProject"]."</video_project>\n";
    echo "<video_client>".$myrow["vidClient"]."</video_client>\n";
    echo "<video_role>".$myrow["vidRole"]."</video_role>\n";
    echo "<video_path>".$myrow["vidPath"]."</video_path>\n";
    echo "<video_cover>".$myrow["vidCover"]."</video_cover>\n";
    echo "</videoData>\n\n";
}

// close the xml file
echo "</videos>\n";

?>
GD Star Rating
loading...


Comments are closed.



Content

Need to pay for services?


Banner    

Contact me


  

Socially you can find me here


                 

        


Need to pick up a few things before you leave?


Grasshopper - The Entrepreneur's Phone System   Affordable Premium Custom Flash Photo and Video Gallery Templates
2010 Copyright © Todd Vaughn. All rights reserved. Register