get method displays in url
|
|
how to display selected elements only from data base
|
|
<?php
|
|
require 'lesson44.php';
|
|
?>
|
|
ist access the variables of that templaates using require,
with this this page conect to database and server, |
|
<form action ="lesson44template.php" method
="GET">
|
next execute form with select option , which one we select
that one displays in url, |
SELECT: <select name='ab'>
|
it checks it submit or not, after submit, get the value with
which it is submit, it has two value,oly one at a time it ican submit, that value it can select, after selectd it get that, run one query, about get the names from food table by using type, selected some items, convert to associative array, get that data usinf access method, that one print |
<option value="f" > fruits </option>
|
|
<option value="v" > vegetables </option>
|
|
</select>
|
|
<input type="submit" value="submit">
|
|
</form>
|
|
<?php
|
|
if(isset($_GET['ab'])) {
|
chceks it is submit or not
|
$fv = $_GET['ab'];
|
get the what value it is submitted
|
echo $fv .' </br>';
|
print what value is submitted
|
$query = "SELECT `name` FROM `foods` WHERE `type` = '$fv'
";
|
write query what to do
|
if($query_run = mysqli_query($mycon, $query)){
|
executt that query by chceking that database
|
while($row = @mysqli_fetch_assoc($query_run)){
|
convett to associative array
|
$name = $row['name'];
|
access that associative array
|
echo $name .'<br><br>';
|
|
}
|
|
} else {
|
|
echo 'validity';
|
|
}
|
|
}
|
|
?>
|
|
how to use another php
page to know server and data base is connected, like template
require
where after submit it will go
action and get
optional selection
select name
we can take any thing
option value
option value
how to check it is submit or not
isset
how to get the value from url
$_GET
how to print what value it is selected
create query
query
how to execute the query
mysqli_query
how to convert that to associative array
@mysqli_fetch_assoc(
how to access that
associative array
$row['name'];
if while else
No comments:
Post a Comment