Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Web app - bootstrap toggle buttons to filter mysql/php query

Featured Replies

I'm hoping someone here can help me? I'm trying to create a simple web app for my own local use (i.e. not necessarily to publish to the web) that contains:

- A table of data populated by a php query to a mysql database
- Some bootstrap toggle buttons along the top that when pressed, filter the table contents

At the moment I'm working on the assumption that I will use the toggle buttons to change the WHERE clause in the mysql query and then refresh the page automatically so that only relevant records are returned from the database.

My problem is that I have absolutely no idea how to achieve this, to the point where my google searching isn't helping because I'm not sure what to look for.

Can anyone point me in the right direction as to how I might approach this? Are there certain tools/languages that I should be looking for? I can make basic HTML pages and program in python so I have some technical skills, it's been many years since I looked at any web development though smile.gif

Any help would be appreciated!

Quick, easy way would be to use the buttons as links to this same page, with query parameters. The query parameters determine what query should be executed.

 

So a bs button could be..

<a href="http://example.com/?query=xxx" class="btn btn-primary">Link 1</a>

Then grab the value of $_GET['query'] and use some condition statements & logical operators to determine which query is executed.

 

e.g

 

 

if($query === 'xxx') :

// query string here

elseif($query === 'yyy') :

// query string here

endif;

 

//execute query, output results

 

 

 

 

Quickest way really, you could make it more elegant with the use of ajax if you want

Edited by Samus

  • 9 months later...

Quick, easy way would be to use the buttons as links to this same page, with query parameters. The query parameters determine what query should be executed.

 

So a bs button could be..

<a href="http://example.com/?query=xxx" class="btn btn-primary">Link 1</a>

Then grab the value of $_GET['query'] and use some condition statements & logical operators to determine which query is executed.

 

e.g

 

 

 

 

Quickest way really, you could make it more elegant with the use of ajax if you want

 

The problem is, this is wide open to attacks, you're allowing direct access to your DB query through the URL. It would be easier to output the entries you need and filter them using Javascript.

 

The problem is, this is wide open to attacks, you're allowing direct access to your DB query through the URL. It would be easier to output the entries you need and filter them using Javascript.

No it doesn't. Because you are passing a key which determines what query is executed, you aren't passing a query through the URL.

Wow, please read-up on web security and injection attacks.

I think you still don't understand.

What's the difference from setting up a parameter in your URL to execute a module in your code?

 

I never said write queries in the URL, the OP was looking for how to output different content via button filters. If the queries are pre-written, explain how injection attacks come into this?

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.