1,105,386 Community Members

Latest Posts in PHP

Member Avatar
Rizwan_2
Newbie Poster
1 post since Apr 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 
$rs = mysqli_query($conn,"Call GetProducts") or die(mysqli_error($conn)." Query=".$sql);
    $result = array();
    while($row = mysqli_fetch_array($rs)){
    array_push($result, $row);

    }
        echo json_encode($result);
Member Avatar
surferbloggy
Newbie Poster
3 posts since May 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

with this code it worked!!

global $wpdb;   //required global declaration of WP variable

    $table_name = $wpdb->prefix.$table_name;

    $sql = "DROP TABLE ". $table_name;

    $wpdb->query($sql);

thank you!!

Member Avatar
cecece
Newbie Poster
1 post since Apr 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Can you please paste the sample code of your solution. I need this to integrate in my site.

Thank you

Member Avatar
ehpratah
Junior Poster
141 posts since May 2012
Reputation Points: 27 [?]
Q&As Helped to Solve: 7 [?]
Skill Endorsements: 2 [?]
 
0
 

Hi have you tried using js for redirection? just for debugging purpose try

window.location.href="thankyou.php";

see if its working

Member Avatar
Tpojka
Junior Poster in Training
79 posts since Oct 2011
Reputation Points: 27 [?]
Q&As Helped to Solve: 12 [?]
Skill Endorsements: 0 [?]
 
0
 

Check this code. Bit different than yours.

Member Avatar
diafol
Where are my eyes?
12,985 posts since Oct 2006
Reputation Points: 1,821 [?]
Q&As Helped to Solve: 1,848 [?]
Skill Endorsements: 92 [?]
Moderator
Featured
Sponsor
 
0
 

Sorry, I got this far and had to stop. $count?? The getlisting.php may contain some paragraphs with urls, but this isn't made clear. You seem to re-assign your variables with different datatypes, which can be difficult to follow.

ini_set('max_execution_time', 300);

$errmsg_arr = array();
$errflag = false;

include ('simple_html_dom.php');

function getUrlFriendlyString($str)
{
  // convert spaces to '-', remove characters that are not alphanumeric
  // or a '-', combine multiple dashes (i.e., '---') into one dash '-'.
  $str = ereg_replace("[-]+", "-", ereg_replace("[^a-z0-9-]", "",
  strtolower( str_replace(" ", "-", $str) ) ) );
  return $str;
}

function getPaddedHour($hour, $meridian) 
{
    $ret = intval($hour);
    $ret += ($meridian == 'AM') ? 0 : 11;
    return str_pad($ret,2,'0',STR_PAD_LEFT);
}

$xml = '< ' .'?xml version="1.0" encoding="UTF-8" ?' .'>';
$xml .= '<tv generator-info-name="www.testbox.elementfx.com/test">';
$base1 = "http://www.mysite.com/get-listing.php";

$html = file_get_html($base1);        

