Jump to content

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

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.