Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: php coding  (Read 17268 times)

0 Members and 1 Guest are viewing this topic.

12Strings

    Topic Starter


    Rookie

    • Experience: Experienced
    • OS: Windows 7
    php coding
    « on: February 18, 2020, 10:03:06 PM »
     my objective is to select records from database to remember info, click on and go to the target and
    update the date last used, visit count, time visited and if the info hasn't been saved, save it.
    I do this in html, see the records, click on a button and go to target of interest...  using Xampp
    server w/databases, and access thru php I can update(crud).
     
    My Xammp is running, my database is confirmed, my php doesn't seem to work in accessing the records.
    I've tried other forums to no avail.
    Below is my latest feeble attempt. I'm hoping for adviceI have a screenshot of resulting
    display, any help? c'mon, there's room.
    ===========================================================
    here's my code - hey I feel the lauhter
    ---------------------------------------
    <!DOCTYPE html><html>
    <head></head>
    <BODY><center>

        <?php
    echo "<center>";echo $date->format('d-m-Y H:i:s a');echo "</center>";
    $id="''";
        $con=mysqli_connect("localhost","root","","homedb");

    // ============== check connection

        if(mysqli_errno($con))
        {echo "Can't Connect to mySQL:".mysqli_connect_error();}
        else
        {echo "</br>";}

    // ==========This creates the drop down box using records in the table

           echo "<select name= 'target'>";
        echo '<option value="">'.'---select email account ---'.'</option>';
        $query = mysqli_query($con,"SELECT target FROM lookuptbl");
        $query_display = mysqli_query($con,"SELECT * FROM lookuptbl");
        while($row=mysqli_fetch_array($query))
        { echo "<option class=highlight value='". $row['target']."'>".$row['target']
        .'</option>';}
        echo '</select>';
        ?>
    <input type="submit" name="submit" value="Submit"/>
        </form></body></html>

               <?php
    error_reporting(E_ALL ^ E_NOTICE);
    // error_reporting(0);
        $con=mysqli_connect("localhost","root","","homedb");
        if(mysqli_errno($con))
        {echo "Can't Connect to mySQL:".mysqli_connect_error();}
            if(isset($_POST['target']))
      {
        $id = $_POST['id'];
            $name = $_POST['target'];
        $fetch="SELECT target, purpose, username, password, emailused, visits, lastdate, lasttime, saved
    FROM lookuptbl WHERE target = '".$name."'";
        $result = mysqli_query($con,$fetch);
        if(!$result)
        {echo "Error:".(mysqli_error($con));}

    // =============================== this displays the table

        echo '<table border="1">'.'<tr>'.'<td bgcolor="#FFD47F" align="center">'. 'email menu'. '</td>
    '.'</tr>';
        echo '<tr>'.'<td>'.'<table border="1">'.'<tr bgcolor="#ccffff">'.'<td>'.'target'.'</td>'.'
    <td>'.'purpose'.'</td>' '<td>'.'username'.'</td>'.'<td>'.'password'.'</td>'.'
    <td>'.'emailused'.'</td>'.'<td>'.'lastdate'.'</td>'.'<td>'.'lasttime'.'</td>'.'<td>'.'saved'.'</td>'.'</tr>';
        // while($data = mysqli_fetch_row($fetch))
        while($data=mysqli_fetch_row($result))
        {echo ("<tr><td>$data[0]</td><td>$data[1]</td><td>$data[2]</td><td>$data[3]</td><td>$data[4]</td>
    <td>$data[5]</td><td>$data[6]</td><td>$data[7]</td><td>$data[8]</td></tr>");}
        echo '</table>'.'</td>'.'</tr>'.'</table>';
      }
        ?>
        </body></html>

    Geek-9pm


      Mastermind
    • Geek After Dark
    • Thanked: 1026
      • Gekk9pm bnlog
    • Certifications: List
    • Computer: Specs
    • Experience: Expert
    • OS: Windows 10
    Re: php coding
    « Reply #1 on: February 19, 2020, 11:22:04 AM »
    Why did you pick PHP?
    Are you a PHP programmer?
    If so, what tools do you use?

    12Strings

      Topic Starter


      Rookie

      • Experience: Experienced
      • OS: Windows 7
      Re: php coding
      « Reply #2 on: February 19, 2020, 11:46:02 AM »
      Why did you pick PHP?
      Are you a PHP programmer?
      If so, what tools do you use?

      Please, answers npt ??   what would pick and why, Are you a PHP programmer?
      If so, what tools do you use?
      Are you a PHP programmer?
      If so, what tools do you use?

      I wonder if the fact that win7 is no longer supported is cause for PHP not to work. 
      Checking "php error logs" gets "cannot find path". Installed new xampp.  still no PHP?

      BC_Programmer


        Mastermind
      • Typing is no substitute for thinking.
      • Thanked: 1140
        • Yes
        • Yes
        • BC-Programming.com
      • Certifications: List
      • Computer: Specs
      • Experience: Beginner
      • OS: Windows 11
      Re: php coding
      « Reply #3 on: February 19, 2020, 04:02:30 PM »
      You are directly loading the PHP file into the browser. You need to access it through your server. Usually that is via http://localhost
      I was trying to dereference Null Pointers before it was cool.

      Geek-9pm


        Mastermind
      • Geek After Dark
      • Thanked: 1026
        • Gekk9pm bnlog
      • Certifications: List
      • Computer: Specs
      • Experience: Expert
      • OS: Windows 10
      Re: php coding
      « Reply #4 on: February 20, 2020, 04:25:24 PM »
      Dear topic poster;
      it seems that nobody is giving you a direct answer to your question. Judging by the appearance of things it seems that you are not an experienced PHP programmer.
      This gives rise to the question about why you chose PHP to solve the database problem.
      Although PHP is used widely for creating special programs, most users do not need to have a special program created by themselves solve the problem. Instead, most ordinary users just use something somebody else had already prepared and just adapted to their own needs.
      You seem to indicate that you need to update the database and you need to have some way of editing it according to when something was updated. That sort of thing is often done by people using some form of SQL. So that makes me wonder what kind of programming experience you have and what kind of work do you do.
      Or perhaps I should ask, is this for your own pleasure. If so, perhaps we should concentrate on what your needs are rather than giving you specific help on PHP syntax and usage. Perhaps it is not really need to write a program to get what you want. Perhaps you could give us some clues as to what kind of database you're working on and whether not to doing this for yourself or somebody else. It looks like you have copied somebody else's code. Is that true? And did you get permission to copy the code and posts it somewhere else?
      There are many experienced people year on this forum that would like to help you, but you make it difficult without providing more information about your background and your objectives. In any case, we do not to homework for people. Please help us understand about who you are and what your objectives are. This has nothing to do with your privacy, rather it helps us to understand what kind of background and experience you have and whether or not it would be wise for us to try to coach you in PHP usage.
      Have you had experience with managing databases? If so how large a better database and what sort of information for you handling?
      Again, these questions are to help others know how to respond to your request.

      In order to help you quickly I have written this post in my speech recognition program. So please excuse some bad grammar or spelling mistakes