foreach($html->find('p[id=links]') as $element)
{
  //$count is not encountered elsewhere - so should throw an error  
  $program_list[$count] = array();

  $id_split = explode("?", $element->plaintext);
  //You've just OVERWRITTEN the $id_split array with the following explode
  $id_split = explode("&", $link_split[1]);

  //Is $channels now a single value or an array? Confusing - assuming single
  $channels = explode("channels=",$id_split[0]);
  $channels = $channels[1];

  //Is $id a single value or an array? Assuming single
  $id = explode("id=",$id_split[1]);
  $id = $id[1];

There's a lot of conditionals too, so you could get rid of a lot of it with this:

function returnDateTime($hours, $minutes)
{
    $days = 1;
    if($hours == 24)$days = 2;
    if($hours == 12 || $hours = 24) $hours = 0;
    if($hours > 12 && $hours < 24) $days = 0;

    return date('Ymd', strtotime("+$days day")) . str_pad($hours,2,'0',STR_PAD_LEFT) . $minutes . "00";
}

$time1[0] = returnDateTime($hours,$minutes);

However, this is not quite right as you only allow AM to enter this branch. You've created a getPaddedHour() function, but haven't used it.

Without wanting to sound too critical, this is a mess and it will take some work to clean it up. I'd suggest that you try to cut all those needless conditionals and create reusable functions (as exeplified).

Member Avatar
diafol
Where are my eyes?
12,985 posts since Oct 2006
Reputation Points: 1,821 [?]
Q&As Helped to Solve: 1,848 [?]
Skill Endorsements: 92 [?]
Moderator
Featured
Sponsor
 
0
 

I can't get my head around 500+ lines of code, and it seems few other people can judging by the lack of response thus far. You have a lot of needless code here. I'll see if I can reduce it and perhpas it'll be more digestable :)

Member Avatar
diafol
Where are my eyes?
12,985 posts since Oct 2006
Reputation Points: 1,821 [?]
Q&As Helped to Solve: 1,848 [?]
Skill Endorsements: 92 [?]
Moderator
Featured
Sponsor
 
0
 

Well just change it back to mysql for now or try PDO.

Member Avatar
lukwagomedia
Newbie Poster
15 posts since Mar 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

I have now tried and tried several times to make sure that it really doesent work before I ask again.
I remember you told me that I have to use mysqli instead just myaql.
And that is exaktly the error in it all.

whenever I use mysqli, my website just go blank and I recieve an error message saying: Access denied for user ''@'web103.local.one.com' (using password: NO).

So I think that I cannot get your code to work because it is written with mysqli_queries.

But thank you very much anyway.

Member Avatar
surferbloggy
Newbie Poster
3 posts since May 2010
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi I've wrote a plugin it works but on deactivation it doesn't drop the plugin tables from db
this is the code

$sql = "DROP TABLE IF_EXISTS 'TABLENAME'";
                $wpdb->query($sql);
                //$e = $wpdb->query($sql);
                //die(var_dump($e));

and i call that function this way
register_deactivation_hook(FILE, 'deactivate');

if i uncomment to show message error it tells me on deativation

bool(false)

whiy doesn't it drop the table?? could you help me to fix it??
thank you

Member Avatar
chandni2014
Newbie Poster
1 post since Apr 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

hello, i am having the same issue, i am not able to load data in wdcalendar. i have read the conversation, this wdcalendar is working fine in localhost but not working in the server. Please help me out....

Member Avatar
fireburner29
Newbie Poster
7 posts since Aug 2012
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

good . thanks tpojka. based on ur comment i have made my script.
i hereby mentioned my script also.

<?php
    date_default_timezone_set("Indian/Mauritius");
     $todays_date = date("F j Y g:i A e"); 
        $task_assigned_to = $_SESSION['SESSION_USER_NAME'];
     $result = $conn->prepare("SELECT task_end_date FROM `subadmin-task` where task_assigned_to = :task_assigned_to ORDER BY task_id DESC LIMIT 25");
        $result->bindParam(':task_assigned_to', $task_assigned_to); 
        $result->execute();
        $total = $result->rowCount();
        $row = $result->fetch();
    $deadline = $row['task_end_date'];
    $todays_date = date("Y-m-d");
$today = strtotime($todays_date);
$expiration_date = strtotime($deadline);
$timeDiff = abs($expiration_date-$today);
$num_day = $timeDiff/86400; // 1day = 86400 sec
$num_of_days = intval($num_day);


if($total > 0)
{
if ($expiration_date > $today) {
 // echo "<meta http-equiv='refresh' content='1;URL=subadmin_task.php'>"; //deadline is past user can't access 
echo "Still you will have&nbsp&nbsp"."$num_of_days"."&nbsp&nbspdays";
    } 
    else { 

  //echo "<meta http-equiv='refresh' content='1;URL=closed.php'>"; //deadline is past user can't access 
  header("location: closed.php");

    } 
    }

?>      
Member Avatar
net4earning
Newbie Poster
3 posts since Apr 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

this is the HTML produced by above code.

<p>
    <label for="wp_rar_user_role">Account type<br />
          <input type="radio" name="wp_rar_user_role" id="wp_rar_user_role" class="input select"

                 value="voter" /> <label>

        Voter      </label>
                   value="writer" /> <label>

        Writer      </label>
          </label>
</p>
Member Avatar
iamthwee
Posting Sage
7,081 posts since Aug 2005
Reputation Points: 1,307 [?]
Q&As Helped to Solve: 596 [?]
Skill Endorsements: 74 [?]
Featured
 
0
 

I'd worry more about SQL injection in the above code then about backticks, and the fact that the mysql extension is deprecated ;)

Prit can you further explain this as I am curious. Since the OP uses my_sql_real_escape with the deprecated version of mysql() isn't it still safe though.

Couldn't agree more about backticks Bob. I only had one time when I came unstuck using them, and that was when I accidentally call a field 'desc' for description, desc being a reserve word.

You would believe how long I took to debug.

Member Avatar
Bob Hensley
Junior Poster in Training
83 posts since Oct 2010
Reputation Points: 20 [?]
Q&As Helped to Solve: 17 [?]
Skill Endorsements: 2 [?]
 
0
 

I found it.
include($_SERVER["DOCUMENT_ROOT"]."/filepath";

I'd just like to point out that there's a syntax error here: you omitted the terminating parenthesis. I would also recommend, if this file is critical to your application, you use the require_once() function instead.

Member Avatar
ProfessorPC
Posting Whiz in Training
274 posts since Dec 2007
Reputation Points: 19 [?]
Q&As Helped to Solve: 29 [?]
Skill Endorsements: 0 [?]
 
0
 

I found it.
include($_SERVER["DOCUMENT_ROOT"]."/filepath";

Member Avatar
ProfessorPC
Posting Whiz in Training
274 posts since Dec 2007
Reputation Points: 19 [?]
Q&As Helped to Solve: 29 [?]
Skill Endorsements: 0 [?]
 
0
 

I have been trying to work around a problem but am not having much luck.
I have classes that include a file with my db settings. The problem is I have a functions directory that calls some of the classes. I get failed to open stream: No such file or directory. Is there a way to include this file no matter where the class is being called from?

Thank you

Member Avatar
mark103
Newbie Poster
22 posts since Apr 2011
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

Hi all,

I need your help, I'm working on my php to get the list of contents from my get-listing.php script so I can generating the XML to output the contents into the XML.

I have got a little bit of problem with output the contents. I'm still getting the same contents in the XML output for each channel when I generating the XML.

Here is the XML:

   <tv generator-info-name="www.mysite.com/myXML">
    <channel id="101 ABC FAMILY">
    <display-name>101 ABC FAMILY</display-name>
    <programme channel="101 ABC FAMILY" start="20140418160000" stop="20140418163000">
    <title lang="en"></title>
    <sub-title lang="en"></sub-title>
    <desc lang="en"></desc>
    <category lang="en"></category>
    </programme>
    <programme channel="101 ABC FAMILY" start="20140418163000" stop="20140418170000">
    <title lang="en"></title>
    <sub-title lang="en"></sub-title>
    <desc lang="en"></desc>
    <category lang="en"></category>
    </programme>
    <programme channel="101 ABC FAMILY" start="20140418170000" stop="20140418173000">
    <title lang="en"></title>
    <sub-title lang="en"></sub-title>
    <desc lang="en"></desc>
    <category lang="en"></category>
    </programme>
    </channel>

    <channel id="102 CBS">
    <display-name>102 CBS</display-name>
    <programme channel="102 CBS" start="20140418160000" stop="20140418163000">
    <title lang="en"></title>
    <sub-title lang="en"></sub-title>
    <desc lang="en"></desc>
    <category lang="en"></category>
    </programme>
    <programme channel="102 CBS" start="20140418163000" stop="20140418170000">
    <title lang="en"></title>
    <sub-title lang="en"></sub-title>
    <desc lang="en"></desc>
    <category lang="en"></category>
    </programme>
    <programme channel="102 CBS" start="20140418170000" stop="20140418173000">
    <title lang="en"></title>
    <sub-title lang="en"></sub-title>
    <desc lang="en"></desc>
    <category lang="en"></category>
    </programme>

Here's the ABC Family programme info:

4:00 PM - Boy Meets World - Home

4:30 PM - Boy Meets World - My Best Friend's Girl

5:00 PM - The Middle - The Big Chill

5:30 PM - The Middle - Friends, Lies and Videotape

Here's the CBS programme info:

4:00 PM - The Talk

5:00 PM - Let's Make a Deal

6:00 PM - Local Programming

8:30 PM - CBS Evening News With Scott Pelley

As you can see that on both channel programme info, it have got different time in each array. On mine it will show the same programme time for both channels when I'm generating the XML.

Here is what it supposed to be:

<tv generator-info-name="www.mysite.com/myXML">
<channel id="101 ABC FAMILY">
<display-name>101 ABC FAMILY</display-name>
<programme channel="101 ABC FAMILY" start="20140418160000" stop="20140418163000">
<title lang="en"></title>
<sub-title lang="en"></sub-title>
<desc lang="en"></desc>
<category lang="en"></category>
</programme>
<programme channel="101 ABC FAMILY" start="20140418163000" stop="20140418170000">
<title lang="en"></title>
<sub-title lang="en"></sub-title>
<desc lang="en"></desc>
<category lang="en"></category>
</programme>
<programme channel="101 ABC FAMILY" start="20140418170000" stop="20140418173000">
<title lang="en"></title>
<sub-title lang="en"></sub-title>
<desc lang="en"></desc>
<category lang="en"></category>
</programme>
</channel>

<channel id="102 CBS">
<display-name>102 CBS</display-name>
<programme channel="102 CBS" start="20140418160000" stop="20140418170000">
<title lang="en"></title>
<sub-title lang="en"></sub-title>
<desc lang="en"></desc>
<category lang="en"></category>
</programme>
<programme channel="102 CBS" start="20140418170000" stop="20140418180000">
<title lang="en"></title>
<sub-title lang="en"></sub-title>
<desc lang="en"></desc>
<category lang="en"></category>
</programme>
<programme channel="102 CBS" start="20140418180000" stop="20140418203000">
<title lang="en"></title>
<sub-title lang="en"></sub-title>
<desc lang="en"></desc>
<category lang="en"></category>
</programme>
</tv>

Here is the PHP:

<?php
ini_set('max_execution_time', 300);
$errmsg_arr = array();
$errflag = false;
include ('simple_html_dom.php');

function getUrlFriendlyString($str)
{
  // convert spaces to '-', remove characters that are not alphanumeric
  // or a '-', combine multiple dashes (i.e., '---') into one dash '-'.
  $str = ereg_replace("[-]+", "-", ereg_replace("[^a-z0-9-]", "",
  strtolower( str_replace(" ", "-", $str) ) ) );
  return $str;
}

function getPaddedHour($hour, $meridian) 
{
  $ret = $hour;
  if ($meridian == 'AM' && $ret == 12) 
  { 
    $ret = 0;
  } 
  else if ($meridian == 'PM' && $ret != 12) 
  { 
    $ret += 11;
  }
  if ($ret < 10) 
  {
    $ret = '0'.$ret;
  }
  return $ret;
}
  $xml .= '<?xml version="1.0" encoding="UTF-8" ?>';
  $xml .= '
<tv generator-info-name="www.testbox.elementfx.com/test">';
  $base1 = "http://www.mysite.com/get-listing.php";
  $html = file_get_html($base1);        
  //echo $xml;

foreach($html->find('p[id=links]') as $element)
{
  $program_list[ $count ] = array();
  $id_split = explode("?", $element->plaintext);
  $id_split = explode("&", $link_split[1]);
  $channels = explode("channels=",$id_split[0]);
  $channels = $channels[1];
  $id = explode("id=",$id_split[1]);
  $id = $id[1];

  //channels
  //$channel_test = $html->find('p[id=channels]', 10)->plaintext;
  //echo $channel_test;

  $program_list[ $count ]['channels'] = $channels;
  $program_list[ $count ]['id'] = $id;

  $channels_split = explode("?", $element->plaintext);
  $channels_split = explode("&", $channels_split[1]);
  $channel_id = explode("channels=",$channels_split[0]);
  $channel_id = $channel_id[1];
  $my_id = explode("id=",$channels_split[1]);
  $my_id = $my_id[1];

  $channel = urlencode($channel_id);
  $id_1 = urlencode($my_id);
  $html_two = file_get_html("http://www.mysite.com/get-listing.php?channels=" . $channel . "&id=" . $my_id);

  //time1
  $time1 = $html_two->find('span[id=time1]',0)->plaintext;
  $title1 = $html_two->find('span[id=title1]',0)->plaintext;

  $hoursMinutes = explode(":", $time1[0]);
  $hours = $hoursMinutes[0];
  $minutes = $hoursMinutes[1];

  $time1 = explode(" ", $time1);
  $hoursMinutes = explode(":", $time1[0]);
  $hours = $hoursMinutes[0];
  $minutes = $hoursMinutes[1];

  if($time1[1] == "PM")
  {
    $time1[0] = date("Ymd") . ((int)($hours) + 12) . $minutes . "00";
  } 
  else 
  {
    if($hours=="12")
    {
      $time1[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00";
    }
    else if($hours=="1")
    {
      $time1[0] = date('Ymd', strtotime(' +1 day')) . "01" . $minutes . "00";
    }
    else if($hours=="2")
    {
      $time1[0] = date('Ymd', strtotime(' +1 day')) . "02" . $minutes . "00";
    }
    else if($hours=="3")
    {
      $time1[0] = date('Ymd', strtotime(' +1 day')) . "03" . $minutes . "00";
    }
    else if($hours=="4")
    {
      $time1[0] = date('Ymd', strtotime(' +1 day')) . "04" . $minutes . "00";
    }
    else if($hours=="5")
    {
      $time1[0] = date('Ymd', strtotime(' +1 day')) . "05" . $minutes . "00";
    }
    else if($hours=="6")
    {
      $time1[0] = date('Ymd', strtotime(' +1 day')) . "06" . $minutes . "00";
    }
    else if($hours=="7")
    {
      $time1[0] = date('Ymd', strtotime(' +1 day')) . "07" . $minutes . "00";
    }
    else if($hours=="8")
    {
      $time1[0] = date('Ymd', strtotime(' +1 day')) . "08" . $minutes . "00";
    }
    else if($hours=="9")
    {
      $time1[0] = date('Ymd', strtotime(' +1 day')) . "09" . $minutes . "00";
    }
    else if($hours=="10")
    {
      $time1[0] = date('Ymd', strtotime(' +1 day')) . "10" . $minutes . "00";
    }
    else if($hours=="11")
    {
      $time1[0] = date('Ymd', strtotime(' +1 day')) . "11" . $minutes . "00";
    }
    else if($hours=="24")
    {
      $time1[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00";
    }
    else
    {
      $time1[0] = date("Ymd") . $hours . $minutes . "00";
    }
  }

  $program_list[$count]['start_time1'] = $time1[0];
  $program_list[$count]['title1'] = $title1;

  //time2
  $time2 = $html_two->find('span[id=time2]',0)->plaintext;
  $title2 = $html_two->find('span[id=title2]',0)->plaintext;

  $time2 = explode(" ", $time2);
  $hoursMinutes = explode(":", $time2[0]);
  $hours = $hoursMinutes[0];
  $minutes = $hoursMinutes[1];

  if($time2[1] == "PM")
  {
    $time2[0] = date("Ymd") . ((int)($hours) + 12) . $minutes . "00";
  } 
  else 
  {
    if($hours=="12")
    {
      $time2[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00";
    }
    else if($hours=="1")
    {
      $time2[0] = date('Ymd', strtotime(' +1 day')) . "01" . $minutes . "00";
    }
    else if($hours=="2")
    {
      $time2[0] = date('Ymd', strtotime(' +1 day')) . "02" . $minutes . "00";
    }
    else if($hours=="3")
    {
      $time2[0] = date('Ymd', strtotime(' +1 day')) . "03" . $minutes . "00";
    }
    else if($hours=="4")
    {
      $time2[0] = date('Ymd', strtotime(' +1 day')) . "04" . $minutes . "00";
    }
    else if($hours=="5")
    {
      $time2[0] = date('Ymd', strtotime(' +1 day')) . "05" . $minutes . "00";
    }
    else if($hours=="6")
    {
      $time2[0] = date('Ymd', strtotime(' +1 day')) . "06" . $minutes . "00";
    }
    else if($hours=="7")
    {
      $time2[0] = date('Ymd', strtotime(' +1 day')) . "07" . $minutes . "00";
    }
    else if($hours=="8")
    {
      $time2[0] = date('Ymd', strtotime(' +1 day')) . "08" . $minutes . "00";
    }
    else if($hours=="9")
    {
      $time2[0] = date('Ymd', strtotime(' +1 day')) . "09" . $minutes . "00";
    }
    else if($hours=="10")
    {
      $time2[0] = date('Ymd', strtotime(' +1 day')) . "10" . $minutes . "00";
    }
    else if($hours=="11")
    {
      $time2[0] = date('Ymd', strtotime(' +1 day')) . "11" . $minutes . "00";
    }
    else if($hours=="24")
    {
      $time2[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00";
    }
    else
    {
      $time2[0] = date("Ymd") . $hours . $minutes . "00";
    }
  }

  $program_list[$count]['end_time1'] = $time2[0];
  $program_list[$count]['start_time2'] = $time2[0];
  $program_list[$count]['title2'] = $title2;

  //time3
  $time3 = $html_two->find('span[id=time3]',0)->plaintext;
  $title3 = $html_two->find('span[id=title3]',0)->plaintext;

  $time3 = explode(" ", $time3);
  $hoursMinutes = explode(":", $time3[0]);
  $hours = $hoursMinutes[0];
  $minutes = $hoursMinutes[1];

  if($time3[1] == "PM")
  {
    $time3[0] = date("Ymd") . ((int)($hours) + 12) . $minutes . "00";
  } 
  else 
  {
    if($hours=="12")
    {
      $time3[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00";
    }
    else if($hours=="1")
    {
      $time3[0] = date('Ymd', strtotime(' +1 day')) . "01" . $minutes . "00";
    }
    else if($hours=="2")
    {
      $time3[0] = date('Ymd', strtotime(' +1 day')) . "02" . $minutes . "00";
    }
    else if($hours=="3")
    {
      $time3[0] = date('Ymd', strtotime(' +1 day')) . "03" . $minutes . "00";
    }
    else if($hours=="4")
    {
      $time3[0] = date('Ymd', strtotime(' +1 day')) . "04" . $minutes . "00";
    }
    else if($hours=="5")
    {
      $time3[0] = date('Ymd', strtotime(' +1 day')) . "05" . $minutes . "00";
    }
    else if($hours=="6")
    {
      $time3[0] = date('Ymd', strtotime(' +1 day')) . "06" . $minutes . "00";
    }
    else if($hours=="7")
    {
      $time3[0] = date('Ymd', strtotime(' +1 day')) . "07" . $minutes . "00";
    }
    else if($hours=="8")
    {
      $time3[0] = date('Ymd', strtotime(' +1 day')) . "08" . $minutes . "00";
    }
    else if($hours=="9")
    {
      $time3[0] = date('Ymd', strtotime(' +1 day')) . "09" . $minutes . "00";
    }
    else if($hours=="10")
    {
      $time3[0] = date('Ymd', strtotime(' +1 day')) . "10" . $minutes . "00";
    }
    else if($hours=="11")
    {
      $time3[0] = date('Ymd', strtotime(' +1 day')) . "11" . $minutes . "00";
    }
    else if($hours=="24")
    {
      $time3[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00";
    }
    else
    {
      $time3[0] = date("Ymd") . $hours . $minutes . "00";
    }
  }

  $program_list[$count]['end_time2'] = $time3[0];
  $program_list[$count]['start_time3'] = $time3[0];
  $program_list[$count]['title3'] = $title3;

  //time4
  $time4 = $html_two->find('span[id=time4]',0)->plaintext;
  $title4 = $html_two->find('span[id=title4]',0)->plaintext;

  $time4 = explode(" ", $time4);
  $hoursMinutes = explode(":", $time4[0]);
  $hours = $hoursMinutes[0];
  $minutes = $hoursMinutes[1];

  if($time4[1] == "PM")
  {
    $time4[0] = date("Ymd") . ((int)($hours) + 12) . $minutes . "00";
  } 
  else 
  {
    if($hours=="12")
    {
      $time4[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00";
    }
    else if($hours=="1")
    {
      $time4[0] = date('Ymd', strtotime(' +1 day')) . "01" . $minutes . "00";
    }
    else if($hours=="2")
    {
      $time4[0] = date('Ymd', strtotime(' +1 day')) . "02" . $minutes . "00";
    }
    else if($hours=="3")
    {
      $time4[0] = date('Ymd', strtotime(' +1 day')) . "03" . $minutes . "00";
    }
    else if($hours=="4")
    {
      $time4[0] = date('Ymd', strtotime(' +1 day')) . "04" . $minutes . "00";
    }
    else if($hours=="5")
    {
      $time4[0] = date('Ymd', strtotime(' +1 day')) . "05" . $minutes . "00";
    }
    else if($hours=="6")
    {
      $time4[0] = date('Ymd', strtotime(' +1 day')) . "06" . $minutes . "00";
    }
    else if($hours=="7")
    {
      $time4[0] = date('Ymd', strtotime(' +1 day')) . "07" . $minutes . "00";
    }
    else if($hours=="8")
    {
      $time4[0] = date('Ymd', strtotime(' +1 day')) . "08" . $minutes . "00";
    }
    else if($hours=="9")
    {
      $time4[0] = date('Ymd', strtotime(' +1 day')) . "09" . $minutes . "00";
    }
    else if($hours=="10")
    {
      $time4[0] = date('Ymd', strtotime(' +1 day')) . "10" . $minutes . "00";
    }
    else if($hours=="11")
    {
      $time4[0] = date('Ymd', strtotime(' +1 day')) . "11" . $minutes . "00";
    }
    else if($hours=="24")
    {
      $time4[0] = date('Ymd', strtotime(' +1 day')) . "00" . $minutes . "00";
    }
    else
    {
      $time4[0] = date("Ymd") . $hours . $minutes . "00";
    }
  }

  $program_list[$count]['end_time3'] = $time4[0];
  $program_list[$count]['start_time4'] = $time4[0];
  $program_list[$count]['title4'] = $title4;

  if (strpos($channel, '+') !== false)
  {
    $channel = str_replace('+', ' ', $channel);
  }

  //program 1#
  $xml .= "
  <channel id='" . $my_id. " " . $channel . "'>";
  $xml .= "
    <display-name>" . $my_id. " " . $channel; 
  $xml .= "</display-name>";
  $xml .= "
  <programme channel='" . $my_id. " " . $channel . "' start='" . $program_list[$i]['start_time1'] . "' stop='" . $program_list[$i]['end_time1'] . "'>";
  $xml .= '
    <title lang="en">';
  $xml .= ' </title>';
  $xml .= '
    <sub-title lang="en">';
  $xml .= ' </sub-title>';
  $xml .= '
    <desc lang="en">';
  $xml .= ' </desc>';
  $xml .= '
    <category lang="en">';
  $xml .= ' </category>';
  $xml .= "
  </programme>";


  //program 2#
  $xml .= "
  <programme channel='" . $my_id. " " . $channel . "' start='" . $program_list[$i]['start_time2'] . "' stop='" . $program_list[$i]['end_time2'] . "'>";
  $xml .= '
    <title lang="en">';
  $xml .= ' </title>';
  $xml .= '
    <sub-title lang="en">';
  $xml .= ' </sub-title>';
  $xml .= '
    <desc lang="en">';
  $xml .= ' </desc>';
  $xml .= '
    <category lang="en">';
  $xml .= ' </category>';
  $xml .= '
  </programme>';


  //program 3#
  $xml .= "
  <programme channel='" . $my_id. " " . $channel . "' start='" . $program_list[$i]['start_time3'] . "' stop='" . $program_list[$i]['end_time3'] . "'>";
  $xml .= '
    <title lang="en">';
  $xml .= ' </title>';
  $xml .= '
    <sub-title lang="en">';
  $xml .= ' </sub-title>';
  $xml .= '
    <desc lang="en">';
  $xml .= ' </desc>';
  $xml .= '
    <category lang="en">';
  $xml .= ' </category>';
  $xml .= '
  </programme>';


  //program 4#
  $xml .= "
  <programme channel='" . $my_id. " " . $channel . "' start='" . $program_list[$i]['start_time4'] . "' stop='" . $program_list[$i]['end_time4'] . "'>";
  $xml .= '
    <title lang="en">';
  $xml .= ' </title>';
  $xml .= '
    <sub-title lang="en">';
  $xml .= ' </sub-title>';
  $xml .= '
    <desc lang="en">';
  $xml .= ' </desc>';
  $xml .= '
    <category lang="en">';
  $xml .= ' </category>';
  $xml .= '
  </programme>';
}
  $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);
?>

Does anyone know how I can get the list of contents for each channel when I'm generating the XML without output the same contents on both channels tags in the XML?

I think I have missing with something especially the integer.

Member Avatar
broj1
Posting Virtuoso
1,578 posts since Jan 2011
Reputation Points: 220 [?]
Q&As Helped to Solve: 219 [?]
Skill Endorsements: 21 [?]
Featured
 
0
 

Ups, I wrongly interpreted your code, I am sory for that. Please disregard my post above.

Can you post the html code for both radio buttons that gets generated, please.

Member Avatar
net4earning
Newbie Poster
3 posts since Apr 2014
Reputation Points: 0 [?]
Q&As Helped to Solve: 0 [?]
Skill Endorsements: 0 [?]
 
0
 

result should be 2 radio buttons like below

  • Voter
  • Writer

this is what showen on the page

38b24846cf8e4ac253603609478cbc16

Attachments

PHP Tag Cloud