Whats the best way to create a wordpress plugin. I have started out learning to make plugins and i want to make a plugin to calculate 2 numbrs and save to a mysql database.
since i didnt know OOP in PHP i decided to code what i know.
my code looks like this only my instructor wants me to do something Awesome.. better than what i coded earlier.
Edit
Now i am trying to make this add and then send to the database.
Code looks like this now
<?php
/*
Plugin Name: Addition DB Plugin
Description: Plugin to Add to Database and call back from database
Author: James Ibrahimov
*/
global $wpdb;
function add2numbersandsavetoDB()
{
$num1 = '5';
$num2 = '11';
$ans = $num1 + $num2;
$wpdb -> insert('answer',array(
'id' => 'id',
'ans'=> $ans
),
array('%d','%s') );
}
add_action('main_menu', 'add2numbersandsavetoDB');
function displayDatafromDB()
{
$results = $wpdb-> get_results("select * from answer");
foreach($results as $result){
echo $result-> id;
echo $result-> ans;
}
}
add_action('main_menu','displayDatafromDB');
?>