Create dropdown list to transfer me from one database to another

28
February 12, 2019, at 05:50 AM

I'm Building a table that displays users data using PHP & Mysql... See this image now:

I want to replace "Show entries" with a dropdown so I can select between my databases: users1 & users2 users3 to display the users data from each one and to insert and delete data from the same page...

Brief: Create drop down list to switch between my databases and display it's data...

Answer 1

You could do this:

First you create a dropdown: (not sure if your dropdown values are coming from your database as well? my example assumes it does and beware my example are using random database values and columns)

  $result = mysqli_query($con,$sql)or die(mysqli_error());
   if (mysqli_num_rows($result) > 0) {
     //open the select tag before the loop
     echo"<select name='category'>";
     //populate the select
     while($row = mysqli_fetch_assoc($result)) {
        $name=$row["Name"];
        echo"<option value=" .$name.">".$name."</option>"  ;
     }

Now you can get the selected option value like this:

 $category = mysqli_real_escape_string($link, $_REQUEST['category']);

Then you can use the variable to insert in your query needed.

For example you could make an if statement, so if $category is one value create query for database 1 and if $category is another value create query for database 2.

READ ALSO
PDF jpeg image compression for DCTDecode

PDF jpeg image compression for DCTDecode

I'm using android pdf writer apw-library to generate a pdf document

44
How can I attach multiple extras to a single Intent in the Bundle object?

How can I attach multiple extras to a single Intent in the Bundle object?

I'm receiving several notifications each with its own unique id

28
React Native TextField component in external library on focus

React Native TextField component in external library on focus

I have a Register Component that has PhoneInput Component from the external library https://githubcom/thegamenicorus/react-native-phone-input The problem is I want to execute some code as soon as TextField inside the PhoneInput is Focused

50