Jump to content

mark107

Members
  • Posts

    113
  • Joined

  • Last visited

Posts posted by mark107

  1. @mac_gyver: My xml definition does make complete sense, you did not read my first post carefully what I want to achieve.

     

    The source you post it doesn't match in my needs. I want to get the arrays of channel from mysql database and I want to output them in each xml tag called `channel` then save the xml file called myChannel.xml.

     

    I want to make xml source that looks like this:

    <?xml version="1.0" encoding="UTF-8" ?>
    <tv generator-info-name="www.mysite.com/xmltv">
    <channel id="row1">
       <display-name>row1</display-name>
       <programme channel="row1" start="" stop="">
           <title lang="en"></title>
           <sub-title lang="en">
           </sub-title>
           <desc lang="en"></desc>
           <category lang="en"></category>
       </programme>
    </channel>
    
    <channel id="row2">
       <display-name>row2</display-name>
       <programme channel="row2" start="" stop="">
           <title lang="en"></title>
           <sub-title lang="en">
           </sub-title>
           <desc lang="en"></desc>
           <category lang="en"></category>
       </programme>
    </channel>
    
    <channel id="row3">
       <display-name>row3</display-name>
       <programme channel="row3" start="" stop="">
           <title lang="en"></title>
           <sub-title lang="en">
           </sub-title>
           <desc lang="en"></desc>
           <category lang="en"></category>
       </programme>
    

    </channel>

    </tv>

     

     

    Here's what my xml output looks like:

    <?xml version="1.0" encoding="UTF-8"?>
    <tv generator-info-name="www.mysite.com/xmltv"><channel><display-name>Information from database</display-name><programme/><desc/></channel></tv>

    As you can see the difference between my xml source and the other xml source i want to make it, on my xml source it doesn't look the same as the other xml source.

     

    Can you modify the source I use to allow me to output the list of arrays of rows from mysql to put the rows in the xml tag `channel`, `display-name` and `programme channel`?

  2. Hi all,
     
    I need some of your help, I'm working on my PHP script to create the XML document with encoding utf8 so I can generate the XML file to allow me to save the XML file in my web host.
     
     
    I want to make the xml output to something like this:
     
    <?xml version="1.0" encoding="UTF-8" ?>
    <tv generator-info-name="www.mysite.com/xmltv">
    <channel id="">
       <display-name>Information from database</display-name>
       <programme channel="Information from database" start="" stop="">
           <title lang="en"></title>
           <sub-title lang="en">
           </sub-title>
           <desc lang="en"></desc>
           <category lang="en"></category>
       </programme>
    </channel>
     
     
     
    Here's what my XML output looks like:
     
    <?xml version="1.0" encoding="UTF-8"?>
    <tv generator-info-name="www.mysite.com/xmltv"><channel><display-name>Information from database</display-name><programme/><desc/></channel></tv>
     
     
    Here's the current code:
     
    <?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 FROM tvguide WHERE channels='$channels' && id='$id'";
    $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error());
    echo '<?xml version="1.0" encoding="UTF-8" ?>
    <tv generator-info-name="www.mysite.com/xmltv">
    <channel id="">
    <display-name></display-name>
    <programme channel="" start="" stop="">
    <title lang="en"></title>
    <sub-title lang="en"></sub-title>
    <desc lang="en"></desc>
    <category lang="en"></category>
    </programme>
    </channel>
    </tv>';
        
    while ($row = mysql_fetch_array($result1))
    {
    
    }
    mysql_close();
    }
    else 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))
    {
    
    }
    mysql_close();
    }
    }
    // create a dom document with encoding utf8
    $domtree = new DOMDocument('1.0', 'UTF-8');
    
    // create a root element of the xml tree
    $tv = $domtree->createElement('tv');
    
    //create attributes for element
    $generator_info_name = $domtree->createAttribute('generator-info-name');
    $generator_info_name->value = 'www.mysite.com/xmltv';
    //append attribute
    $tv->appendChild($generator_info_name);
    // append element to the doc
    $tv = $domtree->appendChild($tv);
    
    //add a channel as a child of the root
    $channel = $domtree->createElement('channel');
    $channel_id = $domtree->createAttribute('id');
    $channel_id->value = '""';
    $channel = $tv->appendChild($channel);
    
    //append children to channel
    $channel->appendChild($domtree->createElement('display-name','Information from database'));
    $channel->appendChild($domtree->createElement("programme"));
    $channel->appendChild($domtree->createElement('desc'));
    
    //finally, save the file
    echo $domtree->saveXML();
    $domtree->save('myChannel.xml');
    ?>
    

     

     
    Do you know how I can make the same XML output as the first code?
     
    And how I can output for each data from mysql database to put it in each channel tag and I want to add the tags under the channel tag including the display-name, programme-channel, title, sub-title, desc and category tags when I output for each data from mysql?
     
    Any advise would be much appreciated.
     
    Thanks in advance
  3. Hi guys,

    I have got a problem with scraping the data from a third party website. I'm currently using a preg_match_all method with each different title tags including the values to output the data from a third party website to my website where I can see some of the data are missing.


    Here's what the HTML is look like from a third party:

        <span id="row1Time" class="zc-ssl-pg-time">9:00 AM</span>
        <a id="rowTitle1" class="zc-ssl-pg-title">CBS News Sunday Morning</a>
        <span id="row2Time" class="zc-ssl-pg-time">10:30 AM</span>
        <a id="rowTitle2" class="zc-ssl-pg-title">Face the Nation</a>
        <span id="row3Time" class="zc-ssl-pg-time">11:30 AM</span>
        <span id="rowTitle3" class="zc-ssl-pg-title">Local Programming</span>
        <span id="row4Time" class="zc-ssl-pg-time">12:00 PM</span>
        <a id="rowTitle4" class="zc-ssl-pg-title">The NFL Today</a>
        <span id="row5Time" class="zc-ssl-pg-time">1:00 PM</span>
        <a id="rowTitle5" class="zc-ssl-pg-title">NFL Football</a>
        <span id="row6Time" class="zc-ssl-pg-time">4:30 PM</span>
        <a id="rowTitle6" class="zc-ssl-pg-title"'>2013 U.S. Open Tennis</a>
        <span id="row7Time" class="zc-ssl-pg-time">7:00 PM</span>
        <span id="rowTitle7" class="zc-ssl-pg-title">Local Programming</span>
        <span id="row8Time" class="zc-ssl-pg-time">7:30 PM</span>
        <a id="rowTitle8" class="zc-ssl-pg-title">CBS Evening News</a>


    Here is the HTML output data on my website:
        <span id='time1'>9:00 AM</span> - <span id='title1'>CBS News Sunday Morning</span><br></br>
        <span id='time2'>10:30 AM</span> - <span id='title2'>Face the Nation</span><br></br>
        <span id='time3'></span> - <span id='title3'></span><br></br>
        <span id='time4'>12:00 PM</span> - <span id='title4'>The NFL Today</span><br></br>
        <span id='time5'>3:30 PM</span> - <span id='title5'>The Bold and the Beautiful</span><br></br>
        <span id='time6'>4:00 PM</span> - <span id='title6'>The Talk</span><br></br>
        <span id='time7'></span> - <span id='title7'></span><br></br>
        <span id='time8'>7:30 PM</span> - <span id='title8'>CBS Evening News</span><br></br>


    Here's the php code:
        <?php
          define('DB_HOST', 'localhost');
          define('DB_USER', 'myusername');
          define('DB_PASSWORD', 'mypassword');
          define('DB_DATABASE', 'mydb');
              
          $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");
          }
        
          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 FROM tvguide WHERE channels='$channels' && id='$id'";
              $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error());
                  
                
              while ($row = mysql_fetch_array($result1))
              {
            
                $links = $row['links'];
                $data = file_get_contents($links);
                preg_match_all('/<span id="row1Time\" class="zc-ssl-pg-time">([^<]+)<\/span>[^>]+>([^<]+)<\/a>/im', $data, $matches);
                preg_match_all('/<a id="rowTitle1\" class="zc-ssl-pg-title"[^>]*>([^<]+)<\/a>/im', $data, $matches1);
                $time1 = $matches[1];
                $titles1 = $matches1[1];
                echo "<span id='time1'>".$time1[1]."</span> - <span id='title1'>".$titles1[1]."</span><br></br>";
        
                preg_match_all('/<span id="row2Time\" class="zc-ssl-pg-time">([^<]+)<\/span>[^>]+>([^<]+)<\/a>/im', $data, $matches);
                preg_match_all('/<a id="rowTitle2\" class="zc-ssl-pg-title"[^>]*>([^<]+)<\/a>/im', $data, $matches2);
                $time2 = $matches[1];
                $titles2 = $matches2[1];
                echo "<span id='time2'>".$time2[1]."</span> - <span id='title2'>".$titles2[1]."</span><br></br>";
        
                preg_match_all('/<span id="row3Time\" class="zc-ssl-pg-time">([^<]+)<\/span>[^>]+>([^<]+)<\/a>/im', $data, $matches);
                preg_match_all('/<a id="rowTitle3\" class="zc-ssl-pg-title"[^>]*>([^<]+)<\/a>/im', $data, $matches3);
                $time3 = $matches[1];
                $titles3 = $matches3[1];
                echo "<span id='time3'>".$time3[1]."</span> - <span id='title3'>".$titles3[1]."</span><br></br>";
        
                preg_match_all('/<span id="row4Time\" class="zc-ssl-pg-time">([^<]+)<\/span>[^>]+>([^<]+)<\/a>/im', $data, $matches);
                preg_match_all('/<a id="rowTitle4\" class="zc-ssl-pg-title"[^>]*>([^<]+)<\/a>/im', $data, $matches4);
                $time4 = $matches[1];
                $titles4 = $matches4[1];
                echo "<span id='time4'>".$time4[1]."</span> - <span id='title4'>".$titles4[1]."</span><br></br>";
                
                preg_match_all('/<span id="row5Time\" class="zc-ssl-pg-time">([^<]+)<\/span>[^>]+>([^<]+)<\/a>/im', $data, $matches);
                preg_match_all('/<a id="rowTitle5\" class="zc-ssl-pg-title"[^>]*>([^<]+)<\/a>/im', $data, $matches5);
                $time5 = $matches[1];
                $titles5 = $matches5[1];
                echo "<span id='time5'>".$time5[1]."</span> - <span id='title5'>".$titles5[1]."</span><br></br>";
                
                preg_match_all('/<span id="row6Time\" class="zc-ssl-pg-time">([^<]+)<\/span>[^>]+>([^<]+)<\/a>/im', $data, $matches);
                preg_match_all('/<a id="rowTitle6\" class="zc-ssl-pg-title"[^>]*>([^<]+)<\/a>/im', $data, $matches6);
                $time6 = $matches[1];
                $titles6 = $matches6[1];
                echo "<span id='time6'>".$time6[1]."</span> - <span id='title6'>".$titles6[1]."</span><br></br>";
                
                preg_match_all('/<span id="row7Time\" class="zc-ssl-pg-time">([^<]+)<\/span>[^>]+>([^<]+)<\/a>/im', $data, $matches);
                preg_match_all('/<a id="rowTitle7\" class="zc-ssl-pg-title"[^>]*>([^<]+)<\/a>/im', $data, $matches7);
                $time7 = $matches[1];
                $titles7 = $matches7[1];
                echo "<span id='time7'>".$time7[1]."</span> - <span id='title7'>".$titles7[1]."</span><br></br>";
                
                preg_match_all('/<span id="row8Time\" class="zc-ssl-pg-time">([^<]+)<\/span>[^>]+>([^<]+)<\/a>/im', $data, $matches);
                preg_match_all('/<a id="rowTitle8\" class="zc-ssl-pg-title"[^>]*>([^<]+)<\/a>/im', $data, $matches8);
                $time8 = $matches[1];
                $titles8 = $matches8[1];
                echo "<span id='time8'>".$time8[1]."</span> - <span id='title8'>".$titles8[1]."</span><br></br>";
         }
              mysql_close($link);
            }
            else if(!$channels && ! $id)
            {
              $qrytable1="SELECT id, channels, links FROM tvguide";
              $result1=mysql_query($qrytable1) or die('Error:<br />' . $qry . '<br />' . mysql_error());
             
              while ($row = mysql_fetch_array($result1))
              {
                echo "<p id='channels'>";
                echo $row['channels'];
                echo "<p id='links'>";
                echo . $row["channels"] . "&id=" . $row["id"] .'</p>';
              }
            }
          }
        ?>
    



    Does anyone know how I can scrape the data using with the preg_match_all or similar method that I currently use including with the time and the title tags with the values so I can output the data without being missing?

    I tried with PHP DOM, but I have no idea how to scrape the ids and the classes.

    If you could post the example PHP DOM including with the ids and classes, I would be very grateful.

    Any advice would be much appreciated.

    Thanks in advance

  4. Hi guys,

    I have got a problem with my JavaScript. I am using the code in my PHP to allow me to use ajax and JavaScript at the same time. There is a problem with the keyboard control, I have four blocks of div with each different size. When I have all four block on per row of div, I can be able to move the yellow block to the four blocks using with the keyboard right arrow button while the four div blocks are moving to the left. When I have one of the blocks that are big while I still have four blocks, I can be able to move the yellow block to the four blocks, but I cannot be able to move the four blocks to the left.


    Here is the code:

    <!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <script src="http://code.jquery.com/jquery-1.9.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    function GetXmlHttpObject()
    {
      if(window.XMLHttpRequest)
      {
        // code for IE7+, Firefox, Chrome, Opera, Safari
        return new XMLHttpRequest();
      }
      else
      {
        // code for IE6, IE5
        return new ActiveXObject("Microsoft.XMLHTTP");
      }
      return null;
    }
    
    var current_col = 1;
    var current_row = 1;
    
    $(document).keyup(function(event){
    var yellowbg = $(".yellowbg");
    var rowwidth = $(".row").css( "width").split("px");
    var yellowbgdivclass = yellowbg.attr('class');
    var splitclass = yellowbgdivclass.split(" ");
    var getcurrentrow = splitclass[1].split("_");
    
    var mainWraptop = $(".mainWrap").position().top;
    var mainWrapheight = $(".mainWrap").height();
    var rowmove=$("#rowmove").val();
    //alert($(".row").length);
    
    var displayrowcount = 6;  //is using for to hide other channels
    var rowheight = 42;
    var rowwidth = 1053;  //is using for how much width the row is going to display while hide the other rows
    var rowwidth1 = 1303;  //is using for how much width the row is going to display while hide the other rows
    var totalwidth_current = 0;
    var totalwidth_current1 = 0;
    
    if(parseInt(current_row)+parseInt(1) <=5)
    {
      for(var i=1; i<=(parseInt(current_row)+parseInt(1));i++ )
      {
        var yellowbgnextdivwidth = $(".div_"+current_col+'_'+i).css( "width");
        var yellowbgnextdivwidthsplit = yellowbgnextdivwidth.split("px");
        totalwidth_current=parseInt(totalwidth_current)+parseInt(yellowbgnextdivwidthsplit[0]);
      }
    }
    
      if (event.keyCode == 39)
      {  //right
        if (yellowbg.next().length)
        {
          var currentrowleft = $(".rowSubPgm div.pgmFirstRow:first").css( "margin-left").split("px");
          currentrowleft1 = currentrowleft[0].split("-");
          currentrowleft2 = currentrowleft[0].split("-");
    
          if(typeof(currentrowleft2[1])!= "undefined")
            currentrowleft = currentrowleft2[1];
          else if(typeof(currentrowleft1[1])!= "undefined")
            currentrowleft = currentrowleft1[1];
          else
            currentrowleft = currentrowleft[0];
                        
          var nextdivwidth = $(".div_"+current_col+'_'+(parseInt(current_row)+parseInt(1))).css( "width").split("px");    
                    
          //alert((parseInt(rowwidth)+parseInt(currentrowleft)));
          //alert(totalwidth_current);
          //alert((parseInt(rowwidth)+parseInt(currentrowleft)) < totalwidth_current);
          //alert(nextdivwidth);
          //alert(totalwidth_current);
          
          if((parseInt(rowwidth)+parseInt(currentrowleft)) < totalwidth_current)
          {
        $("body").find('.rowSubPgm').each(function(index) {
        //var approx = rowwidth/250;
        $(this).find('.pgmFirstRow:first').css( "margin-left", "-"+(rowwidth)+"px" );
        });
        $(".rows div:nth-child(2)").css( "margin-left", "-"+parseInt(rowleft)-70 );
          }    
          
          if((parseInt(rowwidth)+parseInt(currentrowleft1)) < totalwidth_current)
          {
        $(".div_"+current_col+'_'+current_row).css( "margin-left", "-"+rowleft );
          }
          
          if((parseInt(rowwidth1)+parseInt(currentrowleft1)) > totalwidth_current)
          {
        $(".div_"+current_col+'_'+current_row).css( "margin-left", "-"+rowleft );
          }
                
          if(yellowbg.next().position().top == yellowbg.position().top)
          {
        $(".div_"+current_col+'_'+current_row).css( "margin-left", "-"+rowleft );
          }
          else
          {
            alert("5");            
        currentrowleft = parseInt(currentrowleft)+rowwidth;
        var rowleft = currentrowleft+="px";
        $("body").find('.rowSubPgm').each(function(index) {
        $(this).find('.pgmFirstRow:first').css( "margin-left", "-"+rowleft );
        });
        $(".rows div:nth-child(2)").css("margin-left", "-"+parseInt(rowleft)-70);                
          }
          current_row++;
        }
      }
    }




    Does anyone know how I can move the four block to the left using with the keyboard right arrow button control when I have one of the block that are big??

    If you need to see my website link for better understanding, please let me know and I would be happy to send on PM.

    Any advice would be much appreciated.

    Thanks in advance

  5. Hi guys,

    I have got a problem with my current script and I really need your help. I have four blocks on my webpage, I am trying to scrape the title4" data from my other script to output it in my main page. I can be able to output three titles without have any problem, but I can't be able to output on four titles only three :(.

    Here is the code:

    function getSchule($link,j)
    {
      //var widthval = 350;
      var widthval =  850;
      var parts = $link.split("/");
      var links = parts[parts.length-1];
      var programlength = 0;
        
      $.ajax({
      url:$.trim(links),
      type:'GET',
      data:'',
      success: function(data)
      {
        var $data = $(data);        
        var title1 = $data.filter("#title1").html();
        var title2 = $data.filter("#title2").html();
        var title3 = $data.filter("#title3").html();
        var title4 = $data.filter("#title4").html();
                
        var time1 = $data.filter("#time1").html();
        var time2 = $data.filter("#time2").html();
        var time3 = $data.filter("#time3").html();
        var time4 = $data.filter("#time4").html();
        var time5 = $data.filter("#time5").html();
        
        time1 = time1.split(" ");
        var time1AMPM = time1[1];
        time1 = time1[0].split(":");
        time1= time1[0]+'.'+time1[1];
        if($.trim(time1AMPM) == 'PM' && time1<12)
        time1 = parseFloat(time1)+12;
                
        time2 = time2.split(" ");
        var time2AMPM = time2[1];
        time2 = time2[0].split(":");
        time2= time2[0]+'.'+time2[1];
        if($.trim(time2AMPM) == 'PM' && time2<12)
        time2 = parseFloat(time2)+12;
                
        time3 = time3.split(" ");
        var time3AMPM = time3[1];
        time3 = time3[0].split(":");
        time3= time3[0]+'.'+time3[1];
        if($.trim(time3AMPM) == 'PM' && time3<12)
        time3 = parseFloat(time3)+12;
                
        time4 = time4.split(" ");
        var time4AMPM = time4[1];
        time4 = time4[0].split(":");
        time4= time4[0]+'.'+time4[1];
        if($.trim(time4AMPM) == 'PM' && time4<12)
        time4 = parseFloat(time4)+12;
        
        time5 = time5.split(" ");
        var time5AMPM = time5[1];
        time5 = time5[0].split(":");
        time5= time5[0]+'.'+time5[1];
        if($.trim(time5AMPM) == 'PM' && time5<12)
        time5 = parseFloat(time5)+12;
            
        var difftime2time1 = (parseFloat(time2) - parseFloat(time1)).toFixed(2);
        var difftime3time2 = (parseFloat(time3) - parseFloat(time2)).toFixed(2);
        var difftime4time3 = (parseFloat(time4) - parseFloat(time3)).toFixed(2);
        var difftime5time4 = (parseFloat(time5) - parseFloat(time4)).toFixed(2);
                
        if(isNaN(difftime2time1))
        {
          difftime2time1=0;
        }
        if(isNaN(difftime3time2))
        {
          difftime3time2=0;
                }
        if(isNaN(difftime4time3))
        {
          difftime4time3=0;
        }
        if(isNaN(difftime5time4))
        {
          difftime5time4=0;
        }    
        var currenttotal = 0;    
        var firstele = ((j-1)*4)+1; // how many programme i want to output in per block
        var lastele = parseInt(firstele)+2;
        var k=1;
        var programlength = 0;
        for(;firstele <= lastele;firstele++)
        {
          var nexttimedate = parseInt(k)+1;
          programlength = parseFloat(programlength) + parseFloat(eval('difftime'+nexttimedate+'time'+k));
          
          if((eval('difftime'+nexttimedate+'time'+k)) > 0.99 && (eval('difftime'+nexttimedate+'time'+k)) <=1.00 )
          {
            $('#programe'+firstele).addClass("span1hr");
            width[j]=517;
          }
          
          if((eval('difftime'+nexttimedate+'time'+k)) > 1.00 && (eval('difftime'+nexttimedate+'time'+k)) <=1.30 )
          {
            $('#programe'+firstele).addClass("span1hr");
            width[j]=517;  
          }
          
          if((eval('difftime'+nexttimedate+'time'+k)) > 1.03 && (eval('difftime'+nexttimedate+'time'+k)) <=1.33 )
          {
            $('#programe'+firstele).addClass("span1hr");
            width[j]=517;  
          }
          
          if((eval('difftime'+nexttimedate+'time'+k)) > 1.30 && (eval('difftime'+nexttimedate+'time'+k)) <=2.00 )
          {
            $('#programe'+firstele).addClass("span1_5hr");
            width[j]=701;  
          }
          
          if((eval('difftime'+nexttimedate+'time'+k)) > 2.00 && (eval('difftime'+nexttimedate+'time'+k)) <=2.30 )
          {
            $('#programe'+firstele).addClass("span2hr");
            width[j]=1303;
          }
          
          if((eval('difftime'+nexttimedate+'time'+k)) > 2.30 && (eval('difftime'+nexttimedate+'time'+k)) <=3.00 )
          {
            $('#programe'+firstele).addClass("span2_5hr");
            width[j]=1553;
          }
          
          if((eval('difftime'+nexttimedate+'time'+k)) > 3.00 && (eval('difftime'+nexttimedate+'time'+k)) <=3.30 )
          {
            $('#programe'+firstele).addClass("span3hr");
            width[j]=1803;
          }
    
          
          if(programlength == 0.30)
          {
            if(currenttotal == 0)
            {
              $('#programe'+firstele).addClass("span0hr");
              width[j]=250;
            }
          }
          
          if(programlength == 1.00)
          {
            if(currenttotal == 0)
            {
              $('#programe'+firstele).addClass("span1hr");
              width[j]=517;
            }    
          }
          
          if(programlength == 1.01)
          {
            if(currenttotal == 0)
            {
              $('#programe'+firstele).addClass("span1hr");
              width[j]=517;
            }    
          }
          
          if(programlength == 1.02)
          {
            if(currenttotal == 0)
            {
              $('#programe'+firstele).addClass("span1hr");
              width[j]=517;
            }    
          }
          
          if(programlength == 1.03)
          {
            if(currenttotal == 0)
            {
              $('#programe'+firstele).addClass("span1hr");
              width[j]=517;
            }    
          }
          
          if(programlength == 1.30)
          {
            if(currenttotal == 0)
            {
              $('#programe'+firstele).addClass("span1_5hr");
              width[j]=701;
            }        
          }
              
              if(programlength == 2.00)
          {
            if(currenttotal == 0)
            {
              $('#programe'+firstele).addClass("span2hr");
              width[j]=1303;
            }            
          }
          
          if(programlength == 2.30)
          {
            if(currenttotal == 0)
            {
              $('#programe'+firstele).addClass("span2_5hr");
              width[j]=1553;
            }        
          }
          
          if(programlength == 3.00)
          {
            if(currenttotal == 0)
            {
              $('#programe'+firstele).addClass("span3hr");
              width[j]=1803;
            }        
          }
          currenttotal++;
          pgmcontent[firstele] = eval('title'+k);
          k++;        
        }
        checksum+=j;
                
        if(checksuminit == checksum)
        {
        
          for(var ii=1;ii<width.length-1;ii++)
          {
            widthval+=width[ii];
          }
          
          for(var jj=1;jj <= pgmcontent.length-1;jj++)
          {
            $('#programe'+jj).html(pgmcontent[jj]);
          }
          
          for(var kk=1;kk <= imagecontent.length-1;kk++)
          {
            $('#image'+kk).html(imagecontent[kk]);
          }
            $("body").find('.rowSubPgm').each(function(index) {
            $(this).css( "width", widthval+"px");
          });
          $("div").show();    
        }
      }   
      });
    }




    I am using ajax to output the data to my main page. I can't be able to figure out where the trouble is coming from.

    Does anyone know what the problem is?

    Any idea??

  6. Hi guys,

    I have got a problem with the code in my PHP. I stored 8 rows of channels in mysql database and I use var totalrowcount to display 8 boxes for div classes to display with rows that I stored from mysql, but I cannot be able to display more than 8 boxes of div classes when I store more than 8 rows in mysql.

    I want to create the unlimited boxes for div classes with any range of number to match the rows depends on how many rows that I store in mysql database.

    Here is the code I found where the trouble is coming from:

    var totalrowcount = 8;
    
    <div class="mainWrap">
        <div class="row" id="row1">
            <div id="image1" class="channelList div_1_1"></div>
            <div class="rowSubPgm">
                <div id="programe1" class="pgmFirstRow div_1_2"></div>
                <div id="programe2" class="pgmFirstRow div_1_3"></div>
                <div id="programe3" class="pgmFirstRow div_1_4"></div>
            </div>
        </div>
        <div class="clear"></div>
        <div class="row"  id="row2">
            <div id="image2" class="channelList div_2_1"></div>
            <div class="rowSubPgm">
                <div id="programe4" class="pgmFirstRow div_2_2"></div>
                <div id="programe5" class="pgmFirstRow div_2_3"></div>
                <div id="programe6" class="pgmFirstRow div_2_4"></div>
            </div>
        </div>
        <div class="clear"></div>
        <div class="row"  id="row3">
            <div id="image3" class="channelList div_3_1"></div>
            <div class="rowSubPgm">
                <div id="programe7" class="pgmFirstRow div_3_2"></div>
                <div id="programe8" class="pgmFirstRow div_3_3"></div>
                <div id="programe9" class="pgmFirstRow div_3_4"></div>
           </div>
        </div>
        <div class="clear"></div>
        <div class="row"  id="row4">
            <div id="image4" class="channelList div_4_1"></div>
            <div class="rowSubPgm">
                <div id="programe10" class="pgmFirstRow div_4_2"></div>
                <div id="programe11" class="pgmFirstRow div_4_3"></div>
                <div id="programe12" class="pgmFirstRow div_4_4"></div>
           </div>
        </div>
        <div class="clear"></div>
        <div class="row"  id="row5">
            <div id="image5" class="channelList div_5_1"></div>
            <div class="rowSubPgm">
                <div id="programe13" class="pgmFirstRow div_5_2"></div>
                <div id="programe14" class="pgmFirstRow div_5_3"></div>
                <div id="programe15" class="pgmFirstRow div_5_4"></div>
            </div>
        </div>
        <div class="clear"></div>
        <div class="row" id="row6">
            <div id="image6" class="channelList div_6_1"></div>
            <div class="rowSubPgm">
                <div id="programe16" class="pgmFirstRow div_6_2"></div>
                <div id="programe17" class="pgmFirstRow div_6_3"></div>
                <div id="programe18" class="pgmFirstRow div_6_4"></div>
           </div>
        </div>
        <div class="clear"></div>
            <div class="row"  id="row7">
            <div id="image7" class="channelList div_7_1"></div>
            <div class="rowSubPgm">
                <div id="programe19" class="pgmFirstRow div_7_2"></div>
                <div id="programe20" class="pgmFirstRow div_7_3"></div>
                <div id="programe21" class="pgmFirstRow div_7_4"></div>
            </div>
        </div>
        <div class="clear"></div>
            <div class="row"  id="row8">
            <div id="image8" class="channelList div_8_1"></div>
            <div class="rowSubPgm">
                <div id="programe22" class="pgmFirstRow div_8_2"></div>
                <div id="programe23" class="pgmFirstRow div_8_3"></div>
                <div id="programe24" class="pgmFirstRow div_8_4"></div>
            </div>
        </div>
        <div class="clear"></div> 




    I can output the unlimited rows from mysql without have any problem, but I cannot display more than 8 boxes for div classes. If I want to create the classes, I would have to change the last number in each line at the end, e.g: pgmFirstRow div_9_4, pgmFirstRow div_10_4 and so on.

    I am going to store thousand of rows in mysql and I find that it would be too much for me to work it on to add thousand lines of codes for add div classes.

    Does anyone know how to create the code to allow me to add unlimited number of div classes using with the arrays for the totalrowcount to match the rows that I store in mysql to allow me to add any range of boxes for div classes??

    Any advice would be much appreciated.

    Thanks in advance

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.