mardi 6 mars 2018

Dynamic SQL request in a PHP code

I'm currently coding a plugin in PHP and I have a list box containing numbers from 1 to 30 and a "submit" button. The plugin page is running some SQL request.

The point is the SQL request should update when you choose a number in the list box and click the submit button.

For instance:

SELECT G.xxx FROM yyy M, zzz G WHERE M.name = G.nomfield AND G.nomfield = "xxx" AND G.idfield = 01 AND G.xxx = $numberfrom1to30

the display should be different according to the number selected in the list box after the submit button is clicked. How should I do this?

I tried to:

<?php 
$selected = isset( $_GET['numberfrom1to30'] ) ? $_GET['numberfrom1to30'] : "" ;
$selectedValue = 'selected="selected"';
?>

<?php           
$numberfrom1to30= $_GET['numberfrom1to30'];
?>

But here's my error: Unknown column '$numberfrom1to30' in 'where clause'

Aucun commentaire:

Enregistrer un commentaire