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; ?>
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 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>
how to save radio button has been selected at the time the page is reloaded? suppose I have selected some of the radio button and then reload the browser page. but after the page is reloaded radio buttons have been still the same. I use Codeigniter.
here is my view code
<div class="container">
<?php
$no=1;
foreach($hasil->result() as $row):
?>
<form action="<?php echo base_url();?>mahasiswa/hasil" method="post" class="form" enctype="multipart/form-data" name="form" onsubmit="stopCounter();">
<input type="hidden" name="id_soal[<?php echo $row->id_soal;?>]" value="<?php echo $row->id_soal;?>" />
<table>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td><b><?php echo $no.'. ';?></b></td>
<td><?php echo $row->pertanyaan;?></td>
</tr>
<tr>
<td rowspan="5"> </td>
<td><span class="radio"><label><input type="radio" name="jawab[<?php echo $row->id_soal;?>]" value="A" />a. <?php echo $row->a;?></label></span></td>
</tr>
<tr>
<td><span class="radio"><label><input type="radio" name="jawab[<?php echo $row->id_soal;?>]" value="B" />b. <?php echo $row->b;?></label></span></td>
</tr>
<tr>
<td><span class="radio"><label><input type="radio" name="jawab[<?php echo $row->id_soal;?>]" value="C" />c. <?php echo $row->c;?></label></span></td>
</tr>
<tr>
<td><span class="radio"><label><input type="radio" name="jawab[<?php echo $row->id_soal;?>]" value="D" />d. <?php echo $row->d;?></label></span></td>
</tr>
<tr>
<td><span class="radio"><label><input type="radio" name="jawab[<?php echo $row->id_soal;?>]" value="E"/>e. <?php echo $row->e;?></label></span></td>
</tr>
<?php
$no++;
?>
<input type="hidden" name="id_sesi" value="<?php echo $row->id_sesi;?>" />
<input type="hidden" name="jumlah" value="<?php echo $jumlah;?>" />
<?php
endforeach;
?>
<tr>
<td colspan="2"> </td>
</tr>
<tr>
<td colspan="2"><input type="submit" value="Selesai" class="btn btn-default"/></td>
</tr>
</table>
</form>
</div>
here my controller code
public function mulai_tes(){
$id=$this->uri->segment(3);
$this->load->model('m_mahasiswa');
$result=$this->m_mahasiswa->data_mahasiswa();
foreach($result->result() as $row):
$data['user']=$row->username;
$data['nama']=$row->nama;
endforeach;
$cek=$this->m_mahasiswa->validasi_tes($id,$data['user']);
foreach($cek->result() as $c){
if($c->id_sesi==$id){ ?>
<script type="text/javascript" language="javascript">
alert("Anda telah mengikuti tes soal ini");
</script>
<?php
echo "<meta http-equiv='refresh' content='0; url=".base_url()."mahasiswa/tes'>";
}
}
$data['hasil']=$this->m_mahasiswa->mulaites($id);
$data['jumlah']=$data['hasil']->num_rows();
$data['judul']='Mulai Tes';
$this->load->view('elearning/template',$data);
}
How I set cookie and where I can put cookie code in controller?
Check which radio(s) was selected in controler (http://ellislab.com/codeigniter%20/user-guide/libraries/input.html).
Pass this data to view (http://ellislab.com/codeigniter/user-guide/general/views.html).
Mark radio(s) as selected within view depending on data passed by controller (Assign an initial value to radio button as checked).
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 have this code which permits me to display all the data in the database as a textarea, I need to update them by clicking a update button!
Based on this one, is supposed to make me edit them, but when i click submit it doesn't...
<form name="form1" method="post" action="">
<tr>
<td>
<table width="500" border="0" cellspacing="1" cellpadding="0">
<tr>
<td align="center"><strong>Id</strong></td>
<td align="center"><strong>Name</strong></td>
<td align="center"><strong>Lastname</strong></td>
<td align="center"><strong>Email</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result)){
?>
<tr>
<td align="center">
<? $id[]=$rows['id']; ?>
<? echo $rows['id']; ?>
</td>
<td align="center">
<input name="name[]" type="text" id="name" value="<? echo $rows['name']; ?>">
</td>
<td align="center">
<input name="lastname[]" type="text" id="lastname" value="<? echo $rows['lastname']; ?>">
</td>
<td align="center">
<input name="email[]" type="text" id="email" value="<? echo $rows['email']; ?>">
</td>
</tr>
<?php
}
?>
<tr>
<td colspan="4" align="center">
<input type="submit" name="Submit" value="Submit"/>
</td>
</tr>
</table>
</td>
</tr>
</form>
</table>
<?php
// Check if button name "Submit" is active, do this
if($Submit)
{
for($i=0;$i<$count;$i++)
{
$sql1="UPDATE $tbl_name SET name='$name[$i]', lastname='$lastname[$i]', email='$email[$i]' WHERE id='$id[$i]'";
$result1=mysql_query($sql1);
}
}
if($result1)
{
header("location:update_multiple.php");
}
Yes because you forget your id's
<? $id[]=$rows['id']; ?> cannot be passed like that
<input type="hidden" name="id[]" value ="<?php echo $rows['id']; ?>" /><? echo $rows['id']; ?>
and script if($Submit){ should be if($_POST['Submit'] != ''){
You aren't defining $Submit in your post, so the stuff in the { ... } is never executed.
You should try something like this for your update:
if(isset($_POST[$name]))
{
// update stuff
}
In your code, as the if statement never executes, $result is never set, so the user isn't redirected away - it will just show the same page each time.
To check if a post occur when clicking a button should be set as follow:
In the <form>tag add the following
<form name="form1" method="post" action="<?php echo $_SERVER['PHP_SELF']; ?>">
And lastly, where you check if the button was clicked:
if(isset($_POST['Submit'])) {
//Update fields
}
Remember that the submit button name field is case sensitive in php