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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pass query data through link 1

Status
Not open for further replies.
Jan 28, 2003
18
US
Hello,
I am still learning PHP and am in need of help.
What I am trying to do is select a part number from a mssql database, return it to a table as a variable that is a hyperlink. When selected by the user that it would then be passed to another query that shows details.
I hope this is easy to understand.
I have included what I am currently doing.
Any and all help would be appreciated.


Code:
<HTML>
<HEAD>
<TITLE>Results Page</TITLE>
</HEAD>
<BODY>
<?php
//connect to a DSN "myDSN"
$conn = odbc_connect('database','userid','password');
if ($conn)
{
   $query = "select

                  item_no AS Item_Number,
                  item_desc_1 AS Description

                  FROM itemmaster_sql
                  WHERE user_def_fld_2 = '1'";

  $result=odbc_exec($conn, $query);
}
else echo "Hey goober, check your server connection.";
?>
<table bgcolor=#F0F8FF border=1  style=" font-family:arial;font-size:95%;color:black;">
<caption><B></B></caption>
<tr>
<th>Item Number</th>
<th>Description</th>
</tr>
<?php
while($row=odbc_fetch_array($result)){
echo "<tr> <td align=center>";
echo "<a href=combinedquery.php?post=?php echo $row ['Item_Number']>";
echo $row ['Item_Number'];
echo "<td align=left>";
echo "<a href=combinedquery.php?post=?php echo $row ['Item_Number']>";
echo $row ['Description'];
}
echo "</table>";
?>
</BODY>
</HTML>
 
Code:
while($row=odbc_fetch_array($result)){
echo <<<HTML
<tr> 
  <td align=center>
    <a href="combinedquery.php?post={$row ['Item_Number']}">{$row ['Item_Number']}</a>
  </td>
  <td align=left>";
    <a href="combinedquery.php?post={$row ['Item_Number']}">{$row ['Description']}</a>
  </td>
</tr>
HTML;
}
 
Wow, that was fast.
Thanks for the help, that was just what I was needing.

 
there is a superfluous "; inside the heredoc. i missed deleting it.
if you're not familiar with heredoc then there is a good section in the manual at php.net/heredoc
 
I saw that and removed it, no worries.
I will read up on the heredoc, again thanks for the help.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top