• zz21

    (@zz21)


    Good evening Mr, Mrs,
    Hope you’re well, I wanted to know if it would by any chance be possible to make a PHP shortcode couple with some SQL and HTML within you pluggin?
    Thanks in advance for your time,
    Kind regards,
    Sacha Mathey

Viewing 1 replies (of 1 total)
  • Hi Sacha, I didn’t program this plugin but yes you can absolutely do this. You have to write the code in PHP. Create PHP code like this, make sure to replace “your_table” with a table that exists in your DB and “id” with the column name in your table:

    <?php
        global $wpdb; //Mandatory
        $row = $wpdb->get_row("SELECT * FROM your_table WHERE id = '1'", ARRAY_A);
    ?>
    <!-- Now you can write HTML, and inject the PHP variables in it -->
    
    <!-- Will display name, if you have a column in your table labeled "name" -->
    <h2>Name: <?= $row['name'] ?></h2> 
    
    <!-- Will display email, if you have a column in your table labeled "email" -->
    <h2>Email: <?= $row['email'] ?></h2>

    Also, be sure to wrap your_table and id with grave accent symbols in your SQL. Hope that helps!

Viewing 1 replies (of 1 total)
  • The topic ‘Woul it be by any chance possible to have a code mixing html/Php and SQL’ is closed to new replies.