Forum Moderators: coopster
I have created the list boxes and can display the result on the target form but does anybody know the syntax for the following query?
<?php
$field1 = $_POST['select1'];
$field2 = $_POST['select2'];
$conn = mysqli_connect("localhost","root","password","db1");
$result = mysqli_query($conn, "select $field1 from allcolumns where assetid like '$field2';");
?>
Any Help would be much appreciated.
Thanks
If so perhapos this threat will help you
[webmasterworld.com...]
I just want to be able to create a query which can select the field names selected from the list boxes. As I only want to show some fields I am happy to declare them as options manually.
I would like "Select $Listbox1, $Listbox2, $listbox3 from.....";
This is the incorrect syntax for selecting variables in a sql statement though. If you know the right syntax that would be great.
Thanks.
if each field name is variable meaning there is a dynamic number of fields then you need to do a little more testing to build your query.
check whoich are set and append with a comma. It needs to work so that if there is only one, then no comma. If there is more than you could loop it and add a comma between each making sure you don't leave a trailing comma.