I made a new MySQL table in Phpmyadmin in Wordpress in the same database from Wordpress but a new table.
I want to make a new page and add a script in the body that allows:
1. when i insert the page title to the new page, the script should search the database table "workers" just in the column "name" and when it matches title(example "Jimbo") to the value in the column "name" (example "Jimbo") than display the "description" from name "Jimbo" (as in the table look down just "Jones"). It must search and display automatically.
2. or when i insert the link "www.example.com/ji", the script should search the database table "workers" just in the column "link" and when it matches title(example "www.example.com/ji") to the value in the column "link" (example "www.example.com/ji") than display the "description" from link "www.example.com/ji" (as in the table look down just "Jones"). It must search and display automatically.
MySQL table name "workers"
+---------+-----------+-------------+--------------------+
|id | name | description | link |
+---------+-----------+-------------+--------------------+
| 1 | John | Smith |www.example.com/jo |
| 2 | Jane | Smith |www.example.com/ja |
| 3 | Jimbo | Jones |www.example.com/ji |
| 4 | Andy | Smith |www.example.com/an |
| 7 | Chris | Jones |www.example.com/ch |
| 45 | Anna | Bell |www.example.com/ann |
| 44 | Jimmy | Carr |www.example.com/jim |
| 43 | Albert | Smith |www.example.com/al |
| 47 | Johnna | Doe |www.example.com/joh |
+---------+-----------+-------------+--------------------+
Here i had made something but it is not complete, i have run out of ideas, Thanks:
<?php
global $wpdb;
$result = $wpdb->get_row("SELECT name FROM workers");
if($result){
echo $result->description;
}
?>