note 55055 deleted from function.sqlite-fetch-single by cmb

From: Date: Mon, 02 Nov 2020 14:59:52 +0000
Subject: note 55055 deleted from function.sqlite-fetch-single by cmb
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-215733@lists.php.net to get a copy of this message
Note Submitter: jmarbas at hotmail dot com ---- It isnt specified in the above description for this function, but yes this function will not only return the first column, but it will also return the first value (ie from the first row in the result set) of that column. Also the result set pointer is involved here in that if you use sqlite_fetch_single in a loop, it will return each value in the first column sequentially and advance the result set pointer each time. i.e. the first loop iteration it returns the first value in the first column. the second loop iteration it returns the second value in the first column. the third loop iteration the third value and so on. $handle = sqlite_open("database_file_name") or die("Could not open database"); //generate query string $query = "select distinct field1 from database_name"; //execute query $result = sqlite_query($handle,$query) //if a row exists if(sqlite_num_rows($result)>0){ echo "<table cellpadding=\"10\" border=\"1\">"; //check for more rows while(sqlite_has_more($result)){ //get first field from each row //print values $row=sqlite_fetch_single($result); echo "<tr>"; echo "<td>".$row."</td>"; echo "</tr>"; } echo "</table>"; } //close database file sqlite_close($handle);

« previous php.notes (#215733) next »