php - How to make a table print out the columns that are the same into one row? -


What I want to do is shown in the table. I only want to get the math subject and I want to order units from Unit 1 (UI) to the last available unit in the database; Then, within each unit, to show each unit homework related I tried to save it in an array with mysql_fetch_array but it stores the line including a unit I have all those units and only units I want them under their homework. My database is at the end of this post Hope you can help someone

  & Lt ;! DOCTYPE html public "- // W3C // DTD XHTML 1.0 Transitional // N" "http://www.w3.org/TR/xhtml1 /DTD/xhtml1-transitional.dtd"> & Lt; Html xmlns = "http://www.w3.org/1999/xhtml" & gt; & Lt; Top & gt; & Lt; Meta http-equiv = "content-type" content = "text / html; charset = UTF-8" /> & Lt; Title & gt; Document Sin Totillo & lt; / Title & gt; & Lt; / Head & gt; & Lt; Body & gt; & Lt; Form action = "" method = "post" name = "form1" id = "form1" & gt; & Lt; The width of the table = "200" range = "1" & gt; & Lt; TR & gt; & Lt; TD & gt; Subject: & lt; / TD & gt; & Lt; TD & gt; Mathematics & lt; / TD & gt; & Lt; TD & gt; & Nbsp; & Lt; / TD & gt; & Lt; TD & gt; & Nbsp; & Lt; / TD & gt; & Lt; TD & gt; & Nbsp; & Lt; / TD & gt; & Lt; TD & gt; & Nbsp; & Lt; / TD & gt; & Lt; TD & gt; & Nbsp; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; & Nbsp; & Lt; / TD & gt; & Lt; TD & gt; UI & lt; / TD & gt; & Lt; TD & gt; UI & lt; / TD & gt; & Lt; TD & gt; UII & lt; / TD & gt; & Lt; TD & gt; UIII & lt; / TD & gt; & Lt; TD & gt; UII & lt; / TD & gt; & Lt; TD & gt; ... & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; Td> Home work & lt; / Td> & Lt; Td> Math work 1 & lt; / Td> & Lt; Td> Math work 2 & lt; / Td> & Lt; Td> Math work 3 & lt; / Td> & Lt; Td> Math Work 4 & lt; / Td> & Lt; Td> Math Work 5 & lt; / Td> & Lt; TD & gt; ... & lt; / TD & gt; & Lt; / TR & gt; & Lt; TR & gt; & Lt; TD & gt; & Nbsp; & Lt; / TD & gt; & Lt; TD & gt; & Nbsp; & Lt; / TD & gt; & Lt; TD & gt; & Nbsp; & Lt; / TD & gt; & Lt; TD & gt; & Nbsp; & Lt; / TD & gt; & Lt; TD & gt; & Nbsp; & Lt; / TD & gt; & Lt; TD & gt; & Nbsp; & Lt; / TD & gt; & Lt; TD & gt; & Nbsp; & Lt; / TD & gt; & Lt; / TR & gt; & Lt; / Table & gt; & Lt; / Form & gt; & Lt; / Body & gt; & Lt; / Html & gt;   

I just about math and wants with homework his units that each unit is under their My database is:

  - phpMyAdmin SQL Dump - version 4.1.6 - http://www.phpmyadmin.net - Host: 127.0.0.1 - Generation time: July 25, 2014 05:52 AM - server version: 5.6.16 - PHP version: 5.5.9 SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO "; SET time_jon = "+00: 00"; / *! 40101 SET @OLD_CHARACTER_SET_CLIENT = @@ CHARACTER_SET_CLIENT * /; / *! 40101 SET @OLD_CHARACTER_SET_RESULTS = @@ CHARACTER_SET_RESULTS * /; / *! 40101 SET @OLD_COLLATION_CONNECTION = @@ COLLATION_CONNECTION * /; / *! 40101 SET name utf8 * / - - Database: `School '- - ---------------------------------- --- ------------------- - Table structure for table `class` - If the table does not exist then create the table (` id`int (11) zero not AUTO_INCREMENT, `subject` varchar (30) Impedance utf8_spanish_ci not nULL,` unit` varchar (5) utf8_spanish_ci nOT nULL, `homework` varchar (50) nULL juxtaposition not nULL not utf8_spanish_ci, primary key match,` dueDate` date ( `Id`)) engine = InnoDB default charge = UTF8 calllet = UTF8_spanish_a AUTO_INCREMENT = 11; - - Table `putting in data dumping -` class` to Class` (` Id`, `Subject`,` Unit`, `Homework`,` DueDate`) values ​​(1, 'mathematics', 'UI' Math Work 1 ',' 2014-04-04 '), (2,' Math ',' UI ',' Math Work 2 ',' 2014-05-12 '), (3)' Science ',' UI ' , 'Science Work 1', '2014-04-09'), (4, 'Home Economics', 'UII', 'Home Economics Work 1', '2014-04-16'), (5) , 'UII', 'Math Work3', '2014-05-12'), (6), 'Math', 'UII', 'Math Work4', '2014-05-21'), (7) Science 'UII', 'Science Work2', '2014-05-14'), (8) 'Physics',' UI ',' Physics Work1 ',' 2014-05-06 '), (9)' Mathematics ',' UiI ',' Math Work 5 ',' 2014-07-16 '), (10,' Math ',' Uiv ',' Meth Work 6 ',' 2014-07-14 '); / *! 40101 SET CHARACTER_SET_CLIENT = @ OLD_CHARACTER_SET_CLIENT * /; / *! 40101 SET CHARACTER_SET_RESULTS = @ OLD_CHARACTER_SET_RESULTS * /; / *! 40101 SET COLLATION_CONNECTION = @ OLD_COLLATION_CONNECTION * /;    

You can use $ query = mysql_query (where "class Select * subject = 'math'); is that if you like what you are searching for, but you need more help to echo the data, I will answer with more, the topic of mathematics will select everything from the class table with information .

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -