Page 1 of 1

[SOLVED] Extract Record

Posted: Mon May 09, 2005 9:52 pm
by S_henry
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?

Posted: Mon May 09, 2005 10:40 pm
by harrisonad
do this

Code: Select all

--------------------
Class | StudentName
--------------------
    A | John
    A | Adam
    A | Mike
    A | Henry
    A | Ralf 
    B | Harry
    B | Robert
    B | Kevin
    B | Alex 
--------------------
and everytime you want to extract their names according to their classes:

Code: Select all

// class A
$query = "select * from students where class='A'";
// class B
$query = "select * from students where class='B'";

Posted: Tue May 10, 2005 2:21 am
by S_henry
At first i also want to do like that. But it definitely can't because if i do like that, the records in the table will exceed the limit. The record that i can store inside the table shouldn't be more than 1000 records. So anybody got any idea to solve this problem pls?

Posted: Tue May 10, 2005 3:44 pm
by andre_c
S_henry wrote:At first i also want to do like that. But it definitely can't because if i do like that, the records in the table will exceed the limit. ...
why do you have that limit?
why less than 1000?
what database are you using?

Posted: Tue May 10, 2005 4:14 pm
by phpScott
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.

Code: Select all

$studentArr = explode("," , $row['student']);
once in the array you should be able to do what ever you want with it.

Posted: Tue May 10, 2005 9:25 pm
by S_henry
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..

Posted: Wed May 11, 2005 6:58 am
by John Cartwright
1000 is a very, very, very small limit if it does exist.
Are you sure you cannot post past 1000?

Posted: Tue May 17, 2005 10:29 pm
by S_henry
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.

Code: Select all

$studentArr = explode("," , $row['student']);
Thanx guys. :D