SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Jan 2005
    Location
    Oxford
    Posts
    22
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Listing of Multiple Values

    I have spent a lot of time searching this forum and others for info and I am getting a bit more confident with php/mysql, but i'm still slow at getting results; this is on MySQL 4.1.
    I seem to be successful in displaying linked data for a single instance of a field when joining 'people', 'project' with a linking 'people-project' tables. I query thus:

    Code:
    $connect = db_connect();
    
    $query = "SELECT * 
      FROM people2 AS pe, people_proj AS pp, project AS pr
      WHERE pe.people_id = pp.ppeople_id
      AND pp.pproject_id = pr.project_id
      AND pe.people_id = '$id'";
    
    $result = mysql_query($query);
    if( !$result ){
      echo mysql_error() . ": " . mysql_errno();
    }
    $person = mysql_fetch_array($result);
    I can then draw a form for the 'person' that lists out fields nicely, and using the code below I can show the first instance of descriptive data fields from 'project' somewhere in the page:

    Code:
    if ($person["expired"] == "1") {
      	echo	"<font color='red'>This person is no longer working on any Projects.</font>";
      	} else	{
      	echo  "Participating in the following projects:<br><br>;
      	echo "<a href=" .$person[summary_link]. ">$person[proj_title]</a>";
    }
    However I want to print out all of the project info for the individual at the bottom of the page, and i am clearly getting syntax wrong for mapping out all the instances of the fields - I am trying something like this:
    Code:
    if ($person["expired"] == "1") {
      	echo	"<font color='red'>This person is no longer working on any Projects.</font>";
      	} else	{
      	echo  "Participating in the following projects:<br><br>";
      	$result=mysql_query($query);
      	while (list($summary_link,$proj_title) = mysql_fetch_row($result)) {
        echo "<a href=" .$summary_link. ">$proj_title</a><br>";
      	}
      }
    Right now I am getting a sequence, for person 'Jo Smith', of the right number of values, but the key values as in
    'SmithJ
    SmithJ
    SmithJ
    SmithJ'
    .....where he has four projects. Can anyone help me with this? thanks in advance for any assistance.
    Last edited by ndaisley; Feb 8, 2005 at 02:02.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,247
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    you might want to ask a moderator to move your question to the php forum
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •