Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2006
    Posts
    167
    Rep Power
    21

    How to make tv guide in php?


    Hi guys,

    I am working on my tv guide website and I start to kick it off. I am going to store the channels name in a mysql database, but I am not sure how to input each channel name in each different div tag like "channel1", "channel2", "channel3", "channel4", "channel5 and "channel6" when I store more than 4 channels in the database. Does anyone know how?

    The second things I want to know how I can check on the tv guide program website to compare the time how long the program will last for so I can then resize the image and input each program title in each text on each image instead of create the rows?

    Any advice would be much appreciated.

    Thanks in advance
    Last edited by stephen100; April 2nd, 2013 at 10:06 AM.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,332
    Rep Power
    594
    Show what you want the HTML to look like and what data is stored in your database and perhaps we can suggest a solution. Based on what you posted it is not clear what you are really asking.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2006
    Posts
    167
    Rep Power
    21
    i want the html to show like this:

    Code:
                 Today    5:00pm             5:30pm         6:00pm
    abc family
    abc news
    CNN
    Disney
    Fox news

    And my data is stored in the database:

    Code:
    id    channels   tv_link   startdate   enddate
    101 abc family
    102  abc news
    103 CNN
    104 Disney
    105 Fox news

    The channels and id is random so I want to know how to fill the channels in each different div tag in each row and how to compare on each row between the start time and end time whether if the program will start to run for 30 mins or 1 hour?
    Last edited by stephen100; April 2nd, 2013 at 11:48 AM.
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,332
    Rep Power
    594
    I'm still not sure what you are asking. You can just query the database for the information you want to display and loop though that data to output the HTML.

    If you are asking for someone to write the code for you then you are in the wrong forum. You want the hire a programmer forum. This is a help forum where you are expected to do the work and we can get you over the humps and suggest better programming techniques.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  8. #5
  9. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2006
    Posts
    167
    Rep Power
    21
    I am not in the wrong forum, i am in the right forum. I have set up the php script to output the data in html from mysql database. Now I want to read php in html, how I can do that?
    Last edited by stephen100; April 2nd, 2013 at 12:56 PM.
  10. #6
  11. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,332
    Rep Power
    594
    You can't "read php in html". However, if you mean how do you get the client information back from the browser then you need to create a form with the 'action' attribute pointing to the script you want to handle the input. All the fields in the form will show up in $_POST (using method=post attribute).
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2006
    Posts
    167
    Rep Power
    21
    I don't think you understand what I am asking for. I have created php to extact the data from mysql database:

    PHP Code:
    <?php
    session_start
    ();
      
    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_HOSTDB_USERDB_PASSWORD);
        
      if(!
    $link
      {
        die(
    'Failed to connect to server: ' mysql_error());
      }

      
    $db mysql_select_db(DB_DATABASE);
      if(!
    $db
      {
        die(
    "Unable to select database");
      }

      if(
    $errflag
      {
        
    $_SESSION['ERRMSG_ARR'] = $errmsg_arr;
        echo 
    implode('<br />',$errmsg_arr);
      }
      else 
      {
        
    $qrytable1="SELECT id, channels FROM tvguide";
        
    $result1=mysql_query($qrytable1) or die('Error:<br />' $qry '<br />' mysql_error());
         
        while (
    $row mysql_fetch_array($result1)) 
        {
          
    document.getElementById("channel1").style.visibility "visible"
          
    document.getElementById("channel1").innerHTML $row['channel'];
        }
      }
    ?>
    Now I want to link up the php file in html. Like I mean I can link up the javascript in html using with this code:

    Code:
    <script type="text/javascript" src="myfile.js"></script>
    How I can link up the php in html?

    I don't want to included my username and password in html as I don't want to take the risk to get my website to
  14. #8
  15. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,332
    Rep Power
    594
    Do you understand that PHP is server side only while Javascript is client side? You "link up PHP in HTML" by outputting the HTML from PHP. Once the HTML is sent to the client, PHP goes away and knows nothing about what is happening on the client side.
    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  16. #9
  17. Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Location
    Burb of Detroit, Michigan
    Posts
    86
    Rep Power
    76
    You'll need to use something like AJAX in order to do something like your wanting to do.
  18. #10
  19. Plays with fire
    Devshed Novice (500 - 999 posts)

    Join Date
    Aug 2003
    Location
    Barsoom
    Posts
    942
    Rep Power
    96
    If all you want to do is display the contents of your DB on the webpage, lose the javascript calls and do something like this:

    Code:
    while ($row = mysql_fetch_assoc($result1)) {
       echo "<tr><td>".$row['id']."</td>";
       echo "<td>".$row['channels']."</td>";
       echo "</tr>";
    }
    I don't see how you're storing the program information, but the concept is the same.

    I also imagine you'll need to build a query that matches the program's time with the correct date, but don't see that in your table structure.

    Also, please use PDO instead of mysql_query.
    “Be ashamed to die until you have won some victory for humanity.” -- Horace Mann

    "...all men are created equal." -- US Declaration of Independence
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2006
    Posts
    167
    Rep Power
    21
    do you know how to display the contents of my db on the html webpage when I link up my php in html?

    As for storing the program information, what I meant that when I storing the website links, i want to access to each website and I want to find out on each program how long they will last for before I could resize on each image in my webpage. how i can do that?

    I want to use a database to store the website information as it is more easy to use and I don't have to update on the computer.
  22. #12
  23. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,332
    Rep Power
    594
    Yes, as I said earlier, you run the query then use a loop to output each row in the desired format. Something like
    PHP Code:
    while ($row=$stmt->fetch()) {
       
    // echo the HTML here to format each entry using $row['<column name>']

    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  24. #13
  25. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2006
    Posts
    167
    Rep Power
    21
    yeah but I cant output the data from php to html. The document id I want to output the data from php to html:

    Code:
    document.getElementById("channel1").innerHTML = "<td>".$row['channels']."</td>";

    I tried this but it did not output the data.

    Any idea?
  26. #14
  27. No Profile Picture
    Contributing User
    Devshed Loyal (3000 - 3499 posts)

    Join Date
    Jul 2003
    Posts
    3,332
    Rep Power
    594
    You're mixing up Javascript and PHP. I looks like you are trying to build a table via Javascript. However, to do it that way you need to use Ajax as suggested by another poster. Normally you use PHP to do it something like this:
    PHP Code:
    while ($row=$stmt->fetch()) {
       echo 
    "<td>".$row['channel']."</td>";

    There are 10 kinds of people in the world. Those that understand binary and those that don't.
  28. #15
  29. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Nov 2006
    Posts
    167
    Rep Power
    21
    I am not using javascript to create a table to work with php, I never said that. Do I have to use ajax in html page like this?

    Code:
    <html>
    <head>
    <script>
    function showUser(str)
    {
    if (str=="")
      {
      document.getElementById("txtHint").innerHTML="";
      return;
      }
    if (window.XMLHttpRequest)
      {// code for IE7+, Firefox, Chrome, Opera, Safari
      xmlhttp=new XMLHttpRequest();
      }
    else
      {// code for IE6, IE5
      xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    xmlhttp.onreadystatechange=function()
      {
      if (xmlhttp.readyState==4 && xmlhttp.status==200)
        {
        document.getElementById("txtHint").innerHTML=xmlhttp.responseText;
        }
      }
    xmlhttp.open("GET","getuser.php?q="+str,true);
    xmlhttp.send();
    }
    </script>
    </head>
    </html>
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo