Page 1 of 1

[SOLVED] create a link and pass the variable

Posted: Sun Aug 14, 2005 6:47 am
by ianhull
Hi Guys, I have a db query which works fine and creates a hyperlink for the companyname in a html table.
After clicking this link it will goto nextpage.php but I would lik ethe value of the companyname variable to be passed to the next page. can anyone please tell me what I am doing wrong?

Thanks.

Code: Select all

<?php
include_once("connect.php");

$sql = "SELECT DISTINCT status, companyname, address, phone, fax, type, postcode from companies WHERE postcode='$_REQUEST[form1]' ORDER BY postcode";

$result = mysql_query($sql)
 or die ("Couldn't select $_REQUEST[form1]");

echo "

\n";

//-------------get each type ------

while ($line = mysql_fetch_array($result))    
      {
      extract($line);
      echo '<LINK REL=StyleSheet HREF="123.css" TYPE="text/css">
<table width="100%"  border="0" cellspacing="0" cellpadding="4">
  <tr>
    <th width="10%" height="23" scope="col"><div align="left"><span class="style2"></span></div></th>
    <th width="55%" valign="top" background="bb.jpg" scope="col"><div align="left" class="style3 style4 style7">      <a href="nextpage.php?companyname=$_POST[companyname]">      <span class="style10">' . $companyname . '</span></div></th>
    <th width="35%" scope="col"><div align="left" class="style8 style5"><strong>      </strong></div></th>
  </tr>
  <tr>
    <th height="66" scope="row"><div align="left"><span class="style2"></span></div></th>
    <th valign="top" bgcolor="#F5F5F5" scope="row"><div align="left" class="style4">' . $address . '</div></th>
    <th scope="row"><div align="left">      </div></th>
  </tr>
  <tr>
    <th scope="row"><div align="left"><span class="style2"></span></div></th>
    <th valign="top" scope="row"><div align="left"> </div></th>
    <th scope="row"><div align="left">      </div></th>
  </tr>
</table>';
      }
?>

Posted: Sun Aug 14, 2005 6:50 am
by ianhull
Thanks any7way guys but I have just figured it out.

Code: Select all

<?php
include_once("connect.php");

$sql = "SELECT DISTINCT status, companyname, address, phone, fax, type, postcode from companies WHERE postcode='$_REQUEST[form1]' ORDER BY postcode";

$result = mysql_query($sql)
 or die ("Couldn't select $_REQUEST[form1]");

echo "

\n";

//-------------get each type ------

while ($line = mysql_fetch_array($result))    
      {
      extract($line);
      echo '<LINK REL=StyleSheet HREF="123.css" TYPE="text/css">
<table width="100%"  border="0" cellspacing="0" cellpadding="4">
  <tr>
    <th width="10%" height="23" scope="col"><div align="left"><span class="style2"></span></div></th>
    <th width="55%" valign="top" background="bb.jpg" scope="col"><div align="left" class="style3 style4 style7">      <a href="nextpage.php?companyname=' . $companyname . '">      <span class="style10">' . $companyname . '</span></div></th>
    <th width="35%" scope="col"><div align="left" class="style8 style5"><strong>      </strong></div></th>
  </tr>
  <tr>
    <th height="66" scope="row"><div align="left"><span class="style2"></span></div></th>
    <th valign="top" bgcolor="#F5F5F5" scope="row"><div align="left" class="style4">' . $address . '</div></th>
    <th scope="row"><div align="left">      </div></th>
  </tr>
  <tr>
    <th scope="row"><div align="left"><span class="style2"></span></div></th>
    <th valign="top" scope="row"><div align="left"> </div></th>
    <th scope="row"><div align="left">      </div></th>
  </tr>
</table>';
      }
?>

follow up question

Posted: Mon Nov 21, 2005 12:03 am
by Kilgore Trout
how do I call the variable on the next page?