SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Enthusiast Yonko's Avatar
    Join Date
    Jun 2001
    Location
    Panama
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    PLEASE, Multiple results display HELP

    I've set a form getting user info, I get the usual (name, last name, email, and that sort of things) and I've put some checkboxes to get the users interests too. The system is doing fine, the problem I run to when displaying the results, is with the interests part of the info. A user can have multiple interests, but I can't let the interests show in more than one row because it would copy the rest of the info also. Is there any way I can display the interests separated by commas. I've used a join table that handles the multiple choices (using userid and interestid) but can't make it communicate right with the table containing the interests names.

    Thanks, anyone willing to help but not clear enough, let me know.

  2. #2
    SitePoint Evangelist =X='s Avatar
    Join Date
    Jun 2001
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you might wanna give a url where we can see the problem?
    PHP-Webservices - Profesional Hosting and Programming of sites.

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2001
    Location
    NJ
    Posts
    68
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think the best way to do that is to use a join table---what wasnt communicating right?
    signature

  4. #4
    Mlle. Ledoyen silver trophy seanf's Avatar
    Join Date
    Jan 2001
    Location
    UK
    Posts
    7,168
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Post the code you are using and the database design please

    Sean
    Harry Potter

    -- You lived inside my world so softly
    -- Protected only by the kindness of your nature

  5. #5
    SitePoint Enthusiast Yonko's Avatar
    Join Date
    Jun 2001
    Location
    Panama
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Here it is...

    PHP Code:
    $dbcnx = @mysql_connect(
             
    "localhost""root""password");
    mysql_select_db("database");

    // The basic SELECT statement
    $select "SELECT DISTINCT Usuarios.ID, Usuarios.Nombre AS Nombre, Usuarios.Apellido AS Apellido, Edad.Edad AS Edad, Sexo.Sexo AS Sexo, Estado_Civil.Estado AS Estado, Usuarios.Tel AS Tel, Nivel_Estudios.Nivel As Nivel, Usuarios.Residencia AS Residencia, Usuarios.Email AS Email, User_int.UID As UID, User_int.IID AS intid, Intereses.Interes AS Interes ";
    $from   " FROM Usuarios, Edad, Estado_Civil, Sexo, Nivel_Estudios, User_int, Intereses";
    $where " WHERE Estado_Civil.ID=Usuarios.EstadoID AND Nivel_Estudios.ID=Usuarios.NivelID AND Sexo.ID=Usuarios.SexID AND Edad.ID=Usuarios.EdadID AND User_int.IID=Intereses.ID AND UID=Usuarios.ID"
    <TABLE BORDER=1 bgcolor="#FFFFFF" bordercolor="#3366cc">
    PHP Code:
    $users mysql_query($select $from $where);
    if (!
    $users) {
      echo(
    "</TABLE>");
      echo(
    "<P>Error al recuperar informacin de usuarios<BR>" .
           
    "Error: " mysql_error());
      exit();
    }

    while (
    $user mysql_fetch_array($users)) {
      
    $id           $user["ID"];
      
    $nombre    $user["Nombre"];
      
    $apellido    $user["Apellido"];
      
    $email       $user["Email"];
      
    $tel           $user["Tel"];
      
    $residencia $user["Residencia"];
      
    $sexo        $user["Sexo"];
      
    $edad       $user["Edad"];
      
    $estado     $user["Estado"];
      
    $nivel        $user["Nivel"];
      
    $interes     $user["Interes"];
        
      echo(
    "<TR bgcolor=\"#FFFFCC\">\n");
        echo(
    "<TD><font face=\"Arial, Helvetica, sans-serif\" size=\"-1\" color=\"#000000\">$nombre $apellido</font></TD>\n");
      echo(
    "<TD><font face=\"Arial, Helvetica, sans-serif\" size=\"-1\" color=\"#000000\">$sexo</font></TD>\n");
      echo(
    "<TD><font face=\"Arial, Helvetica, sans-serif\" size=\"-1\" color=\"#000000\">$edad</font></TD>\n");
        echo(
    "<TD><font face=\"Arial, Helvetica, sans-serif\" size=\"-1\" color=\"#000000\">$estado</font></TD>\n");
        echo(
    "<TD><font face=\"Arial, Helvetica, sans-serif\" size=\"-1\" color=\"#000000\">$residencia</font></TD>\n");
        echo(
    "<TD><font face=\"Arial, Helvetica, sans-serif\" size=\"-1\" color=\"#000000\">$tel</font></TD>\n");
        echo(
    "<TD><font face=\"Arial, Helvetica, sans-serif\" size=\"-1\" color=\"#000000\">$email</font></TD>\n");
        echo(
    "<TD><font face=\"Arial, Helvetica, sans-serif\" size=\"-1\" color=\"#000000\">$nivel</font></TD>\n");
        echo(
    "<TD><font face=\"Arial, Helvetica, sans-serif\" size=\"-1\" color=\"#000000\">$interes</font></TD>\n");
        echo(
    "</TR>\n");

    </TABLE>

    I want the table to display only one result per user, but I need it to display the interests separated by commas in the same cell, is that possible?
    Last edited by Yonko; Aug 22, 2001 at 15:03.

  6. #6
    SitePoint Enthusiast Yonko's Avatar
    Join Date
    Jun 2001
    Location
    Panama
    Posts
    79
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Could you please help me?

    I really need your help people, if it wasn't clear enough please tell, I can rephrase

  7. #7
    SitePoint Evangelist =X='s Avatar
    Join Date
    Jun 2001
    Posts
    487
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you should really give the url...don't really understand your problem
    PHP-Webservices - Profesional Hosting and Programming of sites.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •