Good day! Please help me combine several requests and display them in one Foreach.
Example:
$this->db->where('work !=','yes'); $rg1 = $this->db->get('works'); $r1 = $rg1->result(); $this->db->where('image','blank.jpg'); $rg2 = $this->db->get('photos'); $r2 = $rg2->result(); $html = ""; foreach($r1 as $rw){ $html .= "<li class='notifications'> <a href='".$rw->slug."'>".$rw->title." <br>Нет графика </a> </li>"; } foreach($r2 as $rp){ $html .= "<li class='notifications'> <a href='".$rp->link."'>".$rp->name." <br>Нет фото </a> </li>"; } In the example above, there are 2 requests, after 2 outputs (foreach). How can I make two (or more) queries to the database, and then merge them into one foreach, while taking into account that the information received and the output template can be different ($ rw-> title ** $ rp-> name, etc.)?
thank
select slug, 'Нет графика' text from table1 union select link slug, 'Нет картинки' text from table2Get a common array, sort and output - splash58