Hi all,
I need your help. I want to get access on each PHP link for each array to get the list of programme title to output them in the XML source.
Here’s for e.g:
[url]http://testbox.elementfx.com/get-listing.php
I want to access to get-listing.php and I want to get the cbs link to access and get the list of programming info:
[CODE] <span id=”time1″>12:00 PM </span> – <span id=”title1″>2014 NCAA Basketball Tournament”Dayton vs. Ohio State – LIVE</span><br><br>
<span id=”time2″>2:30 PM </span> – <span id=”title2″>2014 NCAA Basketball Tournament”Western Michigan vs. Syracuse – LIVE</span><br><br>
<span id=”time3″>5:00 PM </span> – <span id=”title3″>Local Programming</span><br><br>
<span id=”time4″>6:00 PM </span> – <span id=”title4″>Local Programming</span><br><br>
<span id=”time5″>7:00 PM </span> – <span id=”title5″>2014 NCAA Basketball Tournament”Wofford vs. Michigan – LIVE</span><br><br>
<span id=”time6″>9:30 PM</span> – <span id=”title6″>2014 NCAA Basketball Tournament”Arizona State vs. Texas – LIVE</span><br><br>
<span id=”time7″>12:00 AM </span> – <span id=”title7″> 1 Local Programming</span><br><br>
<span id=”time8″>12:35 AM </span> – <span id=”title8″>Late Show With David LettermanTV-PG </span><br><br>
<span id=”time9″>1:37 AM </span> – <span id=title9>The Late Late Show With Craig FergusonTV-14 </span><br><br>
CBS link: [url]http://testbox.elementfx.com/get-listing.php?channels=CBS&id=102
[code=php]<?php
function db_connect()
{
define(‘DB_HOST’, ‘localhost’);
define(‘DB_USER’, ‘myusername’);
define(‘DB_PASSWORD’, ‘mypassword’);
define(‘DB_DATABASE’, ‘mydbname’);
$errmsg_arr = array();
$errflag = false;
$link = mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
if(!$link)
{
die(‘Failed to connect to server: ‘ . mysql_error());
}
$db = mysql_select_db(DB_DATABASE);
if(!$db)
{
die(“Unable to select database”);
}
}
db_connect();
function clean($var)
{
return mysql_real_escape_string(strip_tags($var));
}
$channels = clean($_GET[‘channels’]);
$id = clean($_GET[‘id’]);
if($errflag)
{
$_SESSION[‘ERRMSG_ARR’] = $errmsg_arr;
echo implode(‘<br />’,$errmsg_arr);
}
else
{
$insert = array();
if(isset($_GET[‘channels’]))
{
$insert[] = ‘channels = ” . clean($_GET[‘channels’]) .”’;
}
if(isset($_GET[‘id’]))
{
$insert[] = ‘id = ” . clean($_GET[‘id’]) . ”’;
}
if(!$channels && ! $id)
{
$qrytable1=”SELECT id, channels, links, streams FROM tvguide”;
$result1=mysql_query($qrytable1) or die(‘Error:<br />’ . $qry . ‘<br />’ . mysql_error());
while ($row = mysql_fetch_array($result1))
{
// fake some example data. the actual data would be retrieved from a database query
$data[] = array(‘channel_id’=>$row[‘channels’],
‘display_name’=>$row[‘channels’],
‘program_id’=>123,’start’=>’s1′,’stop’=>’e1’,
‘title’=>’program title’,
‘sub_title’=>’sub title’,
‘description’=>’program description1’,
‘category’=>’some category’);
// build the xml
$xml = ‘<?xml version=”1.0″ encoding=”UTF-8″ ?>
<tv generator-info-name=”www.testbox.elementfx.com/xmltv”>’;
$last_channel = null; // used to detect when the channel changes
foreach($data as $arr)
{
if($last_channel != $arr[‘channel_id’])
{
// the channel changed
if($last_channel != null)
{
// not the first channel, close out the previous channel
$xml .= ”
</channel> n”;
}
// start a new channel
$xml .= ”
<channel id=”{$arr[‘channel_id’]}”>”;
$xml .= ”
<display-name>{$arr[‘display_name’]}</display-name>”;
$last_channel = $arr[‘channel_id’];
}
// output the program info under each channel
$xml .= ”
<programme channel=”{$arr[‘channel_id’]}” start=”{$arr[‘start’]}” stop=”{$arr[‘stop’]}”>”;
// i don’t see a program id in this definition, but it likely needs one
$xml .= ”
<title lang=”en”>{$arr[‘title’]}</title>”;
$xml .= ”
<sub-title lang=”en”>{$arr[‘sub_title’]}</sub-title>”;
$xml .= ”
<desc lang=”en”>{$arr[‘description’]}</desc>”;
$xml .= ”
<category lang=”en”>{$arr[‘category’]}</category>”;
$xml .= ”
</programme>”;
}
if($last_channel != null)
{
// close out the previous channel if any
$xml .= ‘
</channel>’;
}
}
}
$xml .= ‘
</tv>’;
// output the xml to the browser in this example, write $xml to a file here…
header(“Content-Type: text/xml”);
echo $xml;
$handle = fopen(“myChannel.xml”, “w”);
fwrite ($handle, $xml);
}
?>
The same things that it goes for each array in the get-listing.php.
Can you please tell me how I can get the list of strings from each PHP tag `<span id=”title1″>`<span id=”title2″>`<span id=”title3″>`<title lang=”en”>
Thanks in advance