Answer the question
In order to leave comments, you need to log in
Why duplicate SQL queries?
$result= $db->query("SELECT id,xfields,title,alt_name FROM `post` WHERE `title` = '".$db->safesql($value['name'])."'");
if ($db->num_rows($result)) {
while ($row_actor = $db->get_row($result)) {
$id_actor = $row_actor['id'];
$xf_actor = $row_actor['xfields'];
$alt_name_actor = $row_actor['alt_name'];
}
}
The "Name" field is displayed - $row_actor['xfields']; and "Picture". $row_actor['alt_name'];
If there is news, then the id is displayed as needed - Title + picture, and if there is no news, the Title + picture from the previous news is duplicated
I use Dle engine. How can I make the title + image appear only when there is an entry in the database?
Answer the question
In order to leave comments, you need to log in
I didn’t use DLE, but here, it seems, there’s nothing difficult, just put a condition if there are more than 0 records
if ($db->num_rows($result) > 0)
{
while ($row_actor = $db->get_row($result))
{
$id_actor = $row_actor['id'];
$xf_actor = $row_actor['xfields'];
$alt_name_actor = $row_actor['alt_name'];
}
}
if ($rows = $db->get_row($result))
{
foreach($rows as $row_actor)
{
$id_actor = $row_actor['id'];
$xf_actor = $row_actor['xfields'];
$alt_name_actor = $row_actor['alt_name'];
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question