Jump to content

crmamx

Members
  • Posts

    417
  • Joined

  • Last visited

Posts posted by crmamx

  1. Thorpe:

     

    I have read many of your replies to problems and I indeed would classify you as an expert. In addition I am sure most on here appreciate your devotion of time to help us not as experienced with programming problems.

     

    Just a little background, I believe I do think as a programmer. In my past (I am 76) I have coded in Cobol, RPG, Fortran and Mapper. There, you know I am old. I have designed, help code and installed some of the largest Manufacturing Systems in this country. In my later years I was a systems consultant to the State of Virginia and a couple of other large agencies.

     

    About 10 years ago I put up a simple HTML site. Recently my flying club (http://ecbiz71.inmotionhosting.com/~bayare27/) asked me to develop a website for them. I did but I could not do what I wanted to do and then found the science had jumped years ahead of me.  So I started going thru the tutorials on javascript, mysql, php, CSS, SQL and AJAX. But as you well know there is no way, in a couple of months or even a year, I could ever learn all of these languages or become as proficient as you fellows.

     

    Recent example: I needed to check form input to see if the user had entered a value. That is not simple javascript. But it only took me a couple of minutes to find an example of the code I needed. Saved me from bothering you folks.

     

    Another example: In trying to add or delete a record from the db, I need to know if the record already exists, ect. I tried the different mysql examples and never could get it to work. So I ended up doing it with if and echo statements. I know it is terrible code but it works. I would love to have someone review it and show me a better way but I do not want to impose unless I just can't get it to work.

     

    I have tried several other forums and I will tell you that this is by far the best of them.

     

    Thanks again,

     

    Curtis

     

     

  2. I first try to first find an answer to my problem via the tutorials, w3schools, tizag, internet.com, ect. My problem is I can never seem to find a discussion or example relative to my problem.

     

    Example: I was trying to retrieve a db record and then have the resulting fields display in a form, where the user could change any of the fields data and then update the db with the changed data. Since the form name= variable was the same as the db variable, I assumed the data would "magically" show up in the form fields. No such luck and I was unable to find a solution in the tutorials.

     

    So I turned to php freaks and advised I need to echo the value into the form field.

     

    My question is what do you consider the best tutorials for php? Is there one that gives many examples? I can find javascripts for just about anything I want to do. Is there such a site for php where they can be downloaded or copied? The free stuff of course.

     

    Thanks

     

     

  3. I was told that I could retreive a db record and the fields would display in a form, which I could subsequently change and then update the db. If I am going about it the right way I just can't get the data to display. The echo appears to show I am getting a record.

     

    form4_change_airplane.php

    <html> 
    <head></head>
    <body> 
    
    <?php // Connect to database=====================================================
    
    include("connect_db.php");
    $table1='passwords';
    $table2='airplanes';
    $amano="940276";
    $id="1";
    
    // sending query ===========================================================
    
    $result = mysql_query("SELECT * FROM $table2
    WHERE id='$id'") or die(mysql_error());  
    
    if (!$result) {
        die("Query to show fields from table failed");
    }
    
    $num_rows = mysql_num_rows($result);
    echo "$num_rows";
    
    ?>
    
    <form action="display1_airplanes.php" method="post"> 
    ID #: <input type="text" name="id" size="6">
    AMA #: <input name="ama" type="text" size="6"><br>
    Model Name: <input name="model_name" type="text" size="30"><br>
    Model Mfg: <input name="model_mfg" type="text" size="30"><br>
    Wingspan: <input name="wingspan" type="text" size="6"><br>
    Engine: <input name="engine" type="text" size="30"><br>
    Decibels: <input name="decibels" type="text" size="6"><br>
    
    <input type="submit" value="Send"> 
    </form> 
    </body> 
    </html> 
    
    

     

     

  4. Before I pull my hair out, can I:

     

    form1.html

     

    Retrieve 1 record, 5 columns from the db

    Display that data in a form

    Allow the user to change any of the column data on the form

    Use form action update.php, method post

     

    update.php

     

    use $_POST to capture variables

    update db

     

    My main concern is if the retrieved data will be displayed on the form.

     

    Thanks

     

     

  5. I am trying to write a password script and don't want to impose on the Forum any more than I have to. So I was going to search all the threads. But as you say, it doesn't appear I can because it returns every thread with the word password in it.

     

    I have written something that I know is bad code but it almost works. I have posted another thread (Wish php had a goto statement) so I won't repeat it here.

     

    Maybe you could take a look at it.

     

    Thanks,

     

    Curtis

  6. I am reading the table passwords to see if the password exists. If true then read the table airplanes and output a table with the data. If the password is not in the table, then output msg AMA Number Not Found. All of this works.

     

    My problem is if it does not find the password, it echos the msg, but it also echos the talble headers. I would like to goto end, skip the echo of the table if it does not find the password. Just can't figure out how to do it.

     

    <html>
    <head>
    </head>
    <body>
    <?php
    // Connect to database=====================================================
    
    include("connect_db.php"); 
    $table1='passwords';
    $table2='airplanes';
    
    // Retrieve form data ======================================================
    
    $amano = $_POST['amano']; 
    
    // Send password query ===========================================================
    
    $result = mysql_query("SELECT * FROM $table1
    WHERE ama='$amano'") or die(mysql_error());  
    
    if (!$result) {
        die("Query to show fields from table failed");
    }
    
    // Check if AMA number found in password file =============================
    
    $num=mysql_numrows($result);
    if ($num==0) {
    echo "AMA Number Not Found";
    } else {
    echo "Record Found";
    }
    
    // Send airplanes query ===========================================
    
    $result = mysql_query("SELECT * FROM $table2
    WHERE ama='$amano'") or die(mysql_error());  
    
    if (!$result) {
        die("Query to show fields from table failed");
    }
    
    echo "<table border='10' cellpadding='3' cellspacing='2'>";
    echo "<p>Airplanes for Joe Blow</p><br>";
    
    echo "<tr> <th>ID</th> <th>AMA #</th> <th>Model Name</th> <th>Model MFG</th><th>Wingspan</th><th>Engine</th><th>Decibels</th></tr>";
    
    // keeps getting the next row until there are no more to get ================
    
    while($row = mysql_fetch_array( $result )) {
    
    // Print out the contents of each row into a table ==========================
    
    echo "<tr><td>";
    echo $row['id'];
    echo "</td><td>"; 
    echo $row['ama'];
    echo "</td><td>"; 
    echo $row['model_name'];
    echo "</td><td>"; 
    echo $row['model_mfg'];
    echo "</td><td>"; 
    echo $row['wingspan'];
    echo "</td><td>"; 
    echo $row['engine'];
    echo "</td><td>"; 
    echo $row['decibels'];
    echo "</td></tr>"; 
    } 
    
    echo "</table>";
    ?>
    <br>
    Put something here.
    <body>
    </html>
    

     

    Thanks,

     

    Curtis

     

     

     

     

  7. This is what I ended up with and it seems to work well.

     

    <html>
    <head>
    </head>
    <body>
    <?php
    // Connect to database=====================================================
    
    include("connect_db.php"); 
    $table='airplanes';
    
    // retrieve form data ======================================================
    
    $amano = $_POST['amano']; 
    
    // sending query ===========================================================
    
    $result = mysql_query("SELECT * FROM $table
    WHERE ama='$amano'") or die(mysql_error());  
    
    if (!$result) {
        die("Query to show fields from table failed");
    }
    
    echo "<table border='10' cellpadding='3' cellspacing='2'>";
    echo "<p>Airplanes for Joe Blow</p><br>";
    
    echo "<tr> <th>ID</th> <th>AMA #</th> <th>Model Name</th> <th>Model MFG</th><th>Wingspan</th><th>Engine</th><th>Decibels</th></tr>";
    
    // keeps getting the next row until there are no more to get ================
    
    while($row = mysql_fetch_array( $result )) {
    
    // Print out the contents of each row into a table ==========================
    
    echo "<tr><td>";
    echo $row['id'];
    echo "</td><td>"; 
    echo $row['ama'];
    echo "</td><td>"; 
    echo $row['model_name'];
    echo "</td><td>"; 
    echo $row['model_mfg'];
    echo "</td><td>"; 
    echo $row['wingspan'];
    echo "</td><td>"; 
    echo $row['engine'];
    echo "</td><td>"; 
    echo $row['decibels'];
    echo "</td></tr>"; 
    } 
    
    echo "</table>";
    ?>
    <br>
    Put something here.
    <body>
    </html>
    

     

    This program will display all the entries for the AMA Number entered. Now I need 3 more programs:

     

    1. Delete an ID number.

    2. Add a new entry.

    3. Update an ID number. Suspect this will be the most difficult.

     

    This stuff is addictive. I need to go work on my airplanes.

  8. Pikachu:

     

    Finally after hours and hours I got the basics to working like I want it. Never would have got it without your help. Now I need to do some error checking and other stuff.

     

    Would you be interested in  reviewing it and offering your expert comments on what I have done?

     

    Thanks a bunch!

  9. I can't believe it. I have pulled my hair out. I am an old time cobol/rpg/fortran programmer. Just a novice with HTML and javascript but I usually can get it to work. I know the kind of things to look for but this one has stumped me......till you posted this:

     

    Parse error:  You forgot your semi-colon after your $amano variable declaration.

     

    It works fine. Now I will try to pass the variable to php from a Form.

     

    Thank you so much. I have tried several forums but this is the first one where the participants are serious rather than flaming a novice.

     

  10. <html>
    <head>
    <title>MySQL Table Viewer
    </title>
    </head>
    <body>
    <?php
    // Connect to database=============================
    
    include("connect_db.php");
    $amano='123456'
    
    $query = "SELECT `ama` FROM `airplanes` WHERE `ama` = '$amano'"; // does't work
    // $query = "SELECT `ama` FROM `airplanes` WHERE `ama` = '123456'"; // works, returns 1 result
    // $query = "SELECT `field` FROM `table` WHERE `some_field` = 'some_value'";
    if( $result = mysql_query($query) ) {
    if( mysql_num_rows($result) > 0 ) {
    echo 'Query ran successfully and returned ' . mysql_num_rows($result) . 'results.';
    } else {
    echo 'Query ran successfully, but returned an empty result set';
    }
    } else {
    // query failed to execute
    echo "<br>Query: $query<br>Produced error: " . mysql_error() . '<br>';
    }
    
    ?>
    </body>
    </html>
    

  11. I guess I just do not understand. Tried this:

    <?php
    include("connect_db.php");
    $amano='123456'
    
    $query = "SELECT `ama` FROM `airplanes` WHERE `ama` = '$amano'"; // doesn't work
    // $query = "SELECT `ama` FROM `airplanes` WHERE `ama` = '123456'"; // works, returns 1 result
    // $query = "SELECT `field` FROM `table` WHERE `some_field` = 'some_value'";
    

  12. I am brand new to mysql and php but I have created a database and loaded two tables using cPanel and phpMyAdmin. Now I need some programs to access my data. I have a couple of simple ones that work, but I can't figure out what I really need,

     

    I am trying to Select a table Where the Value is a $variable, not a fixed value.

     

    Of course the end result will be to pass the value from a Form, but I have to get this to work first.

     

     

     

    <?php
    
    // Connect to database=============================
    include("connect_db.php"); 
    $table='airplanes';
    $amano='123456'
    $iden='1'
    
    // Send query ===========================================================
    // $result = mysql_query("SELECT * FROM {$table} where ama='123456'"); == this works
    // $result = mysql_query("SELECT * FROM {$table} where ama='940276'"); == this works
    // $result = mysql_query("SELECT * FROM {$table} where id='1'"); // this works
    // $result = mysql_query("SELECT * FROM {$table} where id = '{$iden}'"); == doesnt work
    // $result = mysql_query("SELECT * FROM {$table} where id = $iden"); == doesnt work
    // $result = mysql_query("SELECT * FROM {$table} where id = ($iden)"); // == doesnt work
    // $result = mysql_query("SELECT * FROM {$table} where id = $iden"); // == doesnt work
    // $result = mysql_query("SELECT * FROM {$table} where ama='$amano'"); // == doesnt work
    $result = mysql_query("SELECT * FROM {$table} where ama=($amano)"); // == doesnt work
    

     

    Thanks

     

     

  13. I have a decent site running using html and javascript. I am moving to a host that supports mysql and php and want to incorporate those features.

     

    I have a Members Table which I maintain and is hard coded using html. Now I want to change it where the Member User has the ability to maintain his own information.

     

    I basically understand the coding to create the database, the table and to insert and/or change the Member Data using Form input. But I don't want to use forms.

     

    Here is what I would like to do:

     

    1.  Display the Members data using the table I currently have.

    2.  Maybe have a buttom that says "Modify Data."

    3.  Have the user enter the "ID" of the row he wants to modify. Or, could I just have him click somewhere on the row he wants to modify?

    4.  Update the database table.

    5.  Redisplay the table with the new data.

     

    I guess my problem is I don't understand how to use a table for input vs. a form.

     

    Something like the flowchart steps would be greatly appreciated.

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