WordPress. Page or Plugin?

Hello! There is a simple PHP script, the result of which I want to see on a separate page of a wordpress site by adding a link to this page in the menu (simplified code sample below). As I understand it, “pages” created by the user can only contain static html, and plugins are designed to add functionality to the engine, but not for separate, separate outputs. What should I do?

<?php
$sqlLink = mysql_connect('localhost', 'user', 'jKQsa821');
$result = mysql_query('SELECT `item_01`, `number` FROM database.items LIMIT 100;', $sqlLink);
$html = "";
$html.= "\n<table>\n<tr><th></th><th></th></tr>";
while ($row = mysql_fetch_array($result)) {
    $html.="\t<tr><td>" . $row['item_01'] . "</td><td>" . $row['number'] . "</td></tr>\n";
}
$html.='</table>';
print $html;
// , , -  =)
?>

Answer 1, authority 100%

for example, you can use shortcodes

function bartag_func( ) {
    // -
    return ",   ";
}
add_shortcode( 'bartag', 'bartag_func' );

by adding this code as a plugin, and writing in your message

[bartag]

, you will execute this script accordingly in this post

In general, shortcodes have a much wider application (they can accept parameters, and be nested like HTML

details
Shortcode_API