Page 1 of 1

Viewing database info from user input

Posted: Sat Oct 20, 2007 8:40 pm
by brancook
Hi all, I'm stuck and need some advice. What I'm trying to do is display some data in a table based on what a user chooses from a drop down menu. The choose the item from the drop down menu, click submit and the data form that item is displayed in the table. The problem seems to be with the $targetrma, when I click submit no data is pulled but if I insert a record that I know is already in the database into $targetrma, the data is displayed correctly. Any help would be appreciated. Thanks in advance. Here is my code:

***** IMPRESSIVE! ;) BUT YOU CAN PUT ALL THE CODE IN ONE BLOCK *****

Code: Select all

<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 = $_GET['rma'];
$sql = "SELECT rma.id, status.id, 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>
		
</tr>
	
	<?php
	}
} else {
	?>
	<tr><td>No Files!</td></tr>
	<?php
}
?>
</table>	
</div>

Thanks

Posted: Sun Oct 21, 2007 9:29 am
by brancook
I wasn't sure if I was getting a bit crazy with all of the tags.

Can anyone offer some advice?

Anyone, anyone

Posted: Mon Oct 22, 2007 12:02 pm
by brancook
Bueller..............Bueller...............