Wordpress Tutorials
- Wordpress
- Directory and file structure.
- Wordpress configuration
- Htaccess Configuration
- WP-CONTENT user playground
- Increase file size loading in phpmyadmin on localhost.
- Fatal error: Allowed memory size of x bytes
- wordpress Dashboard
- How to set local host domain or Virtual host
- Header, index and footer page.
- How to create wordpress Themes
- Html to wordpress themes
- Child Themes
- Increase Upload Max Filesize
- wp_enqueue_style & script
- How to make plugin
- Create Plugin
- Insert data into table using plugin.
- Show data from database
- Hook & Filter
- Template Or Custom page template
- Custom Login template
- How to show post on diffrent page.
- Custom widgit
- How to use contact form 7 plugin.
- Wordpress Database
- How to use Duplicator plugin
- How to fix Fatal Error: Maximum Execution Time Exceeded in WordPress
- How to debuggin mode on in wordpress
- Auto update plugin and themes
- How to Transfer WordPress
- How to change a WordPress site URL
- Top 10 issues in wordpress
- wordpress website link
Wordpress setting
Wordpress Function
wordpress top 10 problems
Important Links
How to show data from database?
create your own plugin
File name : index.php
<?php
/**
* Plugin Name: my-showdata-plugin
* Plugin URI: http://itechtuto.com
* Description: This plugin show login page details.
* Version: 1.0.0
* Author: Mahtab Habib
* Author URI: http://itechtuto.ocm
* License: GPL2
*/
function show_data_db() {
?>
<table border="1">
<tr>
<th>Firstname</th>
<th>Lastname</th>
</tr>
<?php
global $wpdb;
$result = $wpdb->get_results ( "SELECT * FROM wp_my_table" );
foreach ( $result as $print ) {
?>
<tr>
<td><?php echo $print->id;?></td>
<td><?php echo $print->name;?></td>
</tr>
<?php
}
}
// adds a shortcode you can use: [showtabledata]
add_shortcode('showtabledata', 'show_data_db');
?>
Another ways:
File name : index.php
global $wpdb;
/* wpdb class should not be called directly.global $wpdb variable is an instantiation of the class already set up to talk to the WordPress database */
$result = $wpdb->get_results( "SELECT * FROM wp_my_table"); /*mulitple row results can be pulled from the database with get_results function and outputs an object which is stored in $result */
//echo "<pre>"; print_r($result); echo "</pre>";
/* If you require you may print and view the contents of $result object */
echo "ID"." "."Name"."<br><br>";
foreach($result as $row)
{
echo $row->id." ".$row->name."<br>";
}
/* Print the contents of $result looping through each row returned in the result */
File name : index.php
<?php
global $wpdb;
$results = $wpdb->get_results("SELECT * FROM wp_names");
print_r($results);
?>
File name : index.php
<?php
global $wpdb;
$results = $wpdb->get_results("SELECT name FROM wp_names WHERE girl = 1 and cute = 1 ORDER BY name");
if(!empty($results)) {
foreach($results as $r) {
echo "<p>".$r->name."</p>";
}
} else {
echo "<p>Boo, we couldn't find anything that is in all these groups. Try removing a category!</p>";
}
?>
File name : index.php
<?php
global $wpdb;
$gender = esc_sql($_GET["gender"]);
$query = esc_sql($_GET["q"]);
$results = $wpdb->get_results("SELECT name FROM wp_names WHERE $gender = 1 and $query = 1 ORDER BY name");
File name : index.php
global $wpdb;
$name = 'Toby';
$gender = 'boy';
$category1 = 1;
$category2 = 0;
$wpdb->insert('wp_names',
array(
'name'=>$name,
'gender'=>$gender,
'category1'=>$category1,
'category2'=>$category2
),
array(
'%s',
'%s',
'%d',
'%d'
)
);
File name : index.php