How to echo and auto increment receipt number in php? - php

I have a database, and table fees. In which I have to generate a receipt of each payment. But I want that receipt number field must first echo receipt number which is one increment (+1) of last receipt number. For example, last receipt is 1 than new receipt should be 2 and non editable.
I am bit confused in that.
My field code is:
<label class="field-title">Reciept Number <span class="form-req">*</span></label>
<input type="text" name="reciept_number" class="span4" value="<?php
$data = max(mysqli_fetch_array(mysqli_query($conn,"SELECT reciept_number FROM fees"))); echo $data; ?>" readonly>

Dont understand your question exactly but maybe you want something like this:
<label class="field-title">Reciept Number <span class="form-req">*</span></label>
<input type="text" name="reciept_number" class="span4" value="
<?php
$data = mysqli_fetch_row(mysqli_query($conn,"SELECT max(reciept_number)+1 FROM fees"));
echo $data[0];
?>" readonly>

Related

How to arrange the amount in words as same as Total number?

When I entered some objects in Item then automatically others values filled after fetching from database. and from Base Total to Amount in words are also calculated through database. and when I give the some number of value to Round Of below total will be changed. But my problem is after changed the Total There was didn't changed the Amount in words value.
Example
Round Of<input type="text" class="form-control inv_all_total_round" id ="inv_all_total_round" value="<?php if(isset($invoicedata)){ echo $invoicedata->inv_all_total_round_of; } ?> " name="inv_all_total_round_of">
Total <input type="text" class="form-control total_balance" id ="inv_all_total" total="<?php if(isset($invoicedata)){ echo round($invoicedata->inv_all_total); } ?>" value="" name="inv_all_total" readonly>
Amount in words <input type="text" class="form-control" id ="inv_amt_inwords" value="<?php if(isset($invoicedata)){ echo $invoicedata->inv_amt_inwords; } ?>" name="inv_amt_inwords" readonly>
And This is the Jquery code
alll_tot = $("#inv_all_total").attr("total");
$("#inv_all_total").val(alll_tot);
round_offf = $("#inv_all_total_round").val();
$( "#inv_all_total_round" ).keyup(function() {
round_offf = $("#inv_all_total_round").val();
alll_tot = $("#inv_all_total").attr("total");
var final_tot = parseFloat(alll_tot) + parseFloat(round_offf);
if(round_offf!=''){
if(isNaN(final_tot)==false){
$("#inv_all_total").val(final_tot);
}
}else{
$("#inv_all_total").val(alll_tot);
}
});

How to loop inside textbox in PHP

How can I loop numbers inside a textbox whenever page is refresh? in PHP
<input type="text" name="name1" value="loophere">
I want a textbox automatically have a value number whenever I refresh a page.
I need to used this for a column in my database and I want it automatically. I already have one column auto_increment in my database. Big thanks.
Use rand()
<input type="text" name="name1" value="<?php echo "1".rand();?>">
http://php.net/manual/en/function.rand.php
OR Use str_shuffle()
<?php
$string = "123456789AaBbCcDdEeFfGgHhIiJjKkLlMmNnPpQqRrSsTtWwXxYyZz"; //You can use any string
$key_len = "5";
$string_shuffle = str_shuffle($string);
$session_key = str_shuffle(substr($string_shuffle, 3, $key_len));
?>
<input type="text" name="name1" value="<?php echo $session_key;?>">

Loop through 3 arrays at once and save values in the database

