[SOLVED] Extract Record
Moderator: General Moderators
[SOLVED] Extract Record
Let say i have 2 columns for class and student in my table. For example the records is stored in the table like this:
Class | Student
--------------------------------------
A John, Adam, Mike, Henry, Ralf
B Harry, Robert, Kevin, Alex
The column type of class is varchar, student is mediumtext. The problem is how can i list down all the student base on their class? I mean if i choose class A, it will list down all student name (John,...,Ralf) in 5 rows, not in a row. At this moment, i only can display all the name in 1 row. I don't know how to separate all the name. Can anybody help me pls?
Class | Student
--------------------------------------
A John, Adam, Mike, Henry, Ralf
B Harry, Robert, Kevin, Alex
The column type of class is varchar, student is mediumtext. The problem is how can i list down all the student base on their class? I mean if i choose class A, it will list down all student name (John,...,Ralf) in 5 rows, not in a row. At this moment, i only can display all the name in 1 row. I don't know how to separate all the name. Can anybody help me pls?
Last edited by S_henry on Wed May 18, 2005 2:21 am, edited 1 time in total.
- harrisonad
- Forum Contributor
- Posts: 288
- Joined: Fri Oct 15, 2004 4:58 am
- Location: Philippines
- Contact:
do this
and everytime you want to extract their names according to their classes:
Code: Select all
--------------------
Class | StudentName
--------------------
A | John
A | Adam
A | Mike
A | Henry
A | Ralf
B | Harry
B | Robert
B | Kevin
B | Alex
--------------------Code: Select all
// class A
$query = "select * from students where class='A'";
// class B
$query = "select * from students where class='B'";bit of a bummer that limit
I'm assuming you have 2 columns in your table one is class the other is student.
if the data in the student column is stored with ,(commas) between them then when you pull the data out you could always do and explode and get the students into an array or mutli dimensional array.
once in the array you should be able to do what ever you want with it.
I'm assuming you have 2 columns in your table one is class the other is student.
if the data in the student column is stored with ,(commas) between them then when you pull the data out you could always do and explode and get the students into an array or mutli dimensional array.
Code: Select all
$studentArr = explode("," , $row['student']);Actually i'm using MySql database. When i stored the date into the table, the table only can store the data until 1000 records. After that, i can't insert new record anymore. In my opinion, maybe this is the limit in MySql database. Am i right? So i'll try to do as phpScott suggest. I'll be back if still got any problem again. Thanx guys..
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
For me also it is very very small limit. But it does happen at my pc. So i've used phpScott's suggestion to solve the problem and it works.
Thanx guys. 
Code: Select all
$studentArr = explode("," , $row['student']);