I am currently trying to build a booking system for a theatre. I have 5 different productions which are found from my database with a query in php.
I have a table showing the productions and their associated ticket price. Each row states the production, ticket price and a submit button (using $_POST) to choose that production.
I am trying to send the title of the selected production as production_'production title'. e.g. if hamlet was selected I would retrieve the selection using $_POST['production_hamlet'].
However I do not know how to replace the title of each production found in the query when retrieving the POST.
e.g. on the next page when echoing out to see if it's submitted I don't know what to write after echo $POST['production.....'].
Here is my code:
<form method="post" action="choose_performance.php">
<table name="choose_performance">
<thead id="td">
<tr>
<td>Production</td>
<td>Basic Ticket Price</td>
<td>Select</td>
</tr>
<thead>
<tbody>
<?php
$production_set = find_productions();
while($row = mysqli_fetch_assoc($production_set)){?>
<tr>
<td><?php echo $row['Title']?>
<input type="hidden" name="<?php echo "production_".$row['Title']?>" value="<?php echo $row['Title']?>" />
</td>
<td><?php echo $row['BasicTicketPrice'];?>
<input type="hidden" name="<?php echo "price_".$row['Title']?>" value="<?php echo $row['BasicTicketPrice']?>" />
</td>
<td>
<input type="submit" name="submit" value="Submit"
onclick='alert("Thank you for your selection. Please choose your preferred performance time and date on the next page.");'>
</td>
</tr>
<?php
}
?>
</form>
Any advice on how to retrieve the POST would be amazing.
Thanks.
Just put the <form> tag inside your while loop so that each row has its own form for submission. This way, when the form is submitted, you only have 2 posted params (production & price). See below:
<tr>
<td>
<?php echo $row[ 'Title']?>
</td>
<td>
<?php echo $row[ 'BasicTicketPrice'];?>
</td>
<td>
<form method="post" action="choose_performance.php">
<input type="hidden" name="production" value="<?php echo $row['Title'] ?>" />
<input type="hidden" name="price" value="<?php echo $row['BasicTicketPrice'] ?>" />
<input type="submit" name="submit" value="Submit" onclick='alert("Thank you for your selection. Please choose your preferred performance time and date on the next page.");'>
</form>
</td>
</tr>
Related
i update php form and change the value but it cant change it saves the same previous value
<tr>
<td width="22%">Course Fees</td>
<td width="38%">
<div id="total_fees">
<input type="text" class="input_text" name="total_fees" id="toal_fees" onblur="show_record(this.value,1)" value="<?php if($_POST['total_fees']) echo $_POST['total_fees']; else echo $row['total_fees'];?>" />
</div>
</td>
</tr>
Please see the screenshot of source code and input filed . i changed the value in input field but it remain same in source code and save source code value db
The input values not immediately affect on your input but You will get your new value while you submitting your form.
So submit your form and then print the values of the Request. You will find the new value of total_fees into the request parameters.
HTML CODE
<form name="jqueryForm" method="post" id="jqueryForm" enctype="multipart/form-data" onSubmit="return validme();">
<table border="0" cellspacing="15" cellpadding="0" width="100%" >
<tr>
<td width="22%">Course Fees</td>
<td width="38%">
<div id=total_fees>
<input type="text" class="input_text" name="total_fees" id="toal_fees" onblur="show_record(this.value,1)" value="<?php if($_POST['total_fees']) echo $_POST['total_fees']; else echo $row['total_fees'];?>" />
</div>
</td>
<td width="40%"></td>
</tr>
<tr>
<td width="22%">Discount in <input type="radio" name='discount_type' value="<?php if($_POST['discount_type']) echo $_POST['discount_type']; else echo percent; ?>" checked="checked" onChange="show_record()" />% or <input type="radio" name='discount_type' value="<?php if($_POST['discount_type']) echo $_POST['discount_type']; else echo cash; ?>" onChange="show_record()" />Cash</td>
<td width="38%"><input type="text" class="input_text" name="concession" id="concession" value="<?php if($_POST['concession']) echo $_POST['concession']; else if($row_record['discount'] !=0) echo $row_record['discount']; else echo 0; ?>" onBlur="show_record()"/>
</td>
<td width="40%"></td>
</tr>
</table>
<input type="submit" value="Save Record" name="save_changes" />
</form>
PHP CODE FOR SAVE IN DB
if(isset($_POST['save_changes']))
{
$total_fees=($_POST['total_fees']) ? $_POST['total_fees'] : "0";
$data_record['total_fees']=$total_fees;
$courses_id=$db->query_insert("enroll", $data_record);
}
I am looking to display the current value of the NumberedEntered value in the input box.
Currently it will only display the current value when I click submit then refresh. Does anyone know how I can echo it back as soon as I click submit?
Thanks.
<?php foreach($users as $user) : ?>
<tr>
<form action "index.php" method "post" name='form1'>
<td align="center" width="40%" ><?php echo $user['FullName']; ?><input type="hidden" Name="FullName" value="<?php echo $user['FullName']; ?>" /></td>
<td width="30%"><input type="number" name="NumberedEntered" value="<?php echo $user['NumberedEntered']; ?>" /></td>
<td><input type="submit" value="submit"></td>
</form>
</tr>
<?php endforeach; ?>
I am working on an existing application. I am encountering a strang issue. Here is my loop.
<tbody>
<?php if($results->num_rows > 0 ): ?>
<?php foreach ($results->result() as $row1): ?>
<tr>
<td class="td_data"><?php echo $row1->customer_name; ?></td>
<td class="td_data"><?php echo $row1->postcode; ?> </td>
<td class="td_data"><?php echo $row1->company; ?></td>
<td class="td_data"><?php echo $row1->enquiry_status; ?></td>
<td class="td_data"><?php echo $row1->form_source; ?></td>
<td class="td_data"><?php echo anchor('customer/edit/' . $row1->customer_id, 'Edit'); ?></td>
<td class="td_data">
Login
<?php $action = $this->config->item('front_site_url').'members/login';?>
<form id="member_login<?php echo $row1->customer_id?>" action="<?php echo $action;?>" method="post" >
<input type="hidden" name="username" value="<?php echo $row1->username?>"/>
<input type="hidden" name="password" value="<?php echo $row1->password?>"/>
<input type="hidden" name="submitted" value="yes" />
</form>
<script type="text/javascript">
$('#member_login_link<?php echo $row1->customer_id?>').click(function(){
$('#member_login<?php echo $row1->customer_id?>').submit();
});
</script>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td class="td_data">No Record Found</td>
</tr>
<?php endif; ?>
</tbody>
This creates a list. And inspecting element displays this.
Here is the result of firebug which is fine on all the elements except the first.
And here is the first row result
I am unable to understand why this is happening. I have checked on different browsers and all have same issue.
EDITS:
This list that is being generate has form in each row. clicking on Login opens a tabs and asks for username and password. But the first row does not have form tags so it is not opening tag.
I have found the issue. A form closing tag was not written in header for Search functionality. so it was picking the first form closing tag and the form opening tag in the list was left to be hanged so it was not working.
Use empty form tag before main form tag inside foreach loop, then first empty form tag will be removed by foreach loop and functionality will work fine.
For example:
<div>
<form></form>
<form id="member_login<?php echo $row1->customer_id?>" action="<?php echo $action;?>" method="post" >
<input type="hidden" name="username" value="<?php echo $row1->username?>"/>
<input type="hidden" name="password" value="<?php echo $row1->password?>"/>
<input type="hidden" name="submitted" value="yes" />
</form>
</div>
I don't know if this is even possible, though I sure it is, just beyond my ability.
I want to filter a table generated from an SQL query using a set buttons in the browser, i.e. have checkboxes for if a task has been completed or not, and radio buttons for the timeframe (e.g. last 24hrs, week to date, date range etc..). All without constantly refreshing the page.
Can someone point me in the right direction, I'm not asking for someone to do it for me, but I'm self taught and need some guidance. Any help appreciated.
These are the filters I would like to use:
<form id="filters">
<input type="checkbox" id="live" name="filter_live" value="Live" /> <label for="live">Outstanding</label>
<input type="checkbox" id="completed" name="filter_completed" value="completed" /> <label for="completed">Complete</label>
|
<input type="radio" id="last24" name="filter_radio" checked="checked" onchange="return hide_range(this.checked);"/><label for="last24">Last 24hrs</label>
<input type="radio" id="WTD" name="filter_radio" onchange="return hide_range(this.checked);"/><label for="WTD">WTD</label>
<input type="radio" id="last_week" name="filter_radio" onchange="return hide_range(this.checked);"/><label for="last_week">Last Week</label>
<input type="radio" id="range" name="filter_radio" onchange="return show_range(this.checked);" /><label for="range">Range</label>
<div id="date_range" style="display: none;">
<br />
<label for="from">From: </label><input type="text" id="from" name="from"/>
<label for="to">To: </label><input type="text" id="to" name="to" />
<input type="button" value="Go" />
</div>
</form>
I would like to use them on the following table:
<table class="general">
<tr>
<th colspan='8'>Current Tasks</th>
</tr>
<tr>
<th>Created</th>
<th>Updated</th>
<th>Location</th>
<th>Task</th>
<th>Priority</th>
<th>Status</th>
<th>Completed</th>
<th>Action</th>
</tr>
<?php
while($row = mysql_fetch_array($eng_result)) : ?>
<tr>
<form action="Eng_update.php" method="post">
<td><?php if($row['Created'] == NULL){echo "";}else{ echo date("d/m/y", $row['created_ts']);} ?></td>
<td><?php if($row['LastModified']==NULL){echo "";} else {echo date("d/m/y", $row['Last_Modified_ts']);} ?></td>
<td><?php echo $row['Location'] ?><input type="hidden" name ="eng_loc[]" value="<?php echo $row['Location']; ?>" /></td>
<td><?php echo $row['Task'] ?><input type="hidden" name="eng_task[]" value="<?php echo $row['Task']; ?>" /></td>
<td><?php echo $row['Priority'] ?><input type="hidden" name="eng_priority[]" value="<?php echo $row['Priority']; ?>"</td>
<td><?php echo $row['Status'] ?><input type="hidden" name="eng_status[]" value="<?php echo $row['Status']; ?>"</td>
<td>
<?php if($row['Completed']==1){echo "yes";} else {echo "no";}?>
<input type="hidden" name="eng_task_complete[]" value="<?php echo $row['Completed'];?>"
</td>
<td>
<input type="hidden" name="update_id[]" value="<?php echo $row['ID']; ?>" />
<input type="submit" value="Update" onClick="return checkAction('Do you wish to update the status of this task?')"/>
</td>
</form>
</tr>
<?php endwhile; ?>
</table>
Thanks for taking the time to look :)
There is a jquery plugin called DataTables (if you are familiar with JQuery, this will be a breeze to use): http://datatables.net/
It has lots of features for sorting/filtering your data and even has the option to load data dynamically (through AJAX).
I think you want functionality like this: http://datatables.net/release-datatables/examples/api/multi_filter.html
edit:
for date ranges, create a custom sorting function, a similar question is answered here: http://www.datatables.net/forums/discussion/7218/sort-column-by-numerical-range/p1
I apologize in advance, I am a PHP noob!
I have form with some hidden fields. I need the values to POST to "submit_rma.php" so that they're not missing from the db--I need $qty, $estmate_id and $rma_type.
The rest of the fields are just displaying data for the user and are readonly. Currently I only get value from the qty text field.
Is there any easier way to pass these values? URL is out of the question due to security issues.
<form method="post" action="submit_rma.php";>
<table>
<tr>
<td>
Quantity
</td>
<td>
<input type="text" name="qty" value="<?php echo $qty ?>" size="1"/><br/>
</td>
</tr>
<tr>
<td>
Part #
</td>
<td>
<input type="text" name="" value="<?php echo $model ?>" size="8" READONLY/><br/>
</td>
</tr>
<tr>
<td>
Description
</td>
<td>
<input type="text" name="" value="<?php echo $name_EN ?>" size="50" READONLY/><br/>
</td>
</tr>
<tr>
<td>
Paid Date
</td>
<td>
<input type="text" name="" value="<?php echo $sold_date ?>" size="6" READONLY/><br/>
</td>
</tr>
<tr>
<td>
Amount Each
</td>
<td>
<input type="text" name="" value="<?php echo $dealer_price ?>" size="8" READONLY/>
</td>
</tr>
</table>
<input type="hidden" name="estmate_id" value="<?php echo $estmate_id ?>">
<input type="hidden" name="rma_type" value="Short Shipped">
<input type="submit" name="submit";">
</form>
Maybe use a hidden <INPUT>:
<input type="hidden" name="qty" value="<?= $qty ?>">
This won't show anything to the user. If you're unfamiliar, <?= x ?> is effectively equivalent to: <?php echo x; ?>.
However, this is a security problem, as an attacker could craft a fake request and put a different value into the field (sidestepping your page and doing the request directly). You should try and get the value some other way, such as through running the INSERT on page generation, then using an UPDATE on the POST, or something like that.
Am I pointing out the obvious to say that you forgot NAME attributes for all of the text boxes after "qty"? The values won't persist beyond this page if the names aren't there :-)