Database loading

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
papacharlie
Forum Newbie
Posts: 4
Joined: Thu Feb 17, 2005 3:02 am

Database loading

Post by papacharlie »

I am having trouble trying to get basically the same set of codding to work twice, trying to load another table with an id while demonstrating a name.

This first bit of code works, but the second does not.


Can anyone see the problem?
Thanks

Paul

Code: Select all

<td>Result</td>
    <td><select name="result" >
	<?php
	$query1 = "SELECT name FROM result";
   $result1 = mysql_query($query1, $linkID);
     if(mysql_num_rows($result1)) {
       // we have at least one user, so show all users as options in select form
       while($row = mysql_fetch_row($result1))
       {
          print("<option value="$rowї0]">$rowї0]</option>");
       }
     } else {
       print("<option value="">No users created yet</option>");
     }
		 $query  = "SELECT abr FROM result where name='$result'";
      $result = mysql_query($query, $linkID);
?>

Code: Select all

<td>Course</td>
    <td><select name="coursename" >
<?php
	$query3 = "SELECT course_name FROM course";
   $result3 = mysql_query($query3, $linkID);
     if(mysql_num_rows($result3)) {
       // we have at least one user, so show all users as options in select form
       while($row = mysql_fetch_row($result3))
       {
          print("<option value="$rowї0]">$rowї0]</option>");
       }
     } else {
       print("<option value="">No course created yet</option>");
     }
	$query9 = "SELECT course_id FROM course where                                           course_name='$coursename'";
      $course_id = mysql_query($query9, $linkID);

?>

Code: Select all

$sql = "INSERT INTO subjects (unit_no, unit_name, abr, sem, year, uni_id, course_id ) VALUE ('$unit_no', '$unit_name', '$result', '$sem', '$year', '$uni_id', '$course_id')";

feyd | please use

Code: Select all

tags while the

Code: Select all

tags are down![/color]
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

general mysql debugging guidelines:
  • always have a validation check that can spill out mysql_error() if there is a problem.
Post Reply