Hi All,
I've stumped myself here.  In a nutshell, I have a function that returns my
array based on a SQL query and here's the code:

-------------begin code-------------------
function getCourses($UID)
 global $link;
 $result = mysql_query( "SELECT C.CourseName FROM tblcourses C, tblusers U,
tblEnrollment E WHERE C.ID = E.CourseID AND E.UserID = U.ID AND U.ID =
$UID", $link );
 if ( ! $result )
  die ( "getRow fatal error: ".mysql_error() );
 return mysql_fetch_array( $result );
------------end code ----------------

I call this from a PHP page with the following code:

------------begin code--------------
$myCourses = getCourses($session[id]);
foreach ($myCourses as $value)
 print "<br>$value";
------------end code---------------

Now, when I test the SQL from my function directly on the database, it
returns just want I want it to return but it isn't working that way on my
PHP page. For results where there is a single entry, I am getting the same
entry TWICE and for records with more than a single entry I am getting ONLY
the FIRST entry TWICE.

Now I know my SQL code is correct (I am testing it against a MySQL database
using MySQL-Front) so I suspect I'm doing something stupid in my foreach

I'm hoping someone will spot my dumb mistake.  Thanks very much for any help
at all on this.


PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to