Visualizzazione dei risultati da 1 a 5 su 5
  1. #1

    SQL, come selezionare ultima riga?

    Come seleziono con sql l'ultima riga di una tabella?

    Ho provato così:

    Codice PHP:
    mysql_query
    ("SELECT * FROM utenti WHERE EMAIL='".$email."' AND CODE='".$code."'");                
    mysql_query
    ("INSERT INTO home VALUES ('','".$nom."','".$cog."','".$date."','".$time."','".$text."','".$tic."')");    
    $query_1 mysql_query("SELECT TOP 0 FROM home DESC");
    $nrw_1 mysql_num_rows($query_1); 
    Errore:
    codice:
    Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\Program Files\EASYPHP\www\home.php on line 233

  2. #2
    Codice PHP:
    mysql_query
                    
    ("SELECT * FROM utenti WHERE EMAIL='".$email."' AND CODE='".$code."'");                
                    
    mysql_query
                    
    ("INSERT INTO home VALUES ('','".$nom."','".$cog."','".$date."','".$time."','".$text."','".$tic."')");    
                            
                    
    $query_1 mysql_query("SELECT FIRST 1 FROM home ORDER BY ID DESC") or die (mysql_error());
                    
    $nrw_1 mysql_num_rows($query_1); 
    Mi dice:
    codice:
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '1 FROM home ORDER BY ID DESC' at line 1

  3. #3
    Utente di HTML.it L'avatar di nman
    Registrato dal
    Jan 2011
    residenza
    Milano
    Messaggi
    1,333
    Non conosco MySql quindi potrei sbagliare.


    Se la metti in ordine decrescente e poi fai " Limit1 "

    __________________________________________________ ______

    Qui troi un esempio gia risolto ( non da me ma da un altro utente )
    per selezionare gli ultimi 5 record


    Saluti

  4. #4
    No niente, stesso errore!
    Aiuto!

  5. #5
    RI-SOL-TO
    Codice PHP:
    $query_1 mysql_query("SELECT * FROM home ORDER BY ID DESC LIMIT 1") or die (mysql_error()); 

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.