Displaying Data From Mysql Tables

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Displaying Data From Mysql Tables

    this is the first time iam ever working with mysql and ive tried many tutorilas online but,they r too complicated for me to nderstand since its my first time
    ive a table named "mytable" with "id" "name" "dob"

    i just want to echo all of them in an order
    for ex:
    name=xyz
    dob=x/y/z

    name=abc
    dob=a/b/s....................

    ..........n

    i ve already made a file foe coonecting that is" sqlconect.php'

    #2
    maybe it will be like this
    Code:
    $get_data_query = @mysql_query("SELECT `id`, `name`,`dob` FROM `mytable` ORDER BY id ASC limit 20;");
    while ($get_data_query_result=mysql_fetch_array($get_data_query)){
    ++$i; print "[b]$i.[/b]Name: $get_data_query_result[1]
     DOB: $get_data_query_result[2]}

    Comment


      #3
      iam getting this error


      Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/evnixcom/public_html/wap/q23w/4rtt/q23w/data/trial.php on line 6

      Comment


        #4
        ok i got it right !! some small error on my side thnks!!

        Comment


          #5
          u need to connect to your database
          Code:
          $dbhost="";
          $dbuser="";
          $dbpass="";
          $dbname="";
          mysql_connect("$dbhost","$dbuser","$dbpass") or die(mysql_error()); 
          mysql_select_db("$dbname") or die(mysql_error());
          may be this code will help

          Comment


            #6
            To get a single thing out database:
            Code:
            $query=mysql_query("SELECT * FROM table");
            $resault=mysql_fetch_array($query);
            echo "Name: ".$resault[name]."
            \n";
            echo "Surname: ".$resault[surname]."
            \n";
            echo "Number: ".$resault[number]."
            \n";
            echo "Info: ".$resault[info]."
            \n";
            You saw at the top i said SELECT * FROM table
            what the * means, select everything from table, then just to make it easier i said [name] [number] and [info]
            (the name of the collems) or you could use LIMIT 0,2
            and use $rasault[0] $resault[1] $resault[2]...

            Hope this was usefull.

            Click here!!!

            Comment


              #7
              yes indeed it was helpfull,thnks spidey!!!

              Comment

              Working...
              X