Forum Moderators: coopster
<div id='column2'>
<h1>View the Status of an RMA</h1>
<br />
<form action="<?php echo $_SERVER['PHP_SELF'];?>"
method="get" enctype="multipart/form-data">
<?php
print '<select name="rma">'."\n";
print '<option value="none">Select RMA number</option>'."\n";
$rma_number = mysql_query('SELECT * FROM rma');while ($rma = mysql_fetch_array($rma_number, MYSQL_ASSOC)){
print'<option value="'.$rma['id'].'"';
if($record_data['ref_rma_id']==$rma['id']) print " selected=\"selected\" ";
print '>'.$rma['rma_number']."</option>\n";
}
print '</select>'."<br />\n";
?>
<br />
<input type="submit" value="Submit" />
</form>
<?php
$targetrma = "RMA-test-one";
$sql = "SELECT rma.rma_number, status.status_name, filename, date, description FROM dropbox, rma, status WHERE dropbox.ref_status_id=status.id";
$filelist = @mysql_query($sql);
if (!$filelist) {
exit('Database error: ' . mysql_error());
}
?>
<br />
<br />
<p>The following files are stored in the database:</p>
<div align="center">
<table id="rmaview">
<tr>
<th>RMA Number</th>
<th>RMA Status</th>
<th>Filename</th>
<th>Date</th>
<th>Note</th>
<th>Unit Type</th>
</tr>
<?php
if (mysql_num_rows($filelist) > 0) {
while ($f = mysql_fetch_array($filelist)) {
?>
<tr>
<td>
<?php echo $f['rma_number'];?>
</td>
<td>
<?php echo $f['status_name'];?>
</td>
<td>
<a href="<?php echo $_SERVER['PHP_SELF'];?>?action=view&id=<?php echo $f['id'];?>"><?php echo $f['filename'];?></a>
</td>
<td>
<?php echo $f['date'];?>
</td>
<td>
<?php echo $f['description'];?>
</td>
<td>
<?php echo $f['category_name'];?>
</td>
</tr>
<?php
}
} else {
?>
<tr><td>No Files!</td></tr>
<?php
}
?>
</table>
</div>
$sql = "SELECT rma.rma_number, status.status_name, filename, date, description FROM dropbox, rma, status WHERE dropbox.ref_status_id=status.id AND rma.rma_number = '$targetrma'";
Now when I insert the record that I have currently inserted in the database which looks like this:
$targetrma = "RMA-test-one";
The table displays the record properly.
But what I need is $targetrma to display what the user selects from the drop down menu from the form. Which is listed in the original post.
$sql = "SELECT rma.rma_number, status.status_name, filename, date, description FROM dropbox, rma, status WHERE dropbox.ref_status_id=status.id AND dropbox.ref_rma_id=rma.id AND rma.rma_number = '$targetrma'";
But I still can't get that $targetrma to use what the user selects.
$sql = "SELECT rma.rma_number, status.status_name, filename, date, description FROM dropbox, rma, status WHERE dropbox.ref_status_id=status.id AND dropbox.ref_rma_id=rma.id AND rma.rma_number = '"mysql_real_escape_string($targetrma)."'";
$filelist = mysql_query($sql) or die(mysql_error());
$sql = "SELECT rma.rma_number, status.status_name, filename, date, description FROM dropbox, rma, status WHERE dropbox.ref_status_id=status.id AND dropbox.ref_rma_id=rma.id AND rma.rma_number = '".mysql_real_escape_string($targetrma)."'";
$sql = "SELECT rma.rma_number, status.status_name, filename, date, description FROM dropbox, rma, status WHERE dropbox.ref_status_id=status.id AND dropbox.ref_rma_id=rma.id AND rma.rma_number = '".mysql_real_escape_string([b]$_GET['rma'][/b])."'";
if($record_data['ref_rma_id']==$rma['id']) print " selected=\"selected\" ";
I don't have $record_data defined anywhere.
This is a merger of two different blocks of code and somehow slipped in. How can I modify the if statement within that option value? I don't think I need it.
<div id='column2'>
<h1>View the Status of an RMA</h1>
<br />
<form action="<?php echo $_SERVER['PHP_SELF'];?>"
method="GET" enctype="multipart/form-data">
<?php
echo'<select name="rma">';
$res=mysql_query("select * from rma");
if(mysql_num_rows($res)==0) echo "there is no data in table..";
else
for($i=0;$i<mysql_num_rows($res);$i++) {
$row=mysql_fetch_assoc($res);
echo"<option>$row[rma_number]</option>";
}
echo'</select>';
?>
<br />
<input type="submit" value="Submit" />
</form>
<?php
$targetrma = $_POST['rma'];
$sql = "SELECT rma.rma_number, status.status_name, filename, date, description FROM dropbox, rma, status WHERE dropbox.ref_status_id=status.id AND dropbox.ref_rma_id=rma.id AND rma.rma_number = '$targetrma'";
$filelist = @mysql_query($sql);
if (!$filelist) {
exit('Database error: ' . mysql_error());
}
?>
<br />
<br />
<p>The following files are stored in the database:</p>
<div align="center">
<table id="rmaview">
<tr>
<th>RMA Number</th>
<th>RMA Status</th>
<th>Filename</th>
<th>Date</th>
<th>Note</th>
<th>Unit Type</th>
</tr>
<?php
if (mysql_num_rows($filelist) > 0) {
while ($f = mysql_fetch_array($filelist)) {
?>
<tr>
<td>
<?php echo $f['rma_number'];?>
</td>
<td>
<?php echo $f['status_name'];?>
</td>
<td>
<a href="<?php echo $_SERVER['PHP_SELF'];?>?action=view&id=<?php echo $f['id'];?>"><?php echo $f['filename'];?></a>
</td>
<td>
<?php echo $f['date'];?>
</td>
<td>
<?php echo $f['description'];?>
</td>
<td>
<?php echo $f['category_name'];?>
</td>
</tr>
<?php
}
} else {
?>
<tr><td>No Files!</td></tr>
<?php
}
?>
</table>
</div>
</div><!-- close column2 -->
</div> <!-- close contentarea2 -->
</div>
<!-- close contentarea1 -->
</body>
</html>