The goal of the the code below is to list all of the machid and cnames for a specific clientid. The clientid is pulled from a drop-down list on a previous form. What is actually happening is the clientid in the list link is incorrect while the machid is correct.
What am I doing wrong?
<?php
// includes
include("includes/config.php");
include("includes/functions.php");
// open database connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");
// select database
mysql_select_db($db) or die ("Unable to select database!");
?>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table width="680" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="30" height="19"></td>
<td valign="top" width="650"> </td>
</tr>
<tr>
<td height="51"></td>
<td valign="top" align="left">
<p align="left"><font face="Arial, Helvetica, sans-serif" size="3"><b><font color="#000000">Client
Name:
<?php
// generate and execute query
$get_clientname_sql = "SELECT clientname, clientid FROM client WHERE clientid = '$clientid'";
$get_clientname_result = mysql_query($get_clientname_sql) or die ("Error in query: $get_clientname_sql. " . mysql_error());
while ($row = mysql_fetch_array($get_clientname_result)) {
$clientname = $row['clientname'];
}
?>
<?php echo "$clientname"; ?>
</font></b></font>
<p align="left"><font size="2" color="#000000"><b><font size="3" face="Arial, Helvetica, sans-serif">Computers:<br></font></b></font>
<p>
<?php
// generate and execute query
$list_computername_sql = "SELECT cname,machid FROM inventory WHERE clientid='$clientid'";
$list_computername_result = mysql_query($list_computername_sql) or die ("Error in query: $list_computername_sql. " .
mysql_error());
// if records present
if (mysql_num_rows($list_computername_result) > 0)
{
// iterate through resultset
// print title with links to edit and delete scripts
while ($list = mysql_fetch_array($list_computername_result)) {
echo "<li><a href=\"displaysystem.php?clientid=".$list["$clientid"]."&machid=".$list["machid"]."\">".$list["cname"]." </a><br><br></li>";
?>
<?php
}
}
// if no records present
// display message
else
{
?>
<p><font face="Arial, Helvetica, sans-serif" size="3" color="#000000">No computers for this client are currently available.</font>
<?php
}
// close connection
mysql_close($connection);
?>
</td>
</tr>
</table>
</body>