SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Addict
    Join Date
    May 2005
    Posts
    209
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question solve THE TEASER: retrieving the largest value from mysql db

    friends! good morning...can u solve this small problem of mine?
    wat i want is to find out the largest of the int values stored in a field called 'qno' in the table 'questions'. i tried the following script....but i dont get any output.....kindly help......waiting eagerly
    PHP Code:
    <?php
    /* Connect to the MySQL database */
    $db_connectio mysql_connect( )
    or die(
    "Could not connect to DB");

    /* Select the MasteringPHP database */
    mysql_select_db ("questionnaire"$db_connectio)or die("mysql_error()");

    $query15="select max(qno) from questions";
    $result15=@mysql_query($query15,$db_connectio) or die(mysql_error());
       while( 
    $row=@mysql_fetch_object($result15))

          { 
    $up_lim=$row->qno;}

       echo
    $up_lim;
       
       
    mysql_close();
       
    ?>

  2. #2
    SitePoint Enthusiast
    Join Date
    Jun 2005
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    <?php 
    /* Connect to the MySQL database */ 
    $db_connectio mysql_connect( ) 
    or die(
    "Could not connect to DB"); 

    /* Select the MasteringPHP database */ 
    mysql_select_db ("questionnaire"$db_connectio)or die("mysql_error()"); 

    $query15="select max(qno) AS maximum from questions"
    $result15=@mysql_query($query15,$db_connectio) or die(mysql_error()); 
       while( 
    $row=@mysql_fetch_object($result15)) 

          { 
    $up_lim=$row->maximum;} 

       echo
    $up_lim
        
       
    mysql_close(); 
       
    ?>


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •