(For Programmers) Help with PHP Functions

Discussion in 'PHP & Perl' started by FBGuru, Nov 15, 2014.

  1. FBGuru

    FBGuru Senior Member

    Sep 22, 2013
    Likes Received:
    Personality Type : ESTP
    Hey Guys!

    I'm building a WordPress site now and I need more functionality on it than just the vanilla WordPress features. I searched around the plugins repo and can't find anything that matches to my requirement.

    The feature I need is to pull random column data from the Wordpress Database and display it on the WordPress page and I need it done via the shortcode using php on custom page template.

    I've found some great articles like the one below to get it done.

    Let's say I need to display a shop's address and contacts from a city, I'd have the address and contact details in the database and I need it to be displayed on whatever page I create when I add this shortcode to the page.

    [shortcode Nottingham]

    Another feature I need is to display 2 tables for each city and have some information generated dynamically next to the table.

    For ex, let's say I add [shortcode Sheffield to Liverpool] to a page; It should display data in the following format.

    |Sheffield | Liverpool | The next shop is located on Liverpool, 77.1 miles from Sheffield
    |Address | Address
    |##### | #####
    |##### | #####
    |Contact : x | Contact : Y
    |Staff Nos : 10 | Staff Nos : 8 | The Liverpool shop have 20% lesser staffs than the Sheffield shop.

    All the data's are there in the table except the highlighted 20% and it should be generated dynamically by comparing two numbers that we have for the Sheffield and Liverpool as it'll be different for each city.

    Can anyone please shed some light on what functions should I use to make it work?

    I know I can simply pay someone to get his done but I'd really like to see it work through my hands.

    P.S. I can work with the css classes to format the data. I only need help with pulling the data from the table and generating the dynamic numbers by comparing 2 integers for the selected cities.

    Thanks a bunch in Advance! :)
  2. MrBlue

    MrBlue Senior Member

    Dec 18, 2009
    Likes Received:
    Web/Bot Developer
    First you need to learn how to implement your own custom shortcodes. You can include your new shortcode functions directly in your theme's function.php file or have them separated in there own plugin.
    Second, you can implement your custom DB queries using the wpdb class:
    This should give you a good starting point
    • Thanks Thanks x 1
  3. pr250

    pr250 Junior Member

    Apr 7, 2010
    Likes Received:
    3 gigs? no way man haha! Its very simple and effective, glad you decided to come here instead.
  4. vayacondios

    vayacondios Newbie

    Mar 3, 2015
    Likes Received:
    Did you get this working?