Need Some Basic Mysql Coding Help

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

    Need Some Basic Mysql Coding Help

    ive got a table with

    Code:
    id|username|password|gender|month|
    i want to echo the usernames who have their "month" as "june" and only the first 20 results should be echoed and please if possible use "for" loop instead of "while"


    i got this below code from ansh which is similar to my table

    Code:
    $get_data_query = @mysql_query("SELECT `id`, `username`,`password`,'gender','month' 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]
     month: $get_data_query_result[4]}


    #2
    how to fecth online users in lava? what will be the sql anyone know?
    Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

    <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

    Comment


      #3
      i got it thnks any way

      Code:
      <?php
      // Make a MySQL Connection
      $result = mysql_query("SELECT * FROM mytable   WHERE month= &#39;june&#39; ORDER BY id ASC limit 5;") or die(mysql_error());
           
      
      $i=6;
      
      while($row = mysql_fetch_array($result)){
      $i++;
          echo $row[1]. " - ". $row[3];
          echo "
      ";
      
      }
      ?>
      i got 5 results in one page does any one know how to do pagination with this

      Comment


        #4
        this is the coding
        Code:
        echo "Online: <a href=\"index.php?action=online&amp;sid=$sid\">".getnumonline()."</a>
        ";
        Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

        <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

        Comment


          #5
          Code:
          $info = mysql_query("SELECT id, name, password, gender, month FROM mytable WHERE month=&#39;june&#39; ORDER BY id ASC LIMIT 20,0");
          
          while($do = mysql_fetch_array($info))
          {
              echo &#39;ID: &#39;.$do[0];
              echo &#39;
          Name: &#39;.$do[1];
              echo &#39;
          Password: &#39;.$do[2];
              echo &#39;
          Gender: &#39;.$do[3];
              echo &#39;
          Month: &#39;.$do[4];
          }

          Comment


            #6
            im sorry i mess the topic but i need helping please
            Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

            <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

            Comment


              #7
              i tried
              Code:
              $onl = mysql_fetch_array(mysql_query("SELECT COUNT(*) FROM ibwf_online"));
              echo "<a href=\"index.php?action=gonline&amp;sid=$sid\">Online! $onl[0]</a>
              ";
              
              and get error
              
              Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/public_html/index.php on line 950
              Failure is not when a girls leaves you, its only when you let her go virgin. heheh!!

              <span style="color:#9ACD32"><span style="font-size:36pt;line-height:100%">BEST MOBILE ADVERTISER</span></span>

              Comment


                #8
                did you supply the column name all i see is the table name

                Comment

                Working...
                X