how fetch from database with horizontally ?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mshatil
    New Member
    • Sep 2014
    • 1

    how fetch from database with horizontally ?

    I have MySQL table where column id fname lname age. I want a selection tag which option is all the data of age.. how do i do that?

    actually I'm very much beginner in PHP MySQL.
  • Luuk
    Recognized Expert Top Contributor
    • Mar 2012
    • 1043

    #2
    There's no such thing as 'PHP MySQL'

    There's PHP, see http://php.net/manual/en/intro-whatis.php
    and
    There's MySQL, see http://dev.mysql.com/doc/refman/5.6/...-is-mysql.html

    The answer to your question, in MySQL is:
    Code:
    SELECT id, fname, lname, age
    FROM table
    WHERE age=42
    Examples on how to implement this query in PHP can be found on the internet.

    Comment

    • Exequiel
      Contributor
      • Jul 2012
      • 288

      #3
      you can do it this way. .
      Code:
      <?php
      $options = "";
      //get data to your table
      $getquery = mysql_query("SELECT * FROM your_tbl");
      while($datas = mysql_fetch_array($getquery)) 
      {
      $options .= '<option value="'.$datas['age'].'">'.$datas['age'].'</option>';
      }
      echo '<select>'.$options.'</select>';//display
      ?>

      Comment

      Working...