Jump to content

benanamen

Members
  • Posts

    2,134
  • Joined

  • Last visited

  • Days Won

    42

Posts posted by benanamen

  1. Your methods are just ridiculous. Stop creating a bunch of variables for nothing. The whole Class_info.php need to be thrown in the trash. It is just a container for a bunch of variables for nothing.

     

    You have an HTML5 document yet you are using XHTML tags.

  2. What you are looking for is called "Auto Complete". It is the same thing google does. It uses AJAX. Google is your friend. I easily found numerous examples. There is no need split the data unless you want to get results by category like @Barand said. The only thing with categories is a medicine can fall into numerous categories. If you do not have that all mapped the user may have trouble drilling down to a specific medicine. A single autocomplete is best if they already know the name of the medicine. You may actually want both options, one if you know the name, the chained select if you are trying to find a type of medicine.

     

    https://www.google.com/search?q=php+autocomplete+dropdown+from+database

  3. You have all kinds of problems.

     

    1. Stop using Dream Weaver and use a proper IDE

    2. Stop needlessly mixing all your html with php

    3. Learn how to properly use heredoc

    4. Don't post code with all the line numbers. Our own proper IDE's will give us the line numbers if we need it.

    5. Basically your Php processing should be at the top of the page and the HTML at the bottom, although you should be at least separating the HTML from the page with an include or ideally use a proper template engine like TWIG.

    6. You can't be mixing quote types.

    7. Your missing brackets

    8. Your missing parenthesis

    9. Your missing quotes.

     

    If you used a proper ide you would have seen all those careless mistakes. The code is full of it from top to bottom.

  4. You don't need all that flag stuff and a "working solution" doesn't make it right. Of course you will want to use htmlentities on the output.

     

    It also looks like you should be using a WHERE clause since you are only looking for a particular result that matches $_GET.

    <?php
    $sql  = "SELECT column_name FROM table";
    $stmt = $pdo->prepare($sql);
    $stmt->execute();
    $result = $stmt->fetchAll();
    
    if ($result)
        {
        foreach ($result as $row)
            {
            echo "{$row['column_name']}<br>";
            }
        }
    else
        {
        echo 'No Results';
        }
    ?>
    
  5. Yes. I already found my mistake. Thanks for trying to help :) 

    I made same radio names and added  if ($_GET['1']  == (radio value)) and its all perfect

     

    That is still wrong. $_GET can have numerous parameters. You are missing a name such as id=1. In your case it is name=1. You should probably be using POST instead of GET.

    <?php
    if (isset($_GET['name']))
        {
        if ($_GET['name'] == 1)
            {
            //do something
            }
    
        if ($_GET['name'] == 2)
            {
            //do something
            }
    
        if ($_GET['name'] == 3)
            {
            //do something
            }
        }
    ?>
    
  6. You are not doing any checks to see if the form has been submitted so the entire code runs before you doing anything. Look up and learn about isset.

     

    There are other problems I am sure others will tell you about.

  7. Ok, So it is a Mysql Keyword. Nevermind on the back ticks OP. name is still not a good column name anyways. What kind of name is name? Who knows? It is not descriptive enough. Thanks @Barand. I missed the line "Reserved keywords are marked with ®. ".

     

    Per the manual:

     

    Nonreserved keywords are permitted as identifiers without quoting. Reserved words are permitted as identifiers if you quote them as described in Section 9.2, “Schema Object Names”:

×
×
  • 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.