OutThisLife wrote:
> I've only been doing MySQL for a few weeks and I've run into a little
> problem..
>
> I have a column named tags and a column named name. I'm trying to find
> the tags that are assigned to the name.
>
> I've set the tag column to LONGTEXT as it will be used to store a
> large list of words. I need to put the first 5 results into a
> variable, then the next 5, and so on.
>
> Code:
>
> $first = mysql_query("SELECT tags,name FROM table WHERE
> name='$username' LIMIT 5") or die(mysql_error());
>
> while($row = mysql_fetch_array($first)) {
> echo $row['tags'];
> }
>
>
>
> It doesn't get only the first 5 results, it prints everything out.
>
> What's wrong w/ the code? And, am I going in the wrong direction with
> this? Is there another way I should be using?
>
> If there's any confusion it's set up like so (examples):
>
> User
> Natthew
>
> Tags
> word another word and another word
>
> Thanks.
>
>
This will give the first 5 rows. If you have multiple values in the a
column, MySQL doesn't know or care - it's all one row.
Google on "database normalization". This is contrary to first normal
form (each value in a column must be atomic).
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================