0

I started PHP yesterday, and I want to know how I get the value from the drop down that I have to pass to the function. OK I got that part already. but I can't seem to call the assignment line below. instead, it just prints it out.

<?php include '../../view/header.php'; ?>
<div id="main">

<h1>Organization and their details</h1>

<br>
    //PRINTS THE LINE BELOW, NOT ASSIGNING TO $VIEW4
$view4 = get_view4($_POST["org_name"])
<?php echo $_POST["org_name"]; ?>
<table>
        <tr>

get_view4($org_name)
Jack Smother
  • 207
  • 1
  • 8
  • 32
  • You need a form and post it. – putvande Mar 13 '14 at 14:23
  • You need to wrap everything in a `
    ` tag, and set some method to actually submit (either POST or GET) the data to your account.
    – BenM Mar 13 '14 at 14:23
  • I think you would need to start from the beginning. Your question on the `for` loop, which is actually a `foreach` also seems to indicate you don't have a lot of knowledge of HTML neither, which is not bad as such, but will complicate your task in learning PHP if you ask me... – Laurent S. Mar 13 '14 at 14:24

4 Answers4

0

You just need to create a form along with the select box then when you just submit the form then you can access the dropdown value with $_REQUEST.

Ravi Sharma
  • 578
  • 4
  • 13
0

If you're using POST in your form, you should use $_POST['org_name'] and if you're using GET in your form, you should use $_GET['org_name']

Fizk
  • 1,015
  • 1
  • 7
  • 19
0
<form method='post'>
<select id='dropdown' name='dropdown' >
<option value='test'>test</option>
</select>
<input type='submit' name='button'>
</form>

<?php
if (isset($_POST['button'])) {

$dropdown = $_POST['dropdown'];

}
echo "$dropdown";
?>
//outcome should be test
-1

If you don't want a form, you'll have to get around and make a jQuery function to get the value. I suppose just adding form would be easier for you.

InsaneSVK
  • 206
  • 2
  • 3
  • 10