Page 1 of 1

Unable to pass variable...

Posted: Wed May 29, 2002 10:17 pm
by abionifade
Hi guys -

i have a drop down of which the module titles are populated from a table within mysql.

Problem that i am having is that when i choose the module title, and click on submit, the following table does not display anything, im assuming that the variable isnt being captured and sent..

Can anybody help with ideas or correction to my coding please?

firstly, here is the dropdown script (simpler sugegstions welcome :D )

Code: Select all

<form action="search_by_module.php" method="POST"> 
<select name="county"> 
<option value="">Choose module</option>
<?php include("dbconnect.php"); ?>
<? 

?> 
 
<? 
$query = mysql_query("select module_title from coursework_table"); 
while($rows=mysql_fetch_array($query)) &#123; 
print $rows&#1111;"module_title"]; 
?> 
<p><option value="<? echo $rows&#1111;"module_title"]?>"> <?echo $rows&#1111;"module_title"]?> </option> 
<? 
&#125; 
?> 
</select><option></select><p><input type=submit name=Submit value="Submit">&nbsp;&nbsp;   <input type=reset name=reset value="Clear">&nbsp;&nbsp;
</p>
here is the table which should display the results...

Code: Select all

<?php include("dbconnect.php"); ?>
<?
$result = mysql_query("select * from coursework_table where module_title='$module_title' ORDER by module_title");
if ($result){
 //echo ":<br><p></p>";
 echo "<table width=90% align=left border=0><tr bgcolor=#CCCCCC>
 <td align=left><b><font face='Verdana' size='1' color='#000080'>Coursework ID</font></b></td>
 <td align=left><b><font face='Verdana' size='1'>User ID</font></b></td>
 <td align=left><b><font face='Verdana' size='1' color='#000080'>Submission Time</font></b></td>
 <td align=left><b><font face='Verdana' size='1'>Module Title</font></b></td>
 <td align=left><b><font face='Verdana' size='1'>Description</font></b></td>
 <td align=left><b><font face='Verdana' size='1' color='#000080'>View</font></b></td>
 
 </tr>";
 while ($row = mysql_fetch_array($result)) {

 echo"
 <tr>
<td><font size='1' face='Verdana'>$row&#1111;coursework_id]</font></td>
 <td><font size='1' face='Verdana'>$row&#1111;user_id]</font></td>
 <td><font size='1' face='Verdana'>$row&#1111;submission_time]</font></td>
 <td><font size='1' face='Verdana'>$row&#1111;module_title]</font></td>
  <td><font size='1' face='Verdana'>$row&#1111;description]</font></td>
<td><font size='1' face='Verdana'><a href="../files/work/$row&#1111;filename]">View</a></font></td>
 </tr>";
  } echo "</table>";
  } else {
  echo "No data.";
  }
  mysql_free_result($result);

?>
I really appreciate your help in helping me solve this.

-Abi

Posted: Wed May 29, 2002 11:02 pm
by phice
I would tell you to replace the first file with the following code :

Code: Select all

<form action="search_by_module.php" method="POST"> 
<select name="county"> 
<option value="">Choose module</option> 
<?php include("dbconnect.php");
 
$query = mysql_query("select * from coursework_table"); 
while($rows=mysql_fetch_array($query)) &#123; 
print $rows&#1111;"module_title"]; 
?> 
<p><option value="<? echo $rows&#1111;"module_title"]?>"> <?echo $rows&#1111;"module_title"]?> </option> 
<? 
&#125; 
?> 
</select><p><input type=submit name=Submit value="Submit">     <input type=reset name=reset value="Clear">   
</p>

Posted: Wed May 29, 2002 11:34 pm
by abionifade
absolute genius.

it worked a treat.

Thank you so much.


-Abi