Jump to content

benanamen

Members
  • Posts

    2,134
  • Joined

  • Last visited

  • Days Won

    42

Posts posted by benanamen

  1. Just noticed that you are looking up ICD codes. That data is way to huge to select everything. You are going to have to do something like a chained select where you select a category and work your way down the dropdowns. 

     

    @barand makes a good point about the DB structure. What does the current DB look like? One big spreadsheet type table or something else?

  2. This is just for learning OOP. It is not about the function itself really, but how to handle superglobals in a class. The issue actually came up in a login logging class that uses $_SERVER['REMOTE_ADDR'], another superglobal. Several code analyzers (scrutinizer, codacy, code climate ) pointed out a problem with using them in the class. 

     

     

    * As far as what the function is for, it is used to display messages to the user after certain actions such as a db record added or deleted

  3. How would I to convert the following function to a class? What is the proper way to deal with GET and POST in a class since they are globals?

     

    My start

    class ShowActionMessage
    {
    
    }

    Function to convert

    function show_action_messages()
    {
    if (isset($_GET['insert']))
    {
    $action = 'Added';
    }
    
    if (isset($_GET['edit']))
    {
    $action = 'Updated';
    }
    
    if (isset($_GET['deleted']))
    {
    $action = 'Deleted';
    }
    
    if (isset($_GET['emailed']))
    {
    $action = 'Emailed';
    }
    
    if (isset($action))
    {
    ?>
    <div class="row">
    <div class="col-md-8 col-md-offset-2">
    <div class="success">Record <?= $action ?></div>
    </div>
    </div>
    <?php
    }
    }
    
  4. Problem is I am returning all the "null" values and I am not sure if there is a way to weed them out.

     

    Oh no, no, no, your problem is the entire database structure. Seriously, stop what you are doing right now and go back to the drawing board and start working on a sensible DB Schema. We will be happy to help you get going. What you have is an XY problem to the extreme.

     

    Start with a project summary of what this application is and what it should do then create a requirements document and post it. Once we know what you want and need we can offer the correct direction.

  5. If you had gone the Vagrant route first you would have saved yourself a lot of time and trouble.

     

    Install Xammp locally for development. If you want to develop or test on the exact server setup that you use in production, use Vagrant with your virtual box. The particular OS doesn't make a lot of difference as far as a LAMP stack. Apache is Apache is Apache. Php is Php is Php. Mysql is Mysql, is Mysql.

     

    My personal Linux choice for production is Debian. Ubuntu and many others are derivatives based off Debian.

  6. I am unable to change it without messing up other portions of the site.

     

    So you prefer to continue building on a bad DB design? Your problems are only going to compound if you continue on that path. Your DB is the foundation of all the code you are going to write. If that is not correct, everything you build on it will not be correct.

     

    The smart thing would be to make a copy of the site and do the fixes and testing locally and then backup and replace the "old" site.

     

    It would also appear you have additional problems repeating data with your "types". Types should be a separate table with a unique id which you would use to reference the data. You will want to learn about "Foreign Keys".

  7. I'm not sure why PHP programmers are so obsessed with PDO exceptions.

     

    It's probably because every PDO tutorial out there does the "Try/Catch show user the system error " way of doing it. I used to do that as well until I was schooled by @Jaques1 on the proper way with set_error_handler. The only place I use a try/catch now is on duplicate username on registration.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.