Submit button has to be pressed twice.

I have a page, that asks for start and end dates and a category, and then gives me a table.
It posts the var back to itself, but I have to click the button twice.

I don’t know if this complicates it, but I want to continue using that page with new dates.

I attached the entire code, but I’ll try to post the pertinent parts.
https://dl.dropboxusercontent.com/u/7834798/Attendance.php

[php]$dStartDate = $_POST[‘StartDate’];
$dEndDate = $_POST[‘EndDate’];
$group_id = $_POST[‘group_id’];
?>

		<tr>
			<td <?php echo "colspan=\"2\""; ?> align="center">
				<input type="submit" class="icButton" value="<?php echo gettext("Submit"); ?>" name="AttendanceSubmit">
			</td>
		</tr>		

<?php mysqli_multi_query($dbc, $query); if(isset($_POST['AttendanceSubmit'])){ // button name $query2 = mysql_query("SELECT pers_id , pers_name, pers_date, pers_date_attend_ind FROM pers_dates") or die(mysql_error()); while($row = mysql_fetch_array($query2)) $rows[] = $row; foreach($rows as $key => $value) { $array[$value['pers_id']]['name'] = $value['pers_name']; $array[$value['pers_id']]['dates'][$value['pers_date']] = $value['pers_date_attend_ind']; } //$rowColor = "brown"; function generate_table($array) { $html = ''; foreach($array as $key => $value) { $html .= ''; // start table inside the loop. It will looks better due to each member may have different number of date count. $html .= ''; $html .= ''; foreach($value['dates'] as $k => $v) { //Date of meeting $html .= ''; } $html .= ''; $html .= ''; //Person name $html .= ''; foreach($value['dates'] as $v) { //attendance indicator $html .= ''; } $html .= ''; $html .= '
 ' .' '. $k .' '. '
' . $value['name'] . '' . $v .' ' . '
'; } return $html; } echo generate_table($array); $clean="Drop TABLE temp_pers, temp_dates, pers_dates;"; mysqli_query($dbc,$clean); } require 'Include/Footer.php'; ?>[/php]

You are mixing Mysqli with old Mysql calls. Not going to work.

Thanks for pointing that out, I was working on updating to mysqli, but I guess it changed the structure of my array and then my html got messed up. Anyway I haven’t finished changing.

The page currently works, everything loads fine its just something about the posting and reposing variables.

That is very confusing, the page works (I’m assuming that the HTML displays properly?), but the posting and re-posting doesn’t work?

You also state that you only got half-way in changing over to mysqli, well that is like taking a tire off a car and not replacing it. Then you expect to drive the car without any problems. Doesn’t make sense to me. Sorry, if that sounds harsh.

Let me backup… The submit button has to be pressed TWICE, on the 2nd press it “works”.
By works I mean the values in the box post back to the page and the table loads.

As far as the tires, I prefer to think of it has having two new back tires instead of 4. :slight_smile: I’m not saying its right, but the sql is doing what I want. The pages does what I want EXCEPT I have to press ‘submit’ two times consecutively.

ps. I would love someone to show me how to fix the “mysql_fetch_array” to mysqli and still have the table generation work, but I know thats a while new can of worms.

If you turn on error reporting you will see that it actually doesn’t work.

Is error reporting different from the error log? I only get

[Wed Oct 08 12:58:14 2014] [error] [client 10.10.10.40] PHP Notice: Undefined index: StartDate in /var/www/churchinfo/Attendance.php on line 39
[Wed Oct 08 12:58:14 2014] [error] [client 10.10.10.40] PHP Notice: Undefined index: EndDate in /var/www/churchinfo/Attendance.php on line 40
[Wed Oct 08 12:58:14 2014] [error] [client 10.10.10.40] PHP Notice: Undefined index: group_id in /var/www/churchinfo/Attendance.php on line 41

I’m quite sure that the sql does work. If I manual drop the table. and run the page, On the first submit I get table does not exist on the second submit I get my data.

What I meant was that there are other problems. Your log post shows that. If there are ANY errors, to me, that means it doesn’t work.

I’m willing to live with those kind of error or at LEAST solve them later. Do you have any insight on the submit button issue?

SO there are no errors on my site now, but it still requires two submit presses.

I am short on time, so if you could add an attachment of ALL the files I need to run it locally, I will take a look at it. Dont forget the sql dump.

Sponsor our Newsletter | Privacy Policy | Terms of Service