<?php require_once('includes/connection.php') ?>
<?php require_once('includes/functions.php') ?>
<?php include('includes/header.php') ?>
<?php include('includes/sidebar.php') ?>
<div id="contentnorightbar">		
<h2 id="Intro"><a href="#">Registered Partners</a></h2> 
<?php
	if(isset($_POST['firstname'])) {
	echo "form submitted";
[B]     // I Want the $edituser variable to be available here[/B]
      

}
?>
	<?php	
		include('includes/topnav.php');
		if ($result) {
			//If the Query succeed
			print "<br /><table class='partners' border='1' cellpadding='0' cellspacing='0' width='100%'>
					<tr>
					<th>User</th>
					<th>Name</th>
					<th>Company</th>
					<th>E-mail</th>
					<th>Mobile</th>
					<th>Edit</th>
					</tr>";
					$data_p = mysql_query("SELECT * FROM partner $max") or die(mysql_error());
					
			while($info = mysql_fetch_array($data_p)) {		
				if($i%2 == 0)
				{
				print "<tr bgcolor='#FFF'>";
				$i++;
				}
				else {
				print "<tr bgcolor='#EFF8FF'>";
				$i++;
				}
				
				// get the "edituser" and "pagenumber" 
				// this code will make the single row editable
				
				if(isset($_GET['edituser'])) {
					[B]$edituser = $_GET['edituser'];[/B]
					$pagenum = $_GET['pagenum'];

					//if($edituser == NULL) { redirect_to("partners_exp.php?pagenum={$pagenum}"); }
					if($edituser == ($info['username']))
					{						
				print "<form method=\"post\" action=\"partners_exp.php?pagenum={$pagenum}&edituser=\"{$edituser}>";
				print "<td>" . $info['username'] . "</td>";
				print "<td><input id=\"firstname\" type=\"text\" name=\"firstname\" value=" . $info['firstname'] . ">" . "<input id=\"lastname\" type=\"text\" name=\"lastname\" value=" . $info['lastname'] . "></td>";				
//				print "<td>" . ucfirst($info['firstname']) . " " . ucfirst($info['lastname']) .  "</td>";
				print "<td>" . $info['orgname'] . "</td>";
				print "<td>" . $info['email'] . "</td>";
				print "<td>" . $info['mobile'] . "</td>";
				//print "<td><input id='button' class='link' type='submit' name='submit' value='Update' /></td>";

				// CODE FOR SUBMIT BUTTON WITHOUT THE BUTTON
				print "<td><a href='#' onclick='document.forms[0].submit();'>Update</a></td>";
				print "</form>";					
				
				//$query = "UPDATE partner SET firstname='
					
					}else {					
				
				// REMEMBER
				// apart from the single editable row all the others are static
				
				print "<td>" . $info['username'] . "</td>";
//				print "<td>" . $info['firstname']. $info['lastname'] . " ></td>";
				print "<td>" . ucfirst($info['firstname']) . " " . ucfirst($info['lastname']) . "</td>";
				print "<td>" . $info['orgname'] . "</td>";
				print "<td>" . $info['email'] . "</td>";
				print "<td>" . $info['mobile'] . "</td>";
				print "<td><a href='partners_exp.php?pagenum={$pagenum}&edituser={$info['username']}'>Edit</a></td></tr>";	
					
				 } // if edituser ends here

				} else {
					
				// on partners.php page
				
				print "<td>" . $info['username'] . "</td>";
				print "<td>" . ucfirst($info['firstname']) . " " . ucfirst($info['lastname']) .  "</td>";
				print "<td>" . $info['orgname'] . "</td>";
				print "<td>" . $info['email'] . "</td>";
				print "<td>" . $info['mobile'] . "</td>";
//				print "<td><a href='partners_exp.php?edituser={$info['username']}'>Edit</a></td></tr>";
				print "<td><a href='partners_exp.php?pagenum={$pagenum}&edituser={$info['username']}'>Edit</a></td></tr>";					
				}
			}
			print "</table>";
			echo " <br /> ";			
			
		} else {
			//Display error message
			echo "<p>Query failed. </p>";
			echo mysql_error();
		}
?>
</div>	
<?php include('includes/footer.php'); ?>

Recommended Answers

All 2 Replies

well if your using forms you can use

<?PHP
$varname = $_GET['varnamefromotherpage'];
?>

or you can put it into a sessions

<?PHP
session_start();
$var = $_SESSION['somevar'];
?>

with session on the first you have to add session start to the top of the page and every page you are going to use it on but then you can just call the var without having to do much

put your get variable in input make it hidden when you post...get it.

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.