PHP Code and Dictionary Help Tools

PHP Code and Dictionary Help Tools

There are a lot of times when a form on a web app wants information already in the database. Such as the example below:

No alt text provided for this image

By adding in a help button, one can get a list of entire of possible entries. You may be looking for a name, but your help screen can give more information:

No alt text provided for this image

From there one can choose more easily and reliably an option that goes in the desired field:

No alt text provided for this image

Then close the help screen after choosing the data that goes in the spot! Let me show the structure of the look up database:

No alt text provided for this image


As well some sample data:

No alt text provided for this image

The code with the desired input follows:

<!DOCTYPE html>
<script type="text/javascript">
function help() {
?? var newwindow=window.open("https://localhost/tools/getname.php",
                             "_blank", 
                             "height=500,fullscreen=no,location=no,menubar=no,scrollbars=yes,resizeable=no,scrollbars=yes,top=300,width=500");
}
</script>
<h2>Get help!</h2><br>
<form name="this">
<input type="text" size="30" id="name" name="name">
<input type="button" onclick="help();return false;" value="Help">
<br>
</form>
</html>        

The magic is using an ID such as "name" for the lookup code to use.

As one can see it opens another window with the code that walks thru the database:

<?php
include "c:/tmp/incdb.php";
$Login["Host"]="localhost";
$Login["User"]="root";
$Login["Password"]="";
$Login["DB"]="test";
$Login["conn"]="";
$Login=AConnect($Login);
$sql="select * from hlpnames";
$R=ApplySQL($Login, $sql);
?>
<form name="this">
<?php
while($Row=$R->fetch_assoc()) {
? $V=$Row["f_name"] . " " . $Row["l_name"];
? $V1=$Row["f_name"] . " " . $Row["l_name"] . "(" 
     . $Row["position"] . ")";
? $U="SendHelp('" . $V . "')";
? ?>
? <input type="button" name="LookUp" 
   value="Choose <?php out($V1)?>" 
   onclick='return SendHelp("<?php echo $V ?>")'>
? <br>
<?php
}
?>
</form>
<script>
function SendHelp(msg) {? 
  opener.document.getElementById("name").value=msg;
}
</script>
</html>        

Hence an easy way to add some help to your apps!

要查看或添加评论,请登录

Scott Augé的更多文章

  • Useful Tool: PHP Wiki (mediawiki)

    Useful Tool: PHP Wiki (mediawiki)

    So many times programmers (or other) want a tool that can be a quick document for work out there. Something to answer…

    1 条评论
  • Management Article: What is quality software?

    Management Article: What is quality software?

    (This is from a E-Zine for developing in Progress. URLs and such are out dated.

  • Menus And The Like On PHP Programs

    Menus And The Like On PHP Programs

    Since it is snowy out today and I have experienced four stokes so don't mind the spelling if it you see an error, I…

  • GetValue() for form/url nvp and cookies with PHP

    GetValue() for form/url nvp and cookies with PHP

    When dealing with PHP and you have Webspeed experience (https://progress.com), it might be useful to create a GetValue()…

  • PHP to 4GL/ABL

    PHP to 4GL/ABL

    Added Entry() and NumEntries() to PHP code for a string of comma delimited substrings like the ABL/4GL has. Also…

  • Queue in PHP (Code)

    Queue in PHP (Code)

    Of course if I write about Stacks(1) (LIFO - Last In, First Out), then I got to write about Queues(1) (FIFO - First In,…

  • Simple stack in PHP (Code)

    Simple stack in PHP (Code)

    Here is a class called Stack that implements a stack. A stack is one of the basic data structures one learns in college.

  • Simple stack in PHP/Maria (Dictionary)

    Simple stack in PHP/Maria (Dictionary)

    This is a dictionary used for a simple stack code in an upcoming article. First of all, what is a stack? Well, it is…

  • HTML/JAVASCRIPT Validating Inputs (using Workbench)

    HTML/JAVASCRIPT Validating Inputs (using Workbench)

    Had a question: How do you validate inputs? (I do pay attention to my comments!) A good question (and gives me the…

  • PHP File browser added to workbench

    PHP File browser added to workbench

    Added a file browser to the workbench (for those of ya who have many test programs!) A new button appears on the bottom…

社区洞察

其他会员也浏览了