-2
i am making a query in the database to list my publications and the people I follow on my Timeline, the more the query just this bringing my publications.
<?php
$tipo_news = "SELECT * FROM $table_post WHERE usuario=$cod_login order by codigo desc";
$tipo_news_resultado = mysqli_query($mysqli, $tipo_news);
$tipo_news_quantidade = mysqli_num_rows($tipo_news_resultado);
$consulta_contatos = "SELECT * FROM $table_contatos WHERE usuario=$cod_login || amigo=$cod_login";
$resultado_contatos = mysqli_query($mysqli, $consulta_contatos);
$quantidade_contatos = mysqli_num_rows($resultado_contatos);
for($i=0;$i < $tipo_news_quantidade;$i++)
{
$vetor_news = mysqli_fetch_array($tipo_news_resultado);
?>
<?php print($vetor_news['nickname']); ?>
<?php print($vetor_news['post']); ?>
<?php
}
?>
hi, thanks for the help I tried to do this way and gave error, I will try to explain better the question, I am making a query in the database to list my publications and the people I follow on my Timeline, plus the consultation just this bringing my publications.
– Davyd Seal
It shows the error?
– Lindomar
Fatal error: Uncaught Typeerror: implode(): Argument #2 ($array) must be of type ? array, string Given in C: xampp htdocs social usuario.php:650 Stack trace: #0 C: xampp htdocs social usuario.php(650): implode(',', 'SELECT F...') #1 {main} thrown in C: xampp htdocs social usuario.php on line 650
– Davyd Seal
Turn $contacts_ids into array, $string_ids = implode(',', (array) $contacts_ids);
– Lindomar
check if contacts_ids is returning an object with contact id list if positive turns into array $string_ids = implode(',', (array) $contacts_ids)
– Lindomar
Calm down, I noticed that you ran over a few steps, you threw SQL straight into $contactos_ids, this is just a model to follow the logic
– Lindomar
need by SQL of $contacts_ids in mysqli_query() mysqli_query(contacts_ids)
– Lindomar
sorry I don’t know how to do it that way.
– Davyd Seal
I will improve the above answer
– Lindomar
I put more details in the answer try now.
– Lindomar
gave error no for. Parse error: syntax error, Unexpected token "for" in C: xampp htdocs social usuario.php on line 663
– Davyd Seal