Note that there are some explanatory texts on larger screens.

plurals
  1. POCombine two tables and echo out the result (PHP MYSQL)
    primarykey
    data
    text
    <p>I have two tables; 'client' and 'sys_notes' in the same DB. (<code>SELECT client.*, sys_notes.* FROM client LEFT JOIN sys_notes ON sys_notes.client_id = client.id ORDER BY create_date DESC</code>)</p> <p>I need to combine the two tables echo in the same <code>&lt;div&gt;content&lt;/div&gt;</code>, like this:</p> <p>echo all from client = first.name + last.name (e.g. Scott)<br> echo all from client = role<br> echo all from client = whatever else<br> echo all from sys_notes sent by Robert Scott = note1, note2, note3, note(etc.)...<br> echo all from client = whatever else<br> echo all from client = whatever else<br></p> <p>example output:</p> <hr> <pre><code>&lt;div class="content"&gt; </code></pre> <p>Robert Scott<br> <i>Supervisor</i><br> Robert works at the order office at the firm.<br> Robert´s notes:<br></p> <ul> <li>today: (Note from sys_notes table)</li> <li>yesterday: (Note from sys_notes table)</li> <li>19.oct 2013: (Note from sys_notes table)</li> </ul> <p>Robert´s Phone: 000 000 000<br> Robert´s E-mail: etc.<br> Other information about Robert: ............<br></p> <pre><code>&lt;/div&gt; </code></pre> <hr> <pre><code>&lt;div class="content"&gt; </code></pre> <p>Lisa Johansson<br> <i>Supervisor</i><br> Lisa works at the marketing dep.<br> Lisas´s notes:<br></p> <ul> <li>today: (Note from sys_notes table)</li> <li>12.may 2013: (Note from sys_notes table)</li> </ul> <p>Lisa´s Phone: 000 000 000<br> Lisa´s E-mail: etc.<br> Other information about Lisa: ............</p> <pre><code>&lt;/div&gt; </code></pre> <hr> <p><b>When i echo results today Robert is being "echoed" as many times he has notes,<br> with one note in each <code>&lt;div class="content"&gt;</code>. (In example over Robert has 3 notes &amp; 3 different Robert-div is echoed.)</p> <p>Please help.</b></p> <p>--- UPDATE ---</p> <pre><code>-- Table structure for table `sys_notes` CREATE TABLE IF NOT EXISTS `sys_notes` ( `note_id` int(11) NOT NULL AUTO_INCREMENT, `client_id` int(11) NOT NULL, `note_created` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, `owning_user` varchar(50) NOT NULL, `note` varchar(500) NOT NULL, PRIMARY KEY (`note_id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=12 ; -- Table structure for table `client` CREATE TABLE IF NOT EXISTS `client` ( `id` int(11) NOT NULL AUTO_INCREMENT, `create_date` datetime NOT NULL, `first_name` varchar(50) NOT NULL, `last_name` varchar(50) NOT NULL, `phone` varchar(20) NOT NULL, `email` varchar(50) NOT NULL, `issue` varchar(50) NOT NULL, `other` longtext NOT NULL, `owning_user` int(11) NOT NULL, `status` varchar(10) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 AUTO_INCREMENT=1081 ; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload