1
I have a big question about mysql_fetch_assoc in while. what happens is the following, I have a page where I do a database search and return to a while existing information with mysql_fetch_assoc, the problem is, when I want to do this while twice, it simply overrides, so I’m doing two database searches on the same page, only changing one situation because of the first mysql_fetch_assoc that overrides the second and so on. the code acts is this.
$buscar_conteudotag = mysql_query('SELECT msg_message FROM flq_message WHERE msg_private LIKE 0 ORDER BY msg_id DESC') or die (mysql_error());
while($quantidade_de_tag = mysql_fetch_assoc($buscar_conteudotag)) {}
$buscar_conteudoclosest = mysql_query("SELECT msg_message FROM flq_message WHERE msg_private LIKE 0 AND msg_message LIKE '%".$closest."%' OR '%".$closest."%' ORDER BY msg_id DESC") or die (mysql_error());
while($buscar_conteudolinhaclosest = mysql_fetch_assoc($buscar_conteudoclosest)){}
$buscar_conteudotag = mysql_query("SELECT msg_message FROM flq_message WHERE msg_private LIKE 0 AND msg_message LIKE '%".trim(substr($siteuri, 1))."%' OR '%".trim(substr($siteuri, 1))."%' ORDER BY msg_id DESC") or die (mysql_error());
while($quantidade_de_tag = mysql_fetch_assoc($buscar_conteudotag)) {}
What I’m looking for in this case is a way to perform only one SELECT for all three whiles. is there? if anyone can help me in this factor.
A tip: the functions
mysql_
are obsolete. Try using Mysqli.– Lucas
@Lucas understand, but I’m learning yet, I haven’t searched much on sqli, but it works on any linux server that runs slq normal?
– flourigh
According to the manual, you must have Mysql >= 4.1.13 and PHP >= 5.0.0
– Lucas