Jump to content

Recommended Posts

<head>
<script language="javascript" type="text/javascript" src="datetimepicker.js">
</script>
</head>
<form action="main.php?id=test.php" method="post">
  <p>Start Date:
  <input name="start" id="start" type="text" size="10">
  <a href="javascript:NewCal('start','ddmmyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
    End Date: <input name="end" id="end" type="text" size="10">
  <a href="javascript:NewCal('end','ddmmyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
  <input name="submit" type="submit" value="Look Up">
</form>
<?php
if(isset($_POST['submit']))
{
$start = $_POST['start'];
$end = $_POST['end'];	
$sql = "SELECT * FROM `corps` WHERE `notedate` BETWEEN '$start' AND '$end'";

$results = mysql_query($sql) OR DIE(mysql_error());
$numrow = mysql_num_rows($results) ;
$i = 0;
While ($i < $numrow)
$shownotes = mysql_result($results,$i,'notes');
echo $shownotes."<br>";
{
Echo "Records found ".$i."<br>";
$i++;
}
}

 

The $start, and $end don't seem to be getting any values

Link to comment
https://forums.phpfreaks.com/topic/226854-variable-not-passing-from-form/
Share on other sites

Add the 3 indicated lines, and see what exactly is in the post array. If they aren't there, disable javascript in your browser, enter something in the text fields and try it again.

 

if(isset($_POST['submit']))
{

echo '<pre>'; // <----- ADD
print_r($_POST); // <----- ADD
echo '</pre>'; // <----- ADD

$start = $_POST['start'];
$end = $_POST['end'];
$sql = "SELECT * FROM `corps` WHERE `notedate` BETWEEN '$start' AND '$end'"

Array

(

    [start] => 1-2-2011

    [end] => 5-2-2011

    [submit] => Look Up

)

 

 

Fatal error: Maximum execution time of 30 seconds exceeded in /home5/ccccomma/public_html/test.php on line 29

 

Line 29 is: $shownotes = mysql_result($results,$i,'notes');

Ok got rid of the error but back to my first problem noting is showing up on the page

 

<head>
<script language="javascript" type="text/javascript" src="datetimepicker.js">
</script>
</head>
<form action="main.php?id=test.php" method="post">
  <p>Start Date:
  <input name="start" id="start" type="text" size="10">
  <a href="javascript:NewCal('start','ddmmyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
    End Date: <input name="end" id="end" type="text" size="10">
  <a href="javascript:NewCal('end','ddmmyyyy')"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a>
  <input name="submit" type="submit" value="Look Up">
</form>
<?php
if(isset($_POST['submit']))
{

echo '<pre>'; // <----- ADD
print_r($_POST); // <----- ADD
echo '</pre>'; // <----- ADD	

$start = $_POST['start'];
$end = $_POST['end'];	
$sql = "SELECT * FROM `corps` WHERE `notedate` BETWEEN '$start' AND '$end'";

$results = mysql_query($sql) OR DIE(mysql_error());
$numrow = mysql_num_rows($results) ;
$i = 0;
While ($i < $numrow)
{
$shownotes = mysql_result($results,$i,"notes");
echo $shownotes."<br>";

$i++;
}
}

?>

 

 

Ah, then you should change the format the date picker sends it over in the $_POST array. Change ddmmyyyy to yyyymmdd and that should do it, if it's the same date picker I've used in the past.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.