how to output data from php to html?

Discussion in 'PHP' started by mark103, Apr 3, 2013.

  1. #1
    Hi guys,

    I need your help. I have stored the information in mysql database where I can print it out in my php using with this following code:

    <?php
    session_start();
      define('DB_HOST', 'localhost');
      define('DB_USER', 'mydbusername');
      define('DB_PASSWORD', 'mydbpassword');
      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");
      }
    
      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))
        {
          echo "</br>";
          echo "<td>".$row['channels']."</td>";
          echo "</br>";
        } 
      }
    ?>
    PHP:

    Now I want to know how I can output the data from php to html, do you know how?

    if you do then i need your help.

    thanks in advance.
     
    mark103, Apr 3, 2013 IP
  2. GMF

    GMF Well-Known Member

    Messages:
    855
    Likes Received:
    113
    Best Answers:
    19
    Trophy Points:
    145
    #2

    You already do that with your while loop. The lines you echo out ARE html


    Or do you mean something different?
     
    GMF, Apr 4, 2013 IP
  3. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,999
    Best Answers:
    253
    Trophy Points:
    515
    #3
    Yeah that question doesn't make any sense, you're already doing it...

    though that data REALLY doesn't look tabular or belong in TD... much less the lack of logic to break it up... and the presence of the mysql_ functions they've been telling us for eight years to stop using and finally had to put a big red warning box up about that on every page of php.net...
     
    deathshadow, Apr 4, 2013 IP