Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Passing a part of the result of an SQL query to another page ..

Status
Not open for further replies.

Bravogolf

Programmer
Nov 29, 2002
204
GB
... and then that part of a result as a separate query!

Hi all, over at it returns in the form of links the first name of everyone in the table.

I've attempted to make those links clickable so that when the first name is clicked, it is carried over to the next page, perparamterview.php and a query is ran on the first name.

How can I do that, it doesn't seem to work for me?
 
Insufficient data for a meaningful answer.

What data are you trying to send from the first page to the second script?
Why does that data not appear in the URLs your first script is writing to the first page?


Were I to do something like this, I would have the names in the first page be links that were of the form:

<a href="....myscript.php?id=123456">Fred</a>

where the id ("123456") is an ID of a record in the database.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Oh, my apologies :)

First, I run the "select all" statement on reglist.php:

Code:
	$query="SELECT * FROM testdb";
	$result=mysql_query($query);
	$colourcount=1;
	echo "<table class='ex' cellpadding='4' cellspacing='0'>\n";
	echo "<tr><td class='header'>Sales ID</td><td class='header'>First Name</td><td class='header'>Last Name</td><td class='header'>Contact No</td></tr>\n";
	while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) 
	{
	   if($colourcount==1)
	   {		
				echo "<tr class='tdex' onmouseover='HighlightBackground(this);' onmouseout='ResetBackgroundtdex(this);'>\n"; //onmouseover="HighlightBackground(this, '#ffeeee');"
				$colourcount=0; //onmouseover='this.className='tdexover'' onmouseout='this.className='tdex''
		}
		else
		{
				echo "<tr class='tdex1' onmouseover='HighlightBackground(this);' onmouseout='ResetBackgroundtdex1(this);'>\n";
				$colourcount=1;
		}
	   	
	   foreach ($line as $col_value) 
	   {
				echo "<td>$col_value</td>\n";
	   }
	   echo "</tr>\n";
	}
	echo "</table>\n";

Then at the bottom of that I have an if loop that displays each first name and makes it a link. Each name is assigned to $fcod.

Code:
	for ($i=0; $i<mysql_numrows($result); $i++)
	{	
	$fcod=mysql_result($result,$i,"Fname"); 	
	echo "<a href='perparameterview.php?cod=$fcod'>$fcod</a><br>";
	}

So, when I click on Darren, the perparameterview.php shows ...perparameterview.php?cod=Darren

So that means that value cod in the perparameterview.php pages contains Darren.

So now I run the same as before but instead of selecting all, I'm attempting to "SELECT * WHERE Fname=$cod" ..

Code:
	$query="SELECT * FROM testdb WHERE Fname=$cod";
	$result=mysql_query($query);
	$colourcount=1;
	echo "<table class='ex' cellpadding='4' cellspacing='0'>\n";
	echo "<tr><td class='header'>Sales ID</td><td class='header'>First Name</td><td class='header'>Last Name</td><td class='header'>Contact No</td></tr>\n";
	while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) 
	{
	   if($colourcount==1)
	   {		
				echo "<tr class='tdex' onmouseover='HighlightBackground(this);' onmouseout='ResetBackgroundtdex(this);'>\n"; //onmouseover="HighlightBackground(this, '#ffeeee');"
				$colourcount=0; //onmouseover='this.className='tdexover'' onmouseout='this.className='tdex''
		}
		else
		{
				echo "<tr class='tdex1' onmouseover='HighlightBackground(this);' onmouseout='ResetBackgroundtdex1(this);'>\n";
				$colourcount=1;
		}
	   	
	   foreach ($line as $col_value) 
	   {
				echo "<td>$col_value</td>\n";
	   }
	   echo "</tr>\n";
	}
	echo "</table>\n";

Any ideas?
 
$query="SELECT * FROM testdb WHERE Fname=$cod";

$query="SELECT * FROM testdb WHERE Fname='.$_GET[cod].'";

______________________________________________________________________
There's no present like the time, they say. - Henry's Cat.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top