Hi Everyone,
Can somebody help me out in this problem.

I am getting a value from 1 page to another through $_GET[].
When I redirect to other page it shows me its value in URL as well as in a query where I am using it further as this. Here assigncow is the value I am getting from previous page



update `docinfo` set `assigncow`='389' where `docid`='2' and `city`='a'

But When I click on some other city option, assigncow becomes blank
What to do for it..
Here is the code

$getcowid = $_GET['mid'];
echo $getcowid;

$query1 = "SELECT DISTINCT `city` FROM `docinfo`";
echo $query;
$result = mysql_query ($query1);

echo "<form name='input' method='post'>";

	echo "<table border='1' align='center'>";
	echo "<tr>";
	echo "<td><b>Locations of the available Doctors </b>";
	echo "<tr>";
	while($row = mysql_fetch_array($result))
			echo "<td><a href='docassign.php?cow={$getcowid}&amp;cit={$row['city']}'>".$row['city']."</td>";
			echo "<tr>";
	$getcity = $_GET['cit'];
	//echo $getcity;
	$gc = $_GET['cow'];
	echo $gc;
	$slctdoc = "select `docid`, `doctor`, `hospital`, `expert`, `phone` from `docinfo` where `city` = '$getcity'";
	//echo $slctdoc;
	$rundoc = mysql_query($slctdoc);
	echo "<table border='1' cellspacing='10' cellpadding='10' align='center'>";
	echo "<tr>";
	echo "<td><b>Doctor </b></td>";
	echo "<td><b>Hospital</b></td>";
	echo "<td><b>Expert</b></td>";
	echo "<td><b>Contact No.</b></td>";
	echo "<tr>";
	echo "<td>".$row['doctor']."</td>";
	//$var = $row['docid'];
	//echo $var;
	echo "<td>".$row['hospital']."</td>";
	echo "<td>".$row['expert']."</td>";
	echo "<td>".$row['phone']."</td>";
	echo "<td><input type='checkbox' value='".$row['docid']."' name='asgn[]'>Assign</td>";
	echo "<td><input type='submit' name='submit' value='Submit'></td>";
	echo "<tr>";
//$ass = $_POST['asgn'];
//echo $ass;
//$selectdoc = "SELECT `docid` FROM `docinfo` where"*/

      foreach ($_REQUEST['asgn'] as $checkbox)
   		$var = $checkbox;
	  	//echo $var;

//echo $as;

$slctassign = "update `docinfo` set `assigncow`='$gc' where `docid`='$var' and `city`='$getcity'";
echo $slctassign;

Recommended Answers

All 2 Replies

Hi Nsam,

I think that you are expecting different results for the input you put in the hyperlink. Check this part: echo "<td><a href='docassign.php?cow={$getcowid}&amp;cit={$row['city']}'>".$row['city']."</td>"; You're clearly setting the get variable 'cow' to $getcowid , but the value in $getcowid is actually $_GET['mid'] , instead of the one you want $_GET['cow'] .

Therefore, i'd suggest you change line 1 of your code from $getcowid = $_GET['mid']; to $getcowid = $_GET['cow'];

Hi please upload ur db with records

Be a part of the DaniWeb community

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