Have an account? Sign in
Login  Register  Facebook
Multiple Action Buttons to Modify Database Contents
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\'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.
Started: September 17, 2011 Latest Activity: September 17, 2011 radio buttons multiple action php
2 Answers
That might work. Right now I\'m working on the functionality, later will come the task of making it pretty. The most frequently used option will be the Call one, for when a technician calls the customer and updates the notes for the system\'s status.

Posted: HurricaneD
In: September 17, 2011

what about make the three pages in one page?
some thing like
manage.php?work_order=[here the input]&action=[del||modify||call]
and then you can make the form will be like this
<form action="manage.php" method="get">
<input type="text" name="work_order" />
<select name="action" size="1">
	<option value="del">delete</option>
    <option value="modify">modify</option>
    <option value="call">call</option>
</select>

<input type="submit" value="Picked Up" />
</form>

Posted: MacOS
In: September 17, 2011

Your Answer

xDo you want to answer this question? Please login or create an account to post your answer