HurricaneDigital Posted May 25, 2010 Share Posted May 25, 2010 All the add/remove/modify/display functions are now working for my little Customer Call Tracker web app thanks to the help of a few others on this site. Currently to manipulate the data after it has been entered I have 3 separate form fields to paste/type in a work order number which is then sent on to the del/modify/call scripts. What I would like to do is have radio buttons down the first column to select an entry and then have all the modifier buttons in one location. I managed to get the radio buttons to show up, but there would need to be some way to dynamically assign name/value to it so that it passes the proper data on to the following script. Here is the current code for the view page: <html> <title>Customer Call Tracker - Dashboard</title> <body> <br> <form> <input type="button" onclick="window.location.href='form.php'" value="Add Record"></input> </form> <form action="del.php" method="post"> <input type="text" name="work_order" /> <input type="submit" value="Picked Up" /> </form> <form action="modify.php" method="get"> <input type="text" name="work_order" /> <input type="submit" value="Modify" /> </form> <form action="call.php" method="get"> <input type="text" name="work_order" /> <input type="submit" value="Call" /> </form> </body> </html> <?php $username="xxxxxx"; $password="xxxxxx"; $database="xxxxxx"; $con=mysql_connect(localhost,$username,$password); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db($database, $con); $query="SELECT *, ((CURDATE() - date_last_called) > call_frequency) AS call_today FROM call_tracker ORDER BY call_today DESC, date_last_called ASC"; $result=mysql_query($query); $i = 0; $radio='<input type="radio" name="radio" />'; echo "<table border='1'>\n <tr>\n <th>Select</th>\n <th>Store</th>\n <th>Work Order</th>\n <th>Customer Name</th>\n <th>Contact Number</th>\n <th>Date Last Called</th>\n <th>Call Frequency</th>\n <th>Call Today</th>\n <th>Notes</th>\n </tr>\n"; while($row=mysql_fetch_array($result) or die(mysql_error())) { $style=((++$i % 2) == 0) ? 'style="background-color:#BFC8FF"' : 'style="background-color:#AAB2E2"'; $style=($row['call_today'] == 1) ? 'style="background-color:#007F0E;color:#FFFFFF"' : $style; $call=($row['call_today'] == 1) ? 'Yes' : 'No'; echo "<tr $style>\n" . "<td>" . $radio . "</td>\n" . "<td>" . $row['location'] . "</td>\n" . "<td>" . $row['work_order'] . "</td>\n" . "<td>" . $row['customer_name'] . "</td>\n" . "<td>" . $row['contact_number'] . "</td>\n" . "<td>" . $row['date_last_called'] . "</td>\n" . "<td>" . $row['call_frequency'] . "</td>\n" . "<td>" . $call . "</td>\n" . "<td>" . $row['notes'] . "</td>\n" . "</tr>\n"; } echo "</table>\n"; ?> I'm not sure how to add the <form> etc. so that you can use the three options from the set of radio buttons, but I'm thinking it would be along the lines of: $radio='<input type="radio" name="$somevariable" value="['work_order']"/>'; echo "<form><table border='1'>\n <tr>\n <th>Select</th>\n <th>Store</th>\n <th>Work Order</th>\n <th>Customer Name</th>\n <th>Contact Number</th>\n <th>Date Last Called</th>\n <th>Call Frequency</th>\n <th>Call Today</th>\n <th>Notes</th>\n </tr>\n"; while($row=mysql_fetch_array($result) or die(mysql_error())) { $style=((++$i % 2) == 0) ? 'style="background-color:#BFC8FF"' : 'style="background-color:#AAB2E2"'; $style=($row['call_today'] == 1) ? 'style="background-color:#007F0E;color:#FFFFFF"' : $style; $call=($row['call_today'] == 1) ? 'Yes' : 'No'; echo "<tr $style>\n" . "<td>" . $radio . "</td>\n" . "<td>" . $row['location'] . "</td>\n" . "<td>" . $row['work_order'] . "</td>\n" . "<td>" . $row['customer_name'] . "</td>\n" . "<td>" . $row['contact_number'] . "</td>\n" . "<td>" . $row['date_last_called'] . "</td>\n" . "<td>" . $row['call_frequency'] . "</td>\n" . "<td>" . $call . "</td>\n" . "<td>" . $row['notes'] . "</td>\n" . "</tr>\n"; } echo "</table>\n" "</form>\n"; ?> I've found a few similar solutions using JavaScript, but I want to see if it would possible to do it just with PHP to simplify things. Any help would be appreciated. Link to comment https://forums.phpfreaks.com/topic/202860-dynamic-radio-buttons-multiple-action-buttons-to-modify-database-contents/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.