i want to fetch data from database into HTML table base on below option value
<form method="POST">
<label>Status</label>
<select class="form-control" name="selection_list">
<option value="">All</option>
<option value="A">A: Not Processed</option>
<option value="B">B: Partially Processed</option>
<option value="C">C: Completely Processed</option>
</select>
<input name="submit" type="submit" class="btn btn-success btn-sm" value="Generate">
</form>
if i select "All", php will select data from table where status = "All"
if i select "A: Not Processed", php will select data from table where status = "A"
...so on
how to writing code in HTML & PHP? please help....
use an id to select field:
<form method="POST">
<label>Status</label>
<select class="form-control" name="selection_list" id="list_id">
<option value="">All</option>
<option value="A">A: Not Processed</option>
<option value="B">B: Partially Processed</option>
<option value="C">C: Completely Processed</option>
</select>
<input name="submit" type="submit" class="btn btn-success btn-sm" value="Generate">
</form>
<?php
if($_POST['submit'])
{
$list_id=$_POST['list_id'];
//write the select query you need to process with WHERE status=$list_id;
}
?>
This is pretty basic stuff.
Official already answered it, but instead of id, you'll have to use the name attribute.
Not to mention that there are security issues with this method.
Related
For example I am at url like this:
localhost/somewhat/?action=active
And I have html form:
<form>
<div class="navbar-form navbar-right" name="x1">
<select class="form-control" name="limit">
<option selected value="10">10</option>
<option value="20">20</option>
<option value="50">50</option>
</select>
<button type="submit" class="btn btn-default">Submit</button>
</div>
</form>
On submit I recive url like
localhost/somewhat/?action=active
But I want to recieve this url in format:
localhost/somewhat/?action=active&limit=20;
I have an idea to do this with hidden inputs and foreach get element do echo of these hidden inputs. But it's a wrong way because $_GET['key'] can be array data also..
So, how to be?
<input type="hidden" name="get_key[array_inside_get_key][]" value="123"/>,
solution is here: https://gist.github.com/eric1234/5802030
I tried searching this and it is probably a really simple solution but I can't figure out how to combine an option field with a text field in html/php/js. Basically I just need the user to be able to select whether it is http or https and then type in the domain. It should then be submitted through _GET as a single variable.
<select>
<option value="http://">http://</option>
<option value="https://">https://</option>
</select>
<input class="span4" id="domain" name="domain" type="text">
<button class="btn btn-success" type="submit">Submit</button></form>
Any input would be appreciated.
I would combine them AFTER the submit...
HTML Page (You need to name your SELECT):
<select name="type">
<option value="http://">http://</option>
<option value="https://">https://</option>
</select>
<input class="span4" id="domain" name="domain" type="text">
<button class="btn btn-success" type="submit">Submit</button></form>
PHP Page:
$type = $_GET['type'];
$name = $_GET['domain'];
$combined = $type . $name;
Assuming you really "meant"
submitted through _GET as a single variable
You would end up with ie. https:// as $type and www.example.com as $name ... then the variable $combined should have a value of https://www.example.com
Select needs a name.
<form>
<select name="protocol">
<option value="http://">http://</option>
<option value="https://">https://</option>
</select>
<input class="span4" id="domain" name="domain" type="text">
<button class="btn btn-success" type="submit">Submit</button>
</form>
I have a form in html that takes the inputs and does some calculations. What I would like to do is have a drop down menu that has some options, but if the user's option isn't there, they can enter their own.
For this example let's assume it takes the sum of all the entries:
<form action="action.php">
<input type="text" name="int1" value="1">
<select name="dropdown">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="NULL">Other</option>
</select>
<input type="text" name="other" value="other">
<input type="submit" value="go">
</form>
My idea is that it would use either the drop down menu, or the "other" input if the drop down is set to other. Is there a way to care care of this in html or is this done with an if statement in php? just some of my ideas.
Help appreciated,
Thanks
Just do something like
if (isset($_GET['dropdown'])
&& $_GET['dropdown'] == 'NULL'
&& isset($_GET['other'])
) {
$value = $_GET['other'];
}
elseif (isset($_GET['dropdown'])) {
$value = $_GET['dropdown'];
}
else {
// Something went wrong. Handle error
}
You could also use JavaScript to submit the form so that only one value is passed to PHP if you're looking for a client-side solution.
You can do something like this using jquery
<script src="http://code.jquery.com/jquery-latest.js"></script>
<html><body>
<form action="" method="POST">
<input type="text" name="int1" value="1">
<select name="dropdown" id="dropdown">
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="NULL">Other</option>
</select>
<input type="text" name="other" value="other" id="other">
<input type="submit" value="go">
</form>
</body></html>
<script>
$(document).ready(function(){
$("#other").hide();
$('#dropdown').change(function(){
if($(this).val()=='NULL'){
$("#other").show();
}
else{
$("#other").hide();
}
});
})
</script>
and use php to catch the correct value
I would embed a PHP statement there that says if dropdown value is equal to other then add input text field under drop down box for user input.
I'm trying to pass two variables (a search query (String) and a column name (also a String)) via a HTML form. The first string is entered into a text box and the second is selected from a drop-down menu.
Obviously this method doesn't work:
<h3>Search for a Customer</h3>
<form action="search.php" method="get">
<input type="text" id="sString">
<select name="sField">
<option value="Name">Name</option>
<option value="HostID">Host ID</option>
<option value="OrderNumber">Order Number</option>
<option value="Theme">Theme</option>
</select>
<input type="submit" value="submit"/>
</form>
You need to give your <input> field a name in order for this to work. Unnamed inputs won't get passed through the form post.
You don't have a 'name' parameter on your sString input boxes. The name parameter is what gets sent back to the server, not the field's ID:
<input type="text" id="sString" name="sString">
and then in PHP
$search = $_GET['sString'];
You need to use attribute name instead of value.
<h3>Search for a Customer</h3>
<form action="search.php" method="get">
<input type="text" id="sString" name="sString"/>
<select name="sField">
<option name="Name">Name</option>
<option name="HostID">Host ID</option>
<option name="OrderNumber">Order Number</option>
<option name="Theme">Theme</option>
</select>
<input type="submit" value="submit"/>
</form>
Try:
<form action="search.php" method="get">
<input type="text" name="sString" id="sString" value="">
<select name="sField">
<option value="Name">Name</option>
<option value="HostID">Host ID</option>
<option value="OrderNumber">Order Number</option>
<option value="Theme">Theme</option>
</select>
<input type="submit" value="submit"/>
</form>
You should be able to access form entered variables by $_GET array in search.php. To see what is going on try var_dump($_GET);
I'm new to PHP, and I can't figure this out.
I'm trying to figure out how to access the data of a group of select boxes I have defined in my HTML code. I tried grouping them as a class, but that doesn't seem to work... maybe I was doing it wrong.
This is the following HTML code.
<form action="" method="post">
<select class="foo">
<option> 1.....100</option>
</select>
<select class="foo">
<option> 1.... 500></option>
</select>
<input type="submit" value="Submit" name="submit"/>
</form>
I essentially want to group all my select boxes and access all the values in my PHP code.
Thanks
Use the name attribute in your select tags. Then you can access those fields by name in the $_POST variable.
<form action="" method="post">
<select name="number_one">
<option value='1'>1</option>
<option value='2'>2</option>
<option value='3'>3</option>
</select>
<select name="number_two">
<option value='a'>1</option>
<option value='b'>2</option>
<option value='c'>3</option>
</select>
<input type="text" name="something"/>
<input type="hidden" name="hidden_value" value="hidden"/>
<input type="submit" value="Submit" name="submit"/>
</form>
In your PHP you can access these like so:
$number_one = $_POST['number_one'];
$number_two = $_POST['number_two'];
$something = $_POST['something'];
$hidden_value = $_POST['hidden_value'];