1
In my code I did at the end of it so that the array did a logical and sequential sequence of my search but it is not working, someone can help me please ?
<?php
error_reporting (E_ALL & ~ E_NOTICE & ~ E_DEPRECATED);
//chama o arquivo de conexão com o banco
include("connect_db.php");
//consulta mysqli
$query = mysql_query("SELECT numero, orig, dest, eqpt, rota FROM voos ORDER BY RAND() LIMIT 5") or die(mysql_error());
//aqui ele gera looping e cria um array com os campos da consulta
while($array = mysql_fetch_array($query))
{
echo $array['numero'];
?><br />
Origem: <?php
echo $array['orig'];
?><br />
Destino: <?php
echo $array['dest'];
?><br />
Aeronave:
<?php
echo $array['eqpt'];
?><br />
Rota: <?php
echo $array['rota'];
?><br /><?php
}
?>
$orig = $array->dest;
}
$dest = $orig;
}
<?php
?>
$orig = $array->dest; } $dest = $orig; } .
– Joaquim Alberico
But that doesn’t make any sense... What you want to see as a result on your screen ?
– rbz
I’m listing some flights, at least it’s my idea, I’d like it to be like this: Flight Number: Origin: XXXX Destination: XXXX And the second listing would be .
– Joaquim Alberico
Jeez ! That’s not how you do so guy... You’re looking from the bank, with RAND still, it’s different from that !
– rbz
I answered from below.
– Joaquim Alberico
Sorry, I can’t see all this now... But basically it would be like this: 1 - Generates an entire array in a variable, instead of printing it while query 2 - With foreach, make the impression, but at source you pull the previous array of the 2nd result forward Obs: you will have to do an if because the 1st result will not pull the origin of the previous array
– rbz
Thank you very much Raoni but I do not know it yet, I continue studying ms is complicated.
– Joaquim Alberico
I posted working as you want... but there may be other ways... The way I did following a simpler example to understand each other...
– rbz
Raoni I put it to test but still it is not coming out in a logical sequence, it would be something in my query ? or SELECT ?
– Joaquim Alberico
You can see here the result: http://www.latamvirtual.net/core/cria_voo.php
– Joaquim Alberico
That’s right! ?
– rbz
If so, and you’re ok, don’t forget to mark as solved in the reply, so help the next !
– rbz
Raoni I’m only trying one thing, the second result is bringing the origin and destiny equal, how can I fix it please ?
– Joaquim Alberico
You copied the code and pasted ? If yes, there is no problem ! Only if the previous destination matches the next destination ! Then you would have to have another if, to skip the registration, since you would not have the flight.
– rbz
Even, you have empty record in your bank... delete it...
– rbz
I’ll take a look here and enter more records to see what happens.
– Joaquim Alberico
Raoni apologies again come here, was looking at the code and comes a few moments he copies the results for example: TAM3002 Origin: SBSP Destination: SBSP Aircraft: A320 Route: DCT SANBO UZ64 NEGUS DCT TAM3000 Origin: SBSP Destination: SBSP Aircraft: A319/ Route: DCT SANBO UZ64 NEGUS DCT Since in the Database these flights are different records.
– Joaquim Alberico
By the code I gave you there is no way ! I tested ! It pulls what is in each regosto, but replaces the origin from the 2nd display !
– rbz