Jump to content


Photo

problem in PHP-MYSQL


  • Please log in to reply
2 replies to this topic

#1 hitesh_here

hitesh_here
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 30 March 2006 - 10:07 AM

Hello friends ,

I am develpoing a form to generate a report in a library about the books that are issued and within a particular time period

this is a bit of html code i m using
           <form action="issued_books.php" method="POST">
           <select name="year" id="year" >
           <option>1998</option>
           <option>1999</option>
           <option>2000</option>
           <option>2001</option>
           <option>2002</option>
           <option>2003</option>
           <option>2004</option>
           <option>2005</option>
           <option>2006</option>
           <option>2007</option>
           </select>
           <input type="text" name="month" size=2 maxlength="2" />
           <input type="text" name="day" size=2 maxlength="2" />
   
           <input type="submit" value="submit" name="submit" />
           </form>
in PHP handler there is a code
<?php
      $year = $_POST['year'];
      echo "$year";
      $month = $_POST['month'];
      echo "$month";
      $day = $_POST['day'];
      echo "$day";
?>

the output for the variable day which i am getting is
230 even when i have input the value 23

I am using EasyPHP in Windows XP

second problem is how to use this date information to compare with the date value in a mysql table.
Thanks for reading my problem and thanks in advance for the solutions.

EDIT BY OBER: PLEASE USE CODE TAGS WHEN POSTING CODE

#2 ober

ober
  • Staff Alumni
  • Advanced Member
  • 5,337 posts
  • LocationEast Coast, USA

Posted 30 March 2006 - 01:09 PM

Well, first of all, your code can be reduced:
<? php
      $year = $_POST['year'];
      echo "$year";
      $month = $_POST['month'];
      echo "$month";
      $day = $_POST['day'];
      echo "$day";
?>

Can be:
<? php
      extract($_POST);
      echo "$year<br/>";
      echo "$month<br/>";
      echo "$day<br/>";
?>

Secondly, are you absolutely sure that's what the output is? The way you echoed your variables, they would have ended up right beside each other. With the breaks in there, it should print out each on it's own line. Also, if you're just echoing the variable with no other HTML, you don't need the double quotes around it.

Info: PHP Manual


#3 hitesh_here

hitesh_here
  • New Members
  • Pip
  • Newbie
  • 2 posts

Posted 30 March 2006 - 04:44 PM

Thank you sir for your support,
I really learned a lot from ur post,
bye n take care.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users