Unable to pass variable...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
abionifade
Forum Commoner
Posts: 34
Joined: Thu Apr 18, 2002 5:32 pm

Unable to pass variable...

Post 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
User avatar
phice
Moderator
Posts: 1416
Joined: Sat Apr 20, 2002 3:14 pm
Location: Dallas, TX
Contact:

Post 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>
Image Image
User avatar
abionifade
Forum Commoner
Posts: 34
Joined: Thu Apr 18, 2002 5:32 pm

Post by abionifade »

absolute genius.

it worked a treat.

Thank you so much.


-Abi
Post Reply