Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Submit Parameters

Status
Not open for further replies.

cogdev

MIS
Nov 30, 2001
85
US
Hi

I have a form that has a drop down menu with dates in it.

The form has a submit button.

I would like to submit the selection from the drop-down list and run a select against my database and dsiplay the results.

I when I clik submit , nothing happens..all I see is "error on page' on the task bar.

Help?

Here is my code:


First page conv.php
function submitFunction {
document.maniform.action ="Convhtml.php";
document.mainform.submit()
}
<form action="" method="get" name="mainform">
<table width="488" border="1">
<caption>
<span class="style1"> Select the Report Options </span>
</caption>
<tr>
<td width="233">Setect Start Date
<select name="Datesel" id="Datesel">
<option value="S" selected ="selected">SelStarate</option>
<?php
$db = mysql_connect("server","user","id")
or die("001 - Connection Failed");
mysql_select_db("iapr", $db);
$result = mysql_query("select distinct convocation_year from tbl_degree_cube_calendar_heads ", $db);

while ($myrow = mysql_fetch_array($result))
{
printf("<option>%s</option>\n",$myrow["convocation_year"]);
}
?>

<td><input type="button" name="Button" onClick="submitFunction()" value="Button"></td>
=========================================================
Convhtml.php

<TD><?php
{
$db = mysql_connect("server","user","id")
or die("001 - Connection Failed");
mysql_select_db("iapr", $db);
$result = mysql_query("select faculty from tbl_degree_cube_calendar_heads where
convocation_year = '$Datesel'", $db);
$loop_ind = ($myrow = mysql_fetch_array($result));

printf("<strong>Department: </strong> %s", $myrow["faculty"]);
}

?>
</TD>


 
You should have a semicolon after the last statement in your submit function.
Here's a tip to troubleshoot JavaScript errors:
Get yourself the Firefox browser. It has an integrated JavaScript console that gives you exact locations of errors in your JavaScript code. IE is really bad with that.

Also, you could just set the form action in the <form> tag with the action attribute and have a submit button <input type="submit"> to trigger the form.

Let's leave it with that for now.
 
I just noticed that when you call submitFunction(), it's not in PHP tags. I bet the browser doesn't recognize your function as being PHP, and parses it just like text. I'm not sure how you would include it to do what you want...I'll leave that to someone more knowledgable.
 
thid code is only returning one row of data..i know there are multiple rows...help???


<?php
{
$db = mysql_connect("server","user","id")
or die("001 - Connection Failed");
mysql_select_db("iapr", $db);
$result = mysql_query("select faculty from tbl_degree_cube_calendar_heads where
convocation_year = '$Datesel'", $db);
$loop_ind = ($myrow = mysql_fetch_array($result));

printf("<strong>Faculty: </strong> %s", $myrow["faculty"]);
}

?>
</TD>
 
TheJavaScript code needs also to be enclosed in <script> ... </script> tags or it will not work. It is JavaScript - PHP has no document.whatever type of object notation.

Loops in PHP do not 'write' themselves, you need to write them. mysql_fetch_array() is not aware of any number of rows in the result set.
Read the FAQ about data retrieval faq434-3850 especially step 4.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top