Good Day,
I have a textbox and I am fetching its value in next page.
Pls see code first below
View.php
echo '<td class="forscreen">Add Accessories</td>';
When you click add accessories, you get value of emp_number on next page where on next page I have:
<input class="input" type="text" name="emp_numberPrint" id="emp_number" readonly value="<?php echo (isset($_GET['emp_number'])) ? htmlentities($_GET['emp_number']) : ''; ?>"/>
Now, I want the same if I have another textbox named owner and I am trying the below code:
echo '<td class="forscreen">Add Accessories</td>';
<input class="input" type="text" name="ownerPrint" readonly value="<?php echo (isset($_GET['ownerPrint'])) ? htmlentities($_GET['first_name']) : ''; ?>"/>
Here first_name is to be fetched from last page in same way as emp_number is coming but it is not working,
Surely I am making mistake. Please guide me
Thanks
As per your approach, you have to pass it in query string to get this on next page.
For View.php
echo '<td class="forscreen">Add Accessories</td>';
On the next page
<input class="input" type="text" name="ownerPrint" readonly value="<?php echo (isset($_GET['first_name'])) ? htmlentities($_GET['first_name']) : ''; ?>"/>
In Second Case
echo '<td class="forscreen">
<a href="equipments.php?emp_number=' .$row['emp_number'].$row['first_name'] . '">
Add Accessories</a></td>';
You are passing the values wrongly
You must pass the variables like this
<a href="equipments.php?emp_number=<?php echo $row['emp_number']; ?>
&first_name=<?php echo $row['first_name'] ; ?>">
Add Accessories</a>
you can get values in next page is like
$_GET['emp_number'];
$_GET['first_name'];
Related
how can I pass this value which data is in database. I want to pass the value from another page by textbox. how can I do it?
here is my database
and I want to pass the Value on the textbox from another page how can I do that?
here is my code
include("topupcard.php";)
<td>
<?php echo htmlentities($row['value']);?>
</td>
<button class="btn btn-success mr-4">Generate QR Code</button>
and to pass the data to another page.
<input type="text" value="$row['value']" name="id">
right now, it is not working nothing is being passed.
also, i dont know if I'll use Session or not, help thanks.
so the output should be 200 or 1000 is displayed on the other page when i click the button.
Using #danblack's explanation you can
Option 1 (not a safe method if this involves transactions):
<a href="generatecode.php?value=<?php echo htmlentities($row['value']); ?>">
then on the other page
<input type="text" value="<?php echo $_GET['value']; ?>" name="id">
Option 2 :
session_start();
$_SESSION['value'] = $row['value'];
then on the other page
session_start();
$value = $_SESSION['value'];
<input type="text" value="<?php echo $value; ?>" name="id">
Hello I think I am really close but I just cant seem to get my statement working correctly
I have a overtime field from Mysql and I can display it but I am trying to make it either checked or not checked depending on if it is a 1 for checked or 0 for not checked. I can show the 1 or the 0 onto a Text field but the checkbox just won't work for me.
echo '<td> Overtime <input type="checkbox" name="chg_hrs_ovt[]" <? if($list_hours["overtime"]==1){ echo "checked=checked"} ?> >';
My complete code:
<?
// This next section is to load the text fields from the mysql
// this is to collect all of the logged hours on the job sheet and then display
// the hours already entered.
$hours_query = "SELECT * FROM hours where job_number = '$job_number'";
$hours_result= ($mysqli-> query($hours_query));
// this next section collects the data from the parts table and then adds it to an array
// this then goes into a while statement until it has displayed all of the results it has
// depending on how many parts were used
while ($list_hours = mysqli_fetch_array($hours_result))
{
echo " <table border ='0' table width = 70%>";
echo '<td> <input type="hidden" name="chg_hrs_id[]" value="'.$list_hours['unique_id'].'">';
echo '<td> Start Time <input type="time" name="chg_hrs_str[]" value="'.$list_hours['start_time'].'" >';
echo '<td> Finish Time <input type="time" name="chg_hrs_fin[]" value="'.$list_hours['finish_time'].'">';
echo '<td> Date Of Work <input type="date" name="chg_hrs_date[]" value="'.$list_hours['date'].'">';
echo '<td> Ovt Boolean <input type="ovt_Booloean" name="chg_hrs_ovtb[]" value="'.$list_hours['overtime'].'">';
echo '<td> Overtime <input type="checkbox" name="chg_hrs_ovt[]" <? if($list_hours["overtime"]==1){ echo "checked=checked"} ?> >';
echo "</tr>";
}
echo "</table>";
?>
I think you have some Syntax issues. Try the following:
echo '<td> Overtime <input type="checkbox" name="chg_hrs_ovt[]"' . ($list_hours["overtime"]==1 ? 'checked="checked"' : '') . '>';
Thanks to Marc I had got the syntax incorrect I have used Marc's syntax and it has worked straight away. I now have to see how the statement is put together.
It seems like the dots is a link to connect statements together and it doesn't seem to actually need a if statement to be setup.
Good day!
I have a form where I have first name and last name but I am sending the first name value only in same field on next page like code below
<label>Owned By:</label>
<br />
<input class="input" type="text" name="ownerPrint" readonly value="<?php echo (isset($_GET['first_name'])) ? htmlentities($_GET['first_name']) : ''; ?>"/>
This works first for first name. How can I do the same for last_name in same line? Becuase above html code is one field with label owned by and this should show both first and last names concatenated
Code which is coming from previous file
echo '<td class="forscreen">Add Accessories</td>';
Just concatenate the two inputs:
<?php
if (isset($_GET['first_name'], $_GET['last_name'])) {
$full_name = htmlentities($_GET['first_name'] . " " . $_GET['last_name']);
} else {
$full_name = '';
}
?>
Then use $full_name in the value attribute of the input:
<input class="input" type="text" name="ownerPrint" readonly value="<?php echo $full_name; ?>"/>
Here, I want to get value of textbox, but I coudn't.
Where am I wrong?
Is it must to use session if i want to get value of textbox?
<input type="submit" id="processorder" name="processorder" class="submit-green" value="Process Order"/>
<?php
foreach ($order_list as $row)
{
?>
<td class="align-center">
<input type="text" name="text[]" autocomplete="off" id="txtid_<?php echo $row['id']; ?>" readonly value="<?php echo $text;?>">
</td>
</tr>
<?php
$i++;
}
?>
if(isset($_POST['processorder']))
{
$txtvalue = $_GET['text[]'];
echo "helo".print_r($txtvalue);
}
this is wrong,
$txtvalue = $_GET['text[]'];
it should be
$txtvalue = $_GET['text'];
^ no [] here
Replace $_GET['text[]'] to $_GET['text']
The field would not be called text[] to PHP. It would just be called text, but would be an array instead of a string.
Try this:
if(isset($_POST['processorder']))
{
$arrayvalue = $_GET['text'];
foreach($arrayvalue as $txtvalue){
echo "helo" . $txtvalue . "<br>";
}
}
As your text input name is text[] with a bracket, it indicates that it is sending as an array, so to get the value you need
if (!empty($_POST["test"][0]) ) {
$test_value = $_POST["test"][0];
}
I am using 0 here since your code only shows one input text, for the server-end will only receive one array value
why you use array name="text[]" if you don't want to get multiple data using "text" than make it name="text"
<input type="text" name="text" autocomplete="off" id="txtid_<?php echo $row['id']; ?>" readonly value="<?php echo $text;?>">
get value using
$_GET['text'] // get value
or
you want to multiple data using same name "Array"(mean using array)
<input type="text" name="text" autocomplete="off" id="txtid_<?php echo $row['id']; ?>" readonly value="<?php echo $text;?>">
get value using
$_GET['text'][0] // 0 is a index value
I have a problem showing the quantity for each article I check through a form which is getting data from a MySQL database I made.
Here is my code:
<?php foreach ($results_articles as $input) : ?>
<input type="text" name="<?php echo $input->id_article; ?>_txtbox[]" style="text-align: center; width:30px;"></input>
<input
type="checkbox"
name="checked_articles[]"
value="<?php echo $input->id_article; ?>">
<?php echo "(".
($input->ref_article).")".
($input->nom_article)." (".
($input->prix_article)." €)"; ?><br>
<?php endforeach; ?>
So, the "checked_articles" are showing up properly on my next page; but I really don't know how to show the quantity for each article checked.
I would like help from you !
Thanks! If you have any other infos, I'll reply of course!
I presume "quantity" is put in the text input, if so it should be accessible using:
foreach ($_POST['checked_articles'] as $checked_id)
{
$quantity = $_POST[$checked_id . '_txtbox'];
}
However, since the txtbox input is named to become an array, $quantity would result in an array. Maybe that is not what you intend. Then you could do it this way instead:
<input type="text" name="txtbox[<?php echo $input->id_article; ?>]" style="text-align: center; width:30px;" />
Having that, the textbox would be accessible using:
$_POST['txtbox'][$checked_id];