sarojthapa60 Posted December 5, 2016 Share Posted December 5, 2016 I have 5 dropdowns on a tab of a website. I have a database table in MS SQL Server. The table has all the data of 5 dropdowns with one of the fieldNames called Region_Name, say the Region_Names are A, B, C, D, and E. I have written codes to display a table and enabled row editing for one of the RegionNames. Now, I am wondering if I could modify the same codes to display associated table with row editing enabled using different queries when a dropdown is clicked. That could reduce the code repetition and improve the performance. But I do not know how to achieve this. Could anyone please give me some hints? I am using PHP PDO to connect to the database. Quote Link to comment https://forums.phpfreaks.com/topic/302686-how-to-display-individual-tables-in-dropdowns-from-sql/ Share on other sites More sharing options...
Solution NotionCommotion Posted December 6, 2016 Solution Share Posted December 6, 2016 Not sure I understand your question, so forgive me if you already know this. Every time the browser makes a request to the server, it should include the region name in the URL (maybe use a default region name if none provided, and be sure to use isset() or something to make sure it exists). You then get the data based on the region name, pass it to a template, and display it. $stmt = $conn->prepare('SELECT x,y,z FROM yourTable WHERE Region_Name=:Region_Name'); $stmt->execute(['Region_Name'=>$_GET['Region_Name']]); $rs=$stmt->fetch(); yourTemplate($rs); Quote Link to comment https://forums.phpfreaks.com/topic/302686-how-to-display-individual-tables-in-dropdowns-from-sql/#findComment-1540070 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.