Note that there are some explanatory texts on larger screens.

plurals
  1. POGet data from a text value in php
    text
    copied!<p>I am totally stuck here and found tens of samples on posting to get and set values. What I am trying to do is -</p> <ol> <li><p>Let a user enter a vehicles year model into a textbox in my form (set to post)</p></li> <li><p>I then need to get this value to a variable state</p> <pre><code>$vehicle_year = $_GET['vyear']; </code></pre> <p>First error is here... vyear is the name and id for my textbox. Error - Undefined index 'vyear'. There is no submission of the form etc, because I am still on the same form/page.</p></li> <li><p>With this value captured, I then search my database to return all of the manufacturers that has a year (as returned) attached to it -</p> <pre><code>$query = "SELECT * FROM `vehicledata` WHERE `year`='$vehicle_year'"; </code></pre> <p>Obviously it does not work because I still do not have the value as yet returned from above with the undefined error. I've tried to change the name and id of the textbox, no luck.</p></li> <li><p>Once these records has been returned, I need to add the values to a select (drop down) box. I have no idea how to get the values in there - seems I need to run a loop, which I know how to, just don't know how to add the options to the select box.</p> <p>Please note that my form is NOT submitted, I need to load all the relevant data first before it gets submitted.</p></li> </ol> <p>Any help will be appreciated, thanx guys.</p> <p>P.S. I will add against sql injection once I know how to get the values and add the options. Just need the basics to get me going.</p> <p>HTML: //This would be my code... Search Just my Wheels<br> <strong>Year</strong>&nbsp;&nbsp; </p> <pre><code> &lt;?php $vehicle_year = isset($_POST['vehicleyear']) ? $_POST['vehicleyear'] : -1; if ($vehicle_year == -1) { echo 'No Value Returned...'; //returns no value... } else { //How to get the value and echo it out... echo $vehicle_year; } //$query = "SELECT * FROM (SELECT * FROM `vehicledata` WHERE `year`='$vehicle_year' ORDER BY `cid` DESC LIMIT 1, 10) AS `table` ORDER BY `cid` ASC"; $query = "SELECT * FROM `vehicledata` WHERE `year`='$vehicle_year'"; $result = mysql_query($query); while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { $vehicle_id = $line['cid']; $vehicle_year = $line['year']; $manufacturer = $line['carfindmake']; //Get manufacturer data... $images = get_make($vehicle_year); if (!empty($make)) { echo 'No data'; } else { echo 'Found stuff'; } } ?&gt; &lt;td align="right"&gt;&lt;span style="visibility:hidden" id="makelabel"&gt;&lt;strong&gt;Make&lt;/strong&gt;&amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/td&gt; &lt;!--&lt;td&gt;&lt;input name="make" id="make" type="text" class="searchbox" style="visibility:hidden" onClick="toggleVisibility('modellabel'); toggleVisibility('model');"/&gt;&lt;/td&gt;--&gt; &lt;td&gt;&lt;select name="make" id="make" class="searchbox" style="visibility:hidden" onClick="toggleVisibility('modellabel'); toggleVisibility('model');"/&gt;&lt;/td&gt; </code></pre>
 

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