Jump to content

How to Display Individual Tables in Dropdowns from SQL?


Go to solution Solved by NotionCommotion,

Recommended Posts

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.

  • Solution

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);
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.