Well, I know that each connection requires a bit of server memory (the exact amount I do not know), and I know that several connections may weigh my site, thinking that I'd like to know if it has the unified code:
$proximo = $pdo->query("SELECT * FROM postagens WHERE ID > ".$pid." AND ID_user = ".$cid." ORDER BY ID DESC")->fetchAll();
if(!$proximo){
print_r($pdo->errorInfo());
}
foreach ($proximo as $next){};
I use this code in a photo gallery, where I capture the current ID and create a link that redirects to the next post. It would be simple if I repeated the code again and changed the ">" for "<" and hence the name of the variables so I would build a link to the previous post. However, this would require two simultaneous connections to the DB, and these two connections, even if they are useful, also become useless since they only serve to create two simple links. Would you like to use a unique connection to create these two links? Or is the only way you can keep both connections?
Speaking about this same code I would like to know how to correct another "problem" I'm having with it, as I said, this code creates a link that advances in the ID of the posts, the "problem" that came up was expected), is that at the end of the ID that correspond to the ID_user, an error arises saying that the ID does not exist, and does not really exist. Would you then like to do some command where as soon as you get to the last ID corresponding to ID_user the ID 'zere' and return to the first ID, thus creating a kind of loop where you can continually advance?