4
It is possible to vary the writing of the results, as an example below where I want to use.
<table width="1000" align="center">
<tr>
<td> NOTICIAS</td>
<td> </td>
<tr>
<td width="350"> <?php
$sql = "SELECT * FROM noticias WHERE categoria='noticias' ORDER BY idnoticia DESC LIMIT 1";
$stmt = DB::prepare($sql);
$stmt->execute();
$exibe = $stmt->fetchAll();
foreach ($exibe as $u) {
echo "<div style='float:left;width:99%;margin-right:10px;'><a style='color:#000;text-decoration:none;' href='{$u->categoria}.php?idnoticia={$u->idnoticia}'>";
echo "<div class='thumbnail'> <img src='img/{$u->idnoticia}/{$u->imagem}' class='img-responsive'>";
echo "<div class='limit'>{$u->titulo}";
echo "</div></div></a></div>";
?></td>
<td width="650"><?php
$sql = "SELECT * FROM noticias WHERE categoria='noticias' ORDER BY idnoticia DESC LIMIT 6 OFFSET 1";
$stmt = DB::prepare($sql);
$stmt->execute();
$exibe = $stmt->fetchAll();
foreach ($exibe as $u) {
echo "<div style='float:left;width:99%;margin-right:10px;'><a style='color:#000;text-decoration:none;' href='{$u->categoria}.php?idnoticia={$u->idnoticia}'>";
echo "<div class='thumbnail'> <img src='img/{$u->idnoticia}/{$u->imagem}' class='img-responsive'>";
echo "<div class='limit'>{$u->titulo}";
echo "</div></div></a></div>";
?></td>
</table>
I can enjoy the same select
used in the first <td>
to continue the result after 2° <td>
? How to write the first result, "pause" and rewrite the rest in another way?
Look, I can’t tell you if this is real, but as far as I know, it’s not a single user access that’s gonna make a difference, but when we’re on a server and multiple users access at the same time, there could be an increase in server machine usage, which is, by the logic I’m proposing here, the more connections, the less "performance", the less "better" connections, correct me if I’m wrong.
– Guilherme Nascimento
Because then, I also do not believe that it is the access of a single user that will make the difference, but I think exactly in this case of many accesses Imultaneos, up to how much can be harmful 2 queries, and in the case could be ( I think ) that used only one?
– Arsom Nolasco
In my view then the question would be to create a page cache structure when possible (besides doing a query only) and in a matter of optimizing php, you could use
fetch
instead offetchAll
and not use buffers in queries, example with Pdo$pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);
– Guilherme Nascimento