Jump to content

PHP Table POST


smidgen11

Recommended Posts

Hi,

 

 

I have a sql query at the top that runs and echos the result to the page. Each row in the table has a radio but to select and then a submit button at the bottom of the table which should run the form's action which is another php script. Here is what I have for the table portion:

 

 

<form name="form1" method="post" action="undoentering.php">

<?php

echo "<table>";

echo "<thead>";

echo "<tr>";

echo "<td>Select</td>";

echo "<td>Location</td>";

echo "<td>First Name</td>";

echo "<td>Last Name</td>";

echo "<td>User Name</td>";

echo "<td>Extension</td>";

echo "<td>Mac</td>";

echo "<td>Type</td>";

echo "</tr>";

echo "</thead>";

?>

<?php

while($rows=mysql_fetch_array($result)){

?>

<?php

echo "<tr>";

?>

<td><input name="Selected" type="radio" id="radio[]" value="<? echo $rows['Mac']; ?>"></td>

 

<?php

echo "<td>";

echo $rows['Location'];

echo "</td>";

echo "<td>";

echo $rows['FirstName'];

echo "</td>";

echo "<td>";

echo $rows['LastName'];

echo "</td>";

echo "<td>";

echo $rows['UserName'];

echo "</td>";

echo "<td>";

echo $rows['Extension'];

echo "</td>";

echo "<td>";

echo $rows['Mac'];

echo "</td>";

echo "<td>";

echo $rows['Type'];

echo "</td></tr>";

?>

<?php

}

?>

<td colspan="8" align="center"><input name="delete" type="submit" id="delete" value="Undo"></td>

 

 

 

 

 

My issue is that nothing POSTs to the next page. When doing it like this the record show empty boxes yet the correct number of empty rows is output:

 

 

<table>

<form name="form1" method="post" action="undoexiting.php">

<thead>

<tr>

<td>Select</td>

<td>Location</td>

<td>First Name</td>

<td>Last Name</td>

<td>User Name</td>

<td>Extension</td>

<td>Mac</td>

<td>Type</td>

</tr>

</thead>

<?php

while($rows=mysql_fetch_array($result)){

?>

<tr>

<td><input name="Selected" type="radio" id="radio[]" value="<? echo $rows['Mac']; ?>"></td>

<td><? echo $rows['Location']; ?></td>

<td><? echo $rows['FirstName']; ?></td>

<td><? echo $rows['LastName']; ?></td>

<td><? echo $rows['UserName']; ?></td>

<td><? echo $rows['Extension']; ?></td>

<td><? echo $rows['Mac']; ?></td>

<td><? echo $rows['Type']; ?></td>

</tr>

<?php

}

?>

 

<tr>

<td colspan="8" align="center"><input name="Undo" type="submit" id="undo" value="Undo"></td>

</tr>

</html>

 

 

Can anyone lend some knowledge on what I may be doing wrong on the first script. And yes, I did and still am using google.

 

Thanks

 

 

Link to comment
Share on other sites

Hopefully this will make sense. So a number of records are queried and output into the table:

 
<?php
echo "<td>";
echo $rows['Location'];
echo "</td>";
echo "<td>";
echo $rows['FirstName'];
echo "</td>";
echo "<td>";
echo $rows['LastName'];
echo "</td>";
echo "<td>";
echo $rows['UserName'];
echo "</td>";
echo "<td>";
echo $rows['Extension'];
echo "</td>";
echo "<td>";
echo $rows['Mac'];
echo "</td>";
echo "<td>";
echo $rows['Type'];
echo "</td></tr>";
?>

 

From this table, each record has a radio button next to hit. When the radio button selects a row the Undo (submit button) is clicked and the "Mac" field of the selected record should post so that my next php file (undoentering.php) will be able to echo the value.

 

Undoentering.php:

 

$del_id = ( $_POST['Selected'] );
echo $del_id;

 

 

Link to comment
Share on other sites

finally...SOLVED.

 

all i had to do was add "php" to this line.

 

BEFORE

 

<td><input name="Selected" type="radio" id="radio[]" value="<? echo $rows['Mac']; ?>"></td>

 

AFTER

 

<td><input name="Selected" type="radio" id="radio[]" value="<?php echo $rows['Mac']; ?>"></td>

 

 

thanks guys

Link to comment
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.