0
I’m making a select
in this way.
$stmt = $lokos->prepare("select CODIGO_PROGRAMA, VERSAO_PROGRAMA,
DATA_INSERCAO, DESCRICAO_ALTERACAO from
programas_padrao Order by DESCRICAO_ALTERACAO DESC");
This select it will pull all the data that has in my data box.
ex: PROGRAMME 1, PROGRAMME 2, PROGRAMA3
Like I do for mine select
or through a if
display only the latest instead of displaying PROGRAMA1, PROGRAM 2 and 3?
How do I make it display only 3?
That’s the Original code. Which I’m having trouble doing.
<?php
$user = "SYSDBA";
$pass = "masterkey";
try{
$lokos=new PDO("firebird:localhost=127.0.0.1;dbname=DUOSIG_APLICACAO",$user,$pass);
}catch(PDOException $e) {
echo "Falha na conexão.".$e->getcode();
}
$stmt = $lokos->prepare("select CODIGO_PROGRAMA, VERSAO_PROGRAMA, DATA_INSERCAO, DESCRICAO_ALTERACAO from programas_padrao Order by DESCRICAO_ALTERACAO DESC");
$stmt->execute();
$dados = $stmt->fetchAll(PDO::FETCH_OBJ);
foreach ($dados as $row) {
echo "<li class='nome'>{$row->CODIGO_PROGRAMA} </li> ";
echo "<li class='versao'>{$row->VERSAO_PROGRAMA} </li> ";
echo "<li class='data'>{$row->DATA_INSERCAO} </li> ";
echo "<li class='descricao'><p>{$row->DESCRICAO_ALTERACAO} </p> </li> ";
}
?>
does Where in program code 3, or puts a date field does Where with the date
– Jefferson Mello Olynyki
To limit the registration number, use
LIMIT X
, whereX
is the desired amount. The rest depends on your condition of most recent. If it is the last inserted, you must sort downwards byid
usingORDER BY id DESC
; if it is the last modified record, you need to store the modification date in a column (typeupdated_at
) and makeORDER BY updated_at DESC
.– Woss
@Andersoncarloswoss Your comment is an answer to this question.
– Ismael
@Ismael, it is possible, I did not understand if this is exactly the problem of the author. And it still depends on the information about what the codition is to define the most recent record. Once the author specifies this, it will be possible to reply completely.
– Woss
This "display only 3": you want it to display only 3 results or it shows only the third program?
– Victor Eyer
In the following case. I have several results, think the following I HAVE 1 CAR GRAY COLOR AND CAR RED COLOR BLZ ? , In the Gray car I have a door version, 1.2 and the 3 , And in the red car I also have the version 1.2 and the 3, BLZ ?. I enter the panel and stand, VERSION 1 , 2, AND THE 3 of the gray car. And the same day I stand to Versao 1, 2 and 3 of the red car. Instead of getting all versions posted I want to appear only THE FINAL VERSIONS IE RED CAR -> 3 , GRAY CAR -> 3, instead of appearing all.
– José Júnior
The question applies to the right Firebird? or is mysql itself?
– rray
Only to the Firebird
– José Júnior