I would like to pass variable value to another php file that runs a query. Query work perfectly alone, yet when I try to pass a form input I don't get the result I would like to. To make things more confusing, I'm using two separate php files in two different Joomla positions.
Here is the search form code:
Code: Select all
<html>
<head>
<script>
/*** Here is the form javascript code that builds a Calendar form
/*** Works perfectly
</script>
</head>
<body>
<form action="http://www.mysite.com/joomla/modules/mod_my_module/mod_my_module.php" method="post">
From:<script>DateInput('startdate', true, 'YYYY-MM-DD','2008-09-01')</script><br> /* This line calls a javascript function that builds the form. It will also create
/*a hidden field using the designated name (in this case, "startdate") containing
/*the selected date's value.
<input type="button" onClick="return this.form.startdate.value" value="Potvrdi">
</form>
</body>
</html>And here is the mod_my_module.php code:
Code: Select all
<?php
defined('_JEXEC') or die('Restricted access'); /* Joomla required line
mysql_connect('localhost','username','password');
mysql_select_db('my_database');
$sd = $_POST[this.form.startdate.value];
if(isset($sd)){
$query = "SELECT * FROM My_Table" WHERE Date > $sd;
$result = mysql_query($query) or die("Query ($query) failed!");
$fields = mysql_num_fields($result);
echo "<table border=1>\n<tr>";
for ($i=0; $i< mysql_num_fields($result); $i++)
{
print "<th style=color:red>".mysql_field_name($result,$i)."</th>";
}
echo "</tr>\n";
while ($row = mysql_fetch_row($result))
{
echo "<tr>";
for ($f=0; $f < $fields; $f++)
{
echo "<td style=white-space:nowrap; align=center>$row[$f]</td>";
}
echo "</tr>\n";}
echo "</table>";
}
?>