neridaj Posted February 13, 2009 Share Posted February 13, 2009 Hello, Is there a way to send multiple vars via the querystring using form action without javascript? I have a form containing a table of users which I would like to add "Create" and "Update" buttons for each user to create and update invoice data. I would like to be able to click on the respective buttons to send the "create" or "update" value along with the username. function display_invoice_table($result) { // display the table of users // set global variable, so we can test later if this is on the page global $invoice_table; $invoice_table = true; // $action = create or update // $user = username ?> <br /> <?php echo "<form name='invoice_table' action='create_invoice.php?a=$action?u=$user' method='post'>"; echo '<table cellpadding="0" cellspacing="0" align="center" border="1">'; echo "<tr><td><strong>User</strong></td>"; echo "<td><strong>Invoice?</strong></td>"; echo "<td><strong>First Name</strong></td>"; echo "<td><strong>Last Name</strong></td>"; echo "<td><strong>Agent Name</strong></td>"; echo "<td><strong>Email</strong></td></tr>"; while ($obj = mysqli_fetch_array($result)) { printf ("<tr><td>%s</td><td><input type='submit' name='create' value='Create'></td><td><input type='submit' name='update' value='Update'></td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>", $obj['username'], $obj['username'], $obj['first_name'], $obj['last_name'], $obj['agent_name'], $obj['email']); } mysqli_free_result($result); } ?> Thanks for any help, J Link to comment https://forums.phpfreaks.com/topic/145116-solved-sending-querystring-vars-via-form-action/ Share on other sites More sharing options...
The Little Guy Posted February 13, 2009 Share Posted February 13, 2009 let me get this straight, you want to have 3 buttons for one form, and when the user clicks on one of the buttons, you want to take that action I'm I correct? Link to comment https://forums.phpfreaks.com/topic/145116-solved-sending-querystring-vars-via-form-action/#findComment-761617 Share on other sites More sharing options...
rhodesa Posted February 13, 2009 Share Posted February 13, 2009 i wouldn't use a form here. just have buttons with onclick events for A tags with href attributes that point to the page: function display_invoice_table($result) { // display the table of users // set global variable, so we can test later if this is on the page global $invoice_table; $invoice_table = true; // $action = create or update // $user = username ?> <br /> <?php echo '<table cellpadding="0" cellspacing="0" align="center" border="1">'; echo "<tr><td><strong>User</strong></td>"; echo "<td><strong>Invoice?</strong></td>"; echo "<td><strong>First Name</strong></td>"; echo "<td><strong>Last Name</strong></td>"; echo "<td><strong>Agent Name</strong></td>"; echo "<td><strong>Email</strong></td></tr>"; while ($obj = mysqli_fetch_array($result)) { printf ('<tr><td>%s</td><td></td><td>',$obj['username']); //With a button printf ('<input type="button" value="Create" onclick="window.location.href=\'create_invoice.php?a=create?u=%s\';" />',$obj['username']); //With a link printf ('<a href="create_invoice.php?a=update?u=%s">Update</a>',$obj['username']); printf ('</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>', $obj['username'], $obj['first_name'], $obj['last_name'], $obj['agent_name'], $obj['email']); } mysqli_free_result($result); echo "</table>"; } ?> Link to comment https://forums.phpfreaks.com/topic/145116-solved-sending-querystring-vars-via-form-action/#findComment-761629 Share on other sites More sharing options...
neridaj Posted February 13, 2009 Author Share Posted February 13, 2009 I believe you helped me out yesterday as well, Thanks again Aaron! Link to comment https://forums.phpfreaks.com/topic/145116-solved-sending-querystring-vars-via-form-action/#findComment-761677 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.