Jump to content

Vidya_tr

Members
  • Posts

    48
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Vidya_tr's Achievements

Member

Member (2/5)

0

Reputation

  1. yes It worked after the space was removed.. thanks for the help...
  2. <?php I get the values of date by posting from another form $fromdate=date('Y-m-d',strtotime($_POST['year1']."-".$_POST['month1']."-".$_POST['day1'])); $fromtime=strftime('%H:%M:%S',strtotime($_POST['hrs1'].":".$_POST['min1'])); $from=$fromdate." ".$fromtime; $todate=date('Y-m-d',strtotime($_POST['year2']."-".$_POST['month2']."-".$_POST['day2'])); $totime=strftime('%H:%M:%S ',strtotime($_POST['hrs2'].":".$_POST['min2'])); $to=$todate." ".$totime; /*Suppose I get the posted value as $fromdate=2009-05-03 $fromtime= 09:00:00 Then I have $from= 2009-05-03 09:00:00 (same values in $toddate ,$totime)*/ //function call to check valid date and time checkDateTime($from,$to); function checkDateTime($fromdate,$todate) { if($todate<$fromdate) { echo "You entered a Wrong date/time.Please enter the Date/Time correctly"; exit;} if($todate==$fromdate) { echo "You entered a Wrong date/time.Please enter the Date/Time correctly"; exit;} } ?> (I am not retrieving the dates from database.sorry there was a mistake in what I told u before)
  3. my values are correct .. Even if I put the code like this.. <?php if($todate<=$fromdate) { echo "You entered a Wrong date/time.Please enter the Date/Time correctly"; exit;} ?> it checks the less than value and produces the message but not the equal to value... Can I check this in some other way???
  4. I have two dates in varaibles $fromdate and $todate my $todate should be always greater than $fromdate an if() condition checks for the valid dates...if they are the same an error message is produced. suppose i have the values.. $fromdate="2009-05-03 09:00:00" and $todate="2009-05-03 09:00:00" (the values are taken from database and are of type DateTime.) <?php if($todate==$fromdate) { echo "You entered a Wrong date/time.Please enter the Date/Time correctly"; exit;} ?> But here the error message is not produced.... Is there any problem in comparing the DateTime values????
  5. I had an array on the above code you posted:some error on the parameters of mysql_fetch_array: but got it like this.... <?php $query = "SELECT timediff('2009-04-30 14:40:00',sysdate()) as timedifference"; $queryResult = mysql_query($query); list($timedifference) = mysql_fetch_row($queryResult); ?> thanks.....
  6. SELECT timediff('2009-04-30 14:40:00',sysdate()); this when done using mysql console returns the difference in time. But how can I get the result of this query in a php variable?? Please help...
  7. what format can I use for strtotime if I want to convert a string "27-04-2009 10:55" to a date format??
  8. I have a form which posts two dates with time to another page. The date and time are taken as string using $_POST $fromdate=$_POST['day1']."-".$_POST['month1']."-".$_POST['year1']."".$_POST['hrs1'].":".$_POST['min1']."<br>"; echo "fromdate as string:".$fromdate."\n";//prints the posted vale $fromdate=date('Y-m-d H:i:s',strtotime($fromdate)); echo "fromdate:".$fromdate."\n";//prints the wrong value $todate=$_POST['day2']."-".$_POST['month2']."-".$_POST['year2']." ".$_POST['hrs2'].":".$_POST['min2']."<br>"; echo "todate as string:".$todate."\n"; $todate=date('Y-m-d H:i:s',strtotime($todate)); echo "todate:".$todate."\n"; I convert the string to date format using date('Y-m-d H:i:s',strtotime($fromdate)); But when I try to print the converted string it prints only the date and not the time i.e for example if I have a string value as "27-04-2009 10:55" in $fromdate, date('Y-m-d H:i:s',strtotime($fromdate)); gives me the value 1970-01-01 00:00:00 ,but not the correct value. what is the error in printing the date? How can I correct it? Please help me.....
  9. I have a set of radio buttons created dynamically... echo ' <input name="choice'.$questions['question_number'].'[]" type="radio" value="'.$answers['answer'].'" />'; one set of radio buttons for choosing the answers for first question, another set for second question and so on...(for a number of questions) each set of radio buttons are created with a unique name,'choice1[]', 'choice2[]' according ot its question number the checked values of the buttons are posted to another page submit.php when the submit button is pressed. How can I access the checked values of each set of radio buttons??? in submit.php? please help.....
  10. Yes.. finally I got it with this... for ($i = 0, $max = sizeof($_POST['choice']); $i < $max; $i++) { $option=$_POST['choice'][$i]; $grade=$_POST['select'][$i]; mysql_query("insert into assign_answers(assignID,question_number,answer,grade) values('$assignid','$qn_num','$option','$grade')"); } thank you for helping me...
  11. for ($i = 0, $max = sizeof($_POST['choice']); $i < $max; $i++) { $option=$_POST['choice'][$i]; echo $option; $grade=$_POST['select'][$i]; echo $grade; mysql_query("Insert into assign_answers(assignID,question_number,answer,grade) values('$assignid','$qn_num','$option','$grade')"); } It prints the values in the for loop.. but doesnt get inserted .....
  12. while(list($garbage1,$option)=each($_POST['choice'])) echo $option; while (list($garbage1,$option) = each($_POST['choice']) && list($garbage2,$grade) = each($_POST['select'])) { echo "OPTION:".$option."<br>";echo $grade; mysql_query("insert into assign_answers(assignID,question_number,answer,grade) values('$assignid','$qn_num','$option','$grade')"); } when I print the $option outside the while loop its shows the value of option. But at the same time inside the while with list() the value doesnt print.(both 'option' and 'grade' doesnt print) After commenting the the while loop for printing the values ,the grade gets printed in the while loop with list(),but OPTION doesnt print. the problem might be in using the while with list()... Can I use two list() conditions in a while? Please help me to solve this...
  13. using the loop like this... while (list($garbage1,$option) = each($_POST['choice']) && list($garbage2,$grade) = each($_POST['select'])) { mysql_query("insert into assign_answers(assignID,question_number,answer,grade) values('$assignid','$qn_num','$option','$grade')"); } nothing gets inserted in to the database....
  14. No..Its not working properly.. Now the answer is not inserted and grade value inserted is not correct value chosen in the list box
  15. I am developing a page for displaying a quiz. On the page for creating the questions i have the text fields for entering the choices for a question.the text fields are named as array 'choice[]'.Beside each textfield there is a list box for setting the grade for the choice.The list boxes are named as array 'select[]'. On submitting the page ,the choices and their corresponding grade are inserted to database .The values are taken using $_POST from the submitting page. The code for inserting is written as follows using while loop and list. while (list(,$option) = each($_POST['choice']) && list(,$grade) = each($_POST['select'])) { mysql_query("insert into assign_answers(assignID,question_number,answer,grade) values('$assignid','$qn_num','$option','$grade')"); } But the answer field ,that is the $_POST['choice'] value is not getting inserted.other fields are inserted. I couldnt find what the problem is.Please help me to find where I went wrong in using the while loop and list....
×
×
  • 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.