Member Avatar for leadcrumb

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;
}
?>

2 ways of doing so,
One when user write in search box, and click on search button , u can post search text to process page. and display search reslut in same or new page. this will load ur whole page

Another way is to use ajax, that u can send search text to process page when user complete typing , and show result in some section of ur page, this will not load whole page

Member Avatar for leadcrumb

It's more a condition (if title = (column)name than display description from (title=name(column) from the same row)). Here is the get title code

<?php echo get_the_title($ID); ?>

Again: wenn i make a new page in wordpress, i enter a title, and in the body i insert a shortcode (from a php code - look up its incomplete) not to insert manually every info what in the database table ist, i want that complete code in php that display automatically the info. Thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.