WordPress beginner, working on a way to query a database and show the results

[ad_1]

Hello. I’m searching for advice for a WordPress project I was tasked with.

I’m a junior webdev, my current work consists of me developing reports for an intranet page using PHP and MySQL. Since they don’t care about performance and our databases are small, most of the time I just make plain PHP pages that query our databases with adoDB and create tables going through the resultset with echo.

I was tasked with making a single report that goes through our database searching for specific words and showing the records that contain them. I achieved that by having a form in which they input what they’re searching for, through AJAX I send the input to the results page, which builds the query by exploding and processing the input, executes the query and outputs the results by echoing a plain table.

Now I’m tasked with making that page available to the public by uploading it to the company’s site, which was built on WordPress by a external dev ages ago, but I’ve worked with WordPress before, so I have no real idea how to start.

Since WordPress uses PHP I thought I could just copy and paste my PHP files into the server and just make it run the same way I do on the intranet site, but surely there’s a better, more efficient way of doing it?

I’d really appreciate your advice, and thank you very much for your time.

[ad_2]
3 Comments
  1. >*Since WordPress uses PHP I thought I could just copy and paste my PHP files into the server and just make it run the same way I do on the intranet site, but surely there’s a better, more efficient way of doing it?*

    That’s probably the most efficient way of doing it 😉 Where are you seeing an ‘inefficiency’ with that?

    Though, where is the DB hosted? Are you moving it to the prod server?

  2. I might iFrame the one you already built into a WP page. Then there’s one script to manage.

  3. Look at WP_Query and the args to make queries with post types.

    WordPress has an API to interact with the MySQL database.

    I’d also use the REST API for the form search. Look at register_rest_route

 

This site will teach you how to build a WordPress website for beginners. We will cover everything from installing WordPress to adding pages, posts, and images to your site. You will learn how to customize your site with themes and plugins, as well as how to market your site online.

Buy WordPress Transfer