i am having some problems using the get function. i aim using it in a href location. while the information is displayed in the url i am just having some problems extracting the required information. here is my code below

this is the code for my href location

echo"<tr><td>$row[0]</td><td>$row[1]</td><td><a href='myform.php?,mode=edit;coursecode=$row[0]'>edit</a></td</tr>";

this is the code where i need to use the value of the course code.

if ($_GET['mode'] == 'edit')
{	$c=$_GET['coursecode'];
	echo"$c";
	// editing an existing entity
	
	// check for value of id
	if (!$_GET['coursecode'])
	{
		echo "error: no coursecode specified, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";	
		exit;
	}
	
	
	if (!$_POST['submit'])
	{
		// first access to form
		
				// checking if the record is in the database 
		$query = "SELECT * FROM courses WHERE course_coode='$_GET[coursecode]'";	
		if (!$result=mysql_query($query))
			{
			echo '<p>nice</p>';
			echo "error: user with id {$_GET['coursecode']} does not exist, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue							 				</a>";	
			exit;	
			}
			else
			{
			echo 'good shit';	
				$row = mysql_fetch_assoc($result);
				extract($row);
				
				$_POST['coursecode']=$course_code;
				$_POST['coursename']=$course_name;
				$_POST['description']=$course_description;
			}
			
			print_form();
	}		
		// retrieve recored
		//$query = "SELECT * FROM courses WHERE course_coode =$_GET['coursecode']";
		
		//$result = ...;
		
		// if record does not exist
		/* if (... record not found ...)
		{
			echo "error: user with id {$_GET['id']} does not exist, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";	
			exit;
		}
		*/
		
		// put existing record into $_POST
		/* $_POST['name'] = $row[0];
		   $_POST['id'] = $row[1];
		*/
		//$_POST['name'] = "user";
		//$_POST['id'] = "1234";
	
	if ($_POST['submit'] == 'Save')
	{
		// user clicked save

		// validate submitted data
		$messages = validate_input();
		if (count($messages) > 0)
		{
			// invalid data, print form for resubmission
			print_form($messages);
		}
		else
		{
			// data was good, update entry
			
			/* code to save entry */
				
				
				$coursecode=$_POST['coursecode'];
				$coursename=$_POST['coursename'];
				$level=$_POST['level'];
				$optionnumber=$_POST['option_no'];
				$description=$_POST['description'];
				$comp=$_POST['comp'];
				$sem_no=$_POST['sem_no'];
				$credits=$_POST['credits'];


				$con = mysql_connect("$hostname","$username","$password");
				if (!$con)
				  {
				  die('Could not connect: ' . mysql_error());
				  }
				
				mysql_select_db("$database", $con);
				
				$sql="UPDATE courses SET course_name=$coursename,level_no=$level,option_no=$optionnumber,compulsory=$comp, 	 																												
				sem_no=$sem_no,course_description=$description,credits=$credits WHEREcourse_code=$coursecode ";	
				
				if (!mysql_query($sql,$con))
				  {
				  die('Error: ' . mysql_error());
				  }
				//quire_once('courses.php');
				//echo "1 record added";
				echo "user {$_POST['coursecode']} updated, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";
				mysql_close($con);
		}
	}
	else
	{
		// user clicked cancel (catch all)
		echo "operation cancelled, <a href=\"{$_SERVER['PHP_SELF']}\">click here to continue</a>";
		
	}
}

this is what is displayed in the url when the link is clicked

http://localhost/template/myform.php?,mode=edit;coursecode=ecng2009


can anyone offer any assistance in doing this.

You have a syntax issue ....

Try this and notice the changes I made:

echo"<tr><td>$row[0]</td><td>$row[1]</td><td><a href='myform.php?mode=edit&coursecode=$row[0]'>edit</a></td</tr>";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.