I have three inputs type text in an HTML page and a button which if clicked duplicate each text box (Javascript) making them 6.
<input type="text" name="category[]">
<input type="text" name="quantity[]">
<input type="text" name="amount[]">
<button>Add more</button>
Which generate same inputs again:
<input type="text" name="category[]">
<input type="text" name="quantity[]">
<input type="text" name="amount[]">
A piece of code in Cakephp I have been trying:
$data = $this->request->data;
foreach($data['category'] as $index => $value){
$this->ModelName->save($value);
}
Trying to get two rows inserted at once with quantity, category and amount as columns. But it is not inserting and not giving any error.
Is there a way I can achieve this?
Thanks.
I'm not sure how your model works in cakephp, but you should be able to get a complete grouping of data like:
foreach($data['category'] as $index => $value){
$category = $value
$quantity = $data['quantity'][$index];
$amount = $data['amount'][$index];
// use the above 3 variables however you need to to persist the model
//$this->ModelName->save($value);
}
On a side note, you may want to consider reordering your html inputs to be like:
<input type="text" name="item[0][category]">
<input type="text" name="item[0][quantity]">
<input type="text" name="item[0][amount]">
And then maintain the next index, incrementing the numeric index of item for each additional group
This will allow you to iterate like:
foreach($data['item'] as $index => $group){
//$group['category'];
//$group['quantity'];
//$group['amount'];
}

Magento Telphone filed in Customer_Account_Edit page

I want to do the same as this guy do
Magento: How to display customer's phone number on customer information field
but I don't want only to display the customer phone number, I want to give ability to change the telephone number on this page.
If I follow the guy's above solution I only get the Telephone display in a field but when I submit the form everything else is being saved except this telephone field. What could be the code solution to save the new information after FormSubmission?
Thanks in advance
UPDATE #1
I update /app/design/frontend/base/default/template/customer/form/edit.phtml with this code
<input type="text" placeholder="<?php echo $this->__('Telephone') ?>" name="telephone" value="<?php echo $this->getCustomer()->getPrimaryBillingAddress()->getTelephone() ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="telephone" />
but it doesn't save (form omit changes) if I change the input value and submit the form.
I wonder why..

MySQLi/PHP - How can I display total "number" of users that chose one side vs the other?

This is as detailed as possible.
I have 2 forms used for pre-registration for an upcoming game. Depending on which form someone fills out, will depend on the side they are registering for. Regardless both forms insert data into the same table and everything is working great for that part.
The issue Im running into is when I try to display the count for the number of times a certain side (red or blue) is used in the database, nothing is displayed.
The end result should show something like "3 vs 2" on the page so people can see it and have it update automatically when new info is submitted.
Where 3 is the current total of times the "blue" side has been chosen and 2 is the current total of times the "red" side has been chosen.
The table name is "game_checkin" and the column for the sides is "side". The two possible answers are "red" or "blue". Both are hidden fields.
Both of my forms looks like this:
<form action="/pre-reg.php" method="post">
<input type="text" name="name" placeholder="Name" required><br/>
<input type="text" name="age" placeholder="Age" maxlength="2" required><br/>
<input type="text" name="location" placeholder="City, ST" required><br/>
<input type="text" name="callsign" placeholder="Callsign" maxlength="12" required>
<input type="hidden" name="date" value="<?php echo date ('m-d-Y');?>">
<input type="hidden" name="side" value="blue"> red has a value of "red"...
<input type="submit" value="Check In">
</form>
This is the current code I use. I supplied an open area for anyone wanting to tell me what I'm missing.
<?php
$con=mysqli_connect("localhost","user","password","dbname");
// Verify Connection - duh!
if (mysqli_connect_errno())
{
echo "You kicked my doge and now he no pee straight:<br/>"
. mysqli_connect_error();
}
///// SCHOOL ME HERE \\\\\
mysqli_close($con);
?>
Like I mentioned,
I need to know how to display the total "number" of users that chose "blue" vs "red".
Then echo it to the page, for example like: 3 vs 2
my resources: mysql 5, php 5, phpmyadmin, linux os, paid hosting...
I have been stuck on this for the past few days trying to find an answer everywhere I could look. If you can help, it will be greatly appreciated.
It's actually kinda trivial...
$sql = mysqli_query($con,"select `side`, count(*) from `game_checkin` group by `side`");
$sides = array("blue"=>0,"red"=>0);
while($row = mysqli_fetch_row($sql)) $sides[$row[0]] = $row[1];
echo $sides['blue']." vs ".$sides['red'];

Categories