Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to stop row data repeating when data is printing
    text
    copied!<p>I have a table which consist of main stream and subjects. At leaset, for each main stream there are five subjects.</p> <p>I want to print the subject and Main stream , but I don't need to repeat the main stream.</p> <p>Can we handle this via mysql query? If yes, how to do it? </p> <p>Here is the table structure for the table</p> <pre><code>CREATE TABLE IF NOT EXISTS `wp_c_subject` ( `id` int(11) NOT NULL AUTO_INCREMENT, `mai_stream` varchar(40) DEFAULT NULL, `subject` varchar(50) DEFAULT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=122 ; foreach($stream as $value_str){ echo $value_str-&gt;mai_stream; echo '&lt;br&gt;'; foreach($employee_subjects as $key=&gt; $value){ if ($value_str-&gt;mai_stream==$value-&gt;mai_stream) echo 'I am in '.$value-&gt;mai_stream; echo '&lt;table&gt;&lt;tbody&gt;'; echo '&lt;tr&gt;&lt;td style="width:300px;"&gt;'.$value-&gt;subject.'&lt;/td&gt;'.'&lt;td style="width:200px;padding:5px;"&gt;'.$value-&gt;skill_level;'&lt;/td&gt;&lt;/tr&gt;'; echo '&lt;/table&gt;&lt;/tbody&gt;'; // echo '&lt;/br&gt;';echo '&lt;/br&gt;'; } } </code></pre> <p>following code always print main_stream.</p> <pre><code>//printing subject information and subject main stream $employee_subjects=$wpdb-&gt;get_results("SELECT wp_c_subject.subject, wp_c_subject.mai_stream ,wp_c_skilllist.skill_level FROM `wp_c_users` JOIN wp_c_skilllist ON wp_c_skilllist.user_id = wp_c_users.id JOIN wp_c_subject ON wp_c_subject.id = wp_c_skilllist.subject_id WHERE wp_c_users.first_name = 'abc' ORDER BY wp_c_subject.mai_stream DESC"); //retriving main strams for subjects $stream=$wpdb-&gt;get_results("SELECT wp_c_subject.mai_stream FROM `wp_c_users` JOIN wp_c_skilllist ON wp_c_skilllist.user_id = wp_c_users.id JOIN wp_c_subject ON wp_c_subject.id = wp_c_skilllist.subject_id WHERE wp_c_users.first_name = 'abc' ORDER BY wp_c_subject.mai_stream DESC"); </code></pre>
 

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