Hello,
I am having problems getting my script to do what I want it to !!
I think I have got the correct variables, but it seems not in the right order.
What I want is to return the results of the query ($result2) in a table, but have slightly different text boxes in the table for each of the different values of $list - where $list == 1, I want the information from the array plus the 'size' text box, where $list == 2, I want the information from the array plus the colour text box, and for $list == 3 to have all the array information plus size AND colour text boxes.
To test this scenario I have populated the table in the database with 4 records, 2 have the value 3 for List, one has 1 and one has 2, so in theory it should test all the options and show all the different layouts for the table........ HOWEVER !!!
When I run the following code it finds and return only one line, the record that has the List value of 1, but shows the message for the $list == 3 with both the size and colour information text boxes.
Where am I going wrong.????
<?php
session_start ();
?>
<html>
<head>
</head>
<body bgcolor="#FFFFFF" text="#000000">
<?php
require_once ('../connect.php');
include ('header.php');
$query = "SELECT SectionRef FROM tblUser WHERE CLogIn = '$username'";
$result = mysql_query($query)
or die ("no info");
$row = mysql_fetch_array($result);
$SectionRef = $row["SectionRef"];
$query = "SELECT List FROM tblMachine WHERE SectionRef = '$SectionRef'";
$result1 = mysql_query($query)
or die ("no such info");
$row1 = mysql_fetch_array($result1);
$List = $row1["List"];
$query = "SELECT `Model`, `SerialNo`, `CommonName` FROM `tblMachine` WHERE SectionRef = '$SectionRef' ";
$result2 = mysql_query($query)
or die ("could not find information");
if ($result2)
{
echo '<table align="centre" cellspacing="0" cellpadding="0">
<tr>
<td align="left"><b>Model</b></td>
<td align="left"><b>Serial Number</b></td>
<td align="left"><b>Location</b></td>
</tr>';
while ($row2 = mysql_fetch_array($result2,MYSQL_NUM))
{
if ("1" == $List)
{
$message =
"<form action=\"process.php\" method=\"post\">
<tr><font face=\"Arial, Helvetica, sans-serif\" >
<td width=\"70\" align=\"left\"> $row2[0]</td>
<td width=\"120\" align=\"left\"> $row2[1]</td>
<td width=\"200\" align=\"left\"> $row2[2]</td>
<td width=\"200\" align=\"left\"> $row2[3] <input type=\"text\" name=\"size\"> </td>
<td width=\"200\" align=\"left\"> $row2[4] </td><br>
</font></tr>\n";
}
elseif ("2" == $List)
{
$message =
"<form action=\"process.php\" method=\"post\">
<tr><font face=\"Arial, Helvetica, sans-serif\" >
<td width=\"70\" align=\"left\"> $row2[0]</td>
<td width=\"120\" align=\"left\"> $row2[1]</td>
<td width=\"200\" align=\"left\"> $row2[2]</td>
<td width=\"200\" align=\"left\"> $row2[3] </td>
<td width=\"200\" align=\"left\"> $row2[4] <input type=\"text\" name=\"colour\"></td><br>
</font></tr>\n";
}
elseif ("3" == $List)
{
$message =
"<form action=\"process_readings.php\" method=\"post\">
<tr> <font face=\"Arial, Helvetica, sans-serif\" >
<td width=\"70\" align=\"left\"> $row2[0]</td>
<td width=\"120\" align=\"left\"> $row2[1]</td>
<td width=\"200\" align=\"left\"> $row2[2]</td>
<td width=\"200\" align=\"left\"> $row2[3] <input type=\"text\" name=\"size\"> </td>
<td width=\"200\" align=\"left\"> $row2[4] <input type=\"text\" name=\"colour\"></td><br>
</font></tr>\n";
}
else
{
$message =
" no info ";
}
} // close while loop
} // close if
echo "$message";
echo '</table></font>';
echo "<br><p align=\"center\"><input type=\"submit\" name=\"submit\" value=\"Submit\">
</form>";
?>