Note that there are some explanatory texts on larger screens.

plurals
  1. POPost and get at the same time in php
    text
    copied!<p>Do you have any suggestions with my problem. I need to use get and post at the same time. Get because I need to output what the user has typed. And post because I need to access the mysql database in relation to that input. It looks something like this:</p> <pre><code>&lt;form name="x" method="get" action="x.php"&gt; &lt;input name="year" type="text"&gt; &lt;select name="general" id="general"&gt; &lt;font size="3"&gt; &lt;option value="YEAR"&gt;Year&lt;/option&gt; &lt;/form&gt; </code></pre> <p>This will output the contents of mysql depending on what the user will check:</p> <pre><code>&lt;form name="y" method="post" action"y.php"&gt; &lt;input name="fname" type="checkbox"&gt; &lt;/form&gt; </code></pre> <p>And the form action of those two combined will look something like this:</p> <pre><code> &lt;?php if($_POST['general'] == 'YEAR'){ ?&gt; &lt;?php echo $_GET["year"]; ?&gt; &lt;?php $result2 = mysql_query("SELECT * FROM student WHERE student.YEAR='$syear'"); ?&gt; &lt;table border='1'&gt; &lt;tr&gt; &lt;?php if ( $ShowLastName ) { ?&gt;&lt;th&gt;LASTNAME&lt;/th&gt;&lt;?php } ?&gt; &lt;?php if ( $ShowFirstName ) { ?&gt;&lt;th&gt;FIRSTNAME&lt;/th&gt;&lt;?php } ?&gt; &lt;/tr&gt; &lt;?php while ( $row = mysql_fetch_array($result2) ) { if (!$result2) { } ?&gt; &lt;tr&gt; &lt;td&gt;&lt;?php echo $row['IDNO']?&gt; &lt;/td&gt; &lt;td&gt;&lt;?php echo $row['YEAR'] ?&gt; &lt;/td&gt; &lt;?php if ( $ShowLastName ) { echo('&lt;td&gt;'.$row['LASTNAME'].'&lt;/td&gt;'); } ?&gt;&lt;/td&gt; &lt;?php if ( $ShowFirstName ) { echo('&lt;td&gt;'.$row['FIRSTNAME'].'&lt;/td&gt;'); } ?&gt; </code></pre> <p>I really get lots of undefined errors when I do this. What can you recommend that I should do in order to get the value inputted by the user together with the mysql data.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload