Jump to content

Strange behavior


play_

Recommended Posts

I have a while loop that displays entries from the database...and then i have an 'x' button to delete an individual entry:

 

code is as follows:

<?php
while($row = $sql->fetchArray()) {		
	echo "<form action='visitorinfo.php' method='post'>";

	echo "<tr>";
	echo '<td class="td_stat">' . $row['visitor_date'] . '</td>';
	echo '<td class="td_stat">' . $row['visitor_fname'] . '</td>';

	echo "<input type='hidden' value='$row[1]' name='todelete' />";
	echo "<td><input type='submit' name='del' value=' x ' /></td>";

	echo "</tr>";
	echo "</form>";

	if (isset($_POST['del'])) {
		// delete query here
	}
} // end while
?>

 

However, when i click the any of the 'x' buttons, nothing happens. page doesnt reload. it's as if the input type was just 'button' and not 'submit'.

 

BUT!, if i pull only one row from the database, it works, like so:

 

<?php
while($row = $sql->fetchArray()) {		
	echo "<form action='visitorinfo.php' method='post'>";

	echo "<tr>";
	echo '<td class="td_stat">' . $row['visitor_date'] . '</td>';  // ONLY RETRIEVING 1 NOW!

	echo "<input type='hidden' value='$row[1]' name='todelete' />";
	echo "<td><input type='submit' name='del' value=' x ' /></td>";

	echo "</tr>";
	echo "</form>";

	if (isset($_POST['del'])) {
		// delete query here
	}
} // end while
?>

 

 

 

so.... what the heck?

Link to comment
https://forums.phpfreaks.com/topic/86026-strange-behavior/
Share on other sites

Ok found the problem.

 

I had these right before echoing out the query results:

 

<table class="border" id="myTable">

<thead>
<tr>
    	<th colspan="15" class="table_header">User/Player Information</th>
    </tr>
<tr>
	<th class="td_header">Date</th>
	<th class="td_header">First Name</th>
	<th class="td_header">Last Name</th>
	<th class="td_header">School</a></th>
	<th class="td_header">Grad. year</th>
	<th class="td_header">Major</th>
	<th class="td_header">E-mail</th>
	<th class="td_header">Phone</th>
	<th class="td_header">Address</th>
	<th class="td_header">City</th>
	<th class="td_header">State</th>
	<th class="td_header">Zip</th>
	<th class="td_header">x</th>
</tr>
</thead>

<tbody>.....[query here]

 

if i take out <thead> and </thead> it works.

wtf?

 

 

Link to comment
https://forums.phpfreaks.com/topic/86026-strange-behavior/#findComment-439304
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.