Note that there are some explanatory texts on larger screens.

plurals
  1. POmysql_query results in a while loop X 2
    primarykey
    data
    text
    <p>I am completely stumped here, Thanks in advance for any solutions or pointers, I really do appreciate any help you can offer.</p> <p>I am trying to make a memo system. Showing memo's is no problem but I am trying to only show the unread memo's. I have 2 tables as you can see, one that has the memo's and the other that lists the read memo's. when a user has read the memo's he/she ticks the box and the memo id and the user id is added to the table 'memo_read'.</p> <p>So basically I am trying to retrieve the memo's that have been read from the 'memo_read' table and then display the results from the 'memo' table that haven't been read where the user_id and the company are correct. As you can see I have 2 variables from a function on another page and these are working fine '$user_id , $company_id',</p> <p>I am trying to display the unread memo's in a while loop displaying the desired variables. I have been working on this for ages and no joy, I have tried every approach i can think of but i'm sure you can tell i'm not the most experienced of guys and i'm sure am have missed some thing or have taken the completely wrong approach! </p> <pre><code>&lt;?php $user_id = $user_data['user_id'] ; $company_id = $user_data['company']; $result1 = mysql_query ("SELECT `user`, `memo_id` FROM`memo_read` WHERE `user`= '$user_id '") or die(mysql_error()); while($row = mysql_fetch_array($result1)){ $memo_id = $row['memo_id']; $result = mysql_query ("SELECT `id`, `link`, `author`, `time`, `title`, `company` FROM `memo` WHERE `worker`= 1 AND `company`= '$company_id' AND `id`!= '$memo_id'") or die(mysql_error()); while($row = mysql_fetch_array($result)) { $id = $row['id']; $link = $row['link']; $author = $row['author']; $time = $row['time']; $title = $row['title']; $company = $row['company']; ?&gt; &lt;ul&gt; &lt;li&gt;&lt;?php echo $title; ?&gt;&lt;/li&gt; &lt;li&gt;&lt;?php echo $author; ?&gt;&lt;/li&gt; &lt;li&gt;&lt;?php echo $company;?&gt;&lt;/li&gt; &lt;li&gt;&lt;?php echo $time;?&gt;&lt;/li&gt; &lt;a href="&lt;?php echo $link; ?&gt;"&gt; Read memo&lt;/a&gt; &lt;/ul&gt;&lt;br&gt; &lt;?php } } ?&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    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.
 

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