Database query

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

    Database query

    Hi guys

    Im trying to call a value or values from a table from a specific row, but for sum reason it aint working, or i got the code wrong.

    Code:
    $item = mysql_fetch_array(mysql_query("SELECT value FROM table WHERE category='a'"));
    
    i want to select all the values in a column called category and print each value and i dont want to use the while statement.
    
    example: i want to print like this: hello  $item[name1]. do you know $item[name2].
    sigpic

    |~~Dont forget to say thanx~~|

    #2
    Read it .

    Comment


      #3
      PHP Code:
      $item mysql_fetch_array(mysql_query("SELECT value,name,car,test FROM table WHERE category='a'"));

      $item[0]
      $item[1]
      $item[2]
      $item[3
      Last edited by metulj; 05.06.09, 19:10.
      Visit: Chat4u.mobi - The New Lay Of being a site of your dreams!
      Visit: WapMasterz Coming Back Soon!
      _______
      SCRIPTS FOR SALE BY SUBZERO
      Chat4u Script : coding-talk.com/f28/chat4u-mobi-script-only-150-a-17677/ - > Best Script for your site no other can be hacked by sql or uploaders.
      FileShare Script : coding-talk.com/f28/file-wap-share-6596/ -> Uploader you will never regret buying yeah it mite be old now but it still seems to own others...
      _______
      Info & Tips
      php.net
      w3schools.com

      Comment


        #4
        can u find a tutorial for sorting data in pages ?
        SAY like 5 data in 1 page ?

        Comment


          #5
          PHP Code:
          <?php 
          // Connects to your Database 
          mysql_connect("your.hostaddress.com""username""password") or die(mysql_error()); 
          mysql_select_db("Database_Name") or die(mysql_error()); 
          $data mysql_query("SELECT * FROM friends LIMIT 5"
          or die(
          mysql_error()); 
          Print 
          "<table border cellpadding=3>"
          while(
          $info mysql_fetch_array$data )) 

          Print 
          "<tr>"
          Print 
          "<th>Name:</th> <td>".$info['name'] . "</td> "
          Print 
          "<th>Pet:</th> <td>".$info['pet'] . " </td></tr>"

          Print 
          "</table>"
          ?>
          Last edited by metulj; 05.06.09, 19:10. Reason: [ php ] ... [ / php] tag for posting code would be nice ;)

          Comment


            #6
            Did you try
            PHP Code:
            SELECT FROM table WHERE active='1' 
            And you also can call it like
            $item['car'] or whatever your table is

            PHP Code:
            foreach ($_SERVER as $server => $value)
            {
            echo 
            "$server is $value<br />";

            Comment


              #7
              try this

              Originally posted by synergyx2009 View Post
              Hi guys

              Im trying to call a value or values from a table from a specific row, but for sum reason it aint working, or i got the code wrong.

              Code:
              $item = mysql_fetch_array(mysql_query("SELECT value FROM table WHERE category='a'"));
              
              i want to select all the values in a column called category and print each value and i dont want to use the while statement.
              
              example: i want to print like this: hello  $item[name1]. do you know $item[name2].
              According the code you wrote,,,
              Try this,
              if you want to call a specific item:
              Code:
              $item = mysql_fetch_array(mysql_query("SELECT value FROM table WHERE category='a'"));
              
              $that_item = $item[0];
              
              echo "$that_item";
              For calling multi items follow the subzero's post.
              Thanks. @ synergyx2009
              Wait...
              sigpic

              Comment

              Working...
              X