Jump to content
Killersites Forums


  • Posts

  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

JeffH13's Achievements


Newbie (1/14)



  1. Thanks I'll give it a try tonight hopefully...
  2. Ben, I based my view edit delete add off of your forum topic. http://www.killersites.com/community/index.php?/topic/1969-basic-php-system-vieweditdeleteadd-records/ I was able to incorporate the Dropdowns on the new page how would approach placing the drop down in the edit page. I want to show what the current selection is but also show the possibilities per field. I'm converting an old MS Access database that we are using. This is a screen shot of that. Thanks any guidance you can give me would be greatly appreciated. Thanks!!
  3. Sorry Ben that not what I was trying to say but I do understand how you came up with that. Ok me try this again. The page I have I'm entering new data, the field "msdstype" I want to limit the the field options so I created a dropdown. But once that dropped has been select which is coming from a different table called typeinfo and the field from that table is called typename. How do i get that value that has been selected to be placed in the database.
  4. My first attempt to create dropdown box. I was able to get the information to correct show up but I'm a little confused on how to transfer it. Here is the old line of code where I hand type in information <td width="100" height="27" align="center" valign="top" bgcolor="#FFFFFF" class="style20"><input type="text" name="msdstype" value="<?php echo $msdstype; ?>"/></td> I have created this dropdown box which does show the values available. <select name="dropdown"> <?php typequery() ?> </select> But after the value is selected and I go to enter next field I want that value to go into "msdstype" Thanks any insight will be helpful.
  5. I agree is sounds easy I just learning the code and how it is written compared how I think. The Submit area: <table wi:th="450" border="0" cellspacing="0" cellpadding="10"> <tr> <td align="center"> <input type="submit" name="submit" value="Add-Another"></td> <td> </td> <td align="center"> <input type="submit" name="submit" value="Submit"></td> </tr> </table> The Post and redirect area: if (isset($_POST['submit'])) { // get form data, making sure it is valid $rlyear = mysql_real_escape_string(htmlspecialchars($_POST['rlyear'])); $rlplayername = mysql_real_escape_string(htmlspecialchars($_POST['rlplayername'])); $rlcarries = mysql_real_escape_string(htmlspecialchars($_POST['rlcarries'])); $rlyards = mysql_real_escape_string(htmlspecialchars($_POST['rlyards'])); $rlavg = mysql_real_escape_string(htmlspecialchars($_POST['rlavg'])); $rltd = mysql_real_escape_string(htmlspecialchars($_POST['rltd'])); // check to make sure all fields are entered if ($rlyear == '' || $rlplayername == '' || $rlcarries == '' || $rlyards == '' || $rlavg == '' || $rltd == '') { // generate error message $error = 'ERROR: Please fill in all required fields!'; // if either field is blank, display the form again renderForm($rlyear, $rlplayername, $rlcarries, $rlyards, $rlavg, $rltd, $error); } else { // save the data to the database mysql_query("INSERT rushingleaders SET rlyear='$rlyear', rlplayername='$rlplayername', rlcarries='$rlcarries', rlyards='$rlyards', rlavg='$rlavg', rltd='$rltd'") or die(mysql_error()); // once saved, redirect back to the view page header("Location: rushingleaders-view-paginated.php"); } } else I figure that I need to write an if else statement here: // once saved, redirect back to the view page header("Location: rushingleaders-view-paginated.php"); Not really sure how? Thanks.
  6. Hi Ben, Thanks this was great. I learned a lot. I was wonder how to set it up on the new.php so that you have a choice. 1. Submit and go back to view.php 2. Submit and go to new.php to add another record. Thanks I really do appreciated the time and effort that was put into this.
  7. OMG.... How stupid... Sorry... Need to stop trying to do this after no sleep.. Thanks again... Works great...
  8. Thanks Ben... I got past that point. I knew it had to be something stupid... Now if I can get past this it would be great... I click on records to be edit it brings up this screen. This is what i change it to. This is what comes up after I hit submit. Ok I'm kinda at a lost... Thank for all your help.
  9. Ben, Any other ideas?? It must be something simple or stupid. I get the same error message on the delete.php also...
  10. So sorry... Internet was funny last night... My whole home network was doing strange things.... Thanks for post and updates... Sorry again...
  11. This will be the forth try to reply to this post. The error message shows up when I open the page. I have checked the spelling of fields and theses are correct...
  12. I get the error message when I open the page. Here is an image of my database. Thanks for your help...
  13. I was working with this topic. http://www.killersites.com/community/index.php?/topic/1969-basic-php-system-vieweditdeleteadd-records/ Which I found very helpful. I was able to get the view, view-page and new to work. But I'm getting an error on edit and delete. Here is the error I'm getting. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 Here is my code... <?php /* EDIT.PHP Allows user to edit specific entry in database */ // creates the edit record form // since this form is used multiple times in this file, I have made it a function that is easily reusable function renderForm($cwid, $cwyears, $cwname, $cwwins, $cwlosses, $cwties, $cwpercent, $error) { ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>Edit Coach Wins Record</title> </head> <body> <?php // if there are any errors, display them if ($error != '') { echo '<div style="padding:4px; border:1px solid red; color:red;">'.$error.'</div>'; } ?> <form action="" method="post"> <input type="hidden" name="cwid" value="<?php echo $cwid; ?>"/> <div> <p><strong>ID:</strong> <?php echo $cwid; ?></p> <strong>Years: *</strong> <input type="text" name="cwyears" value="<?php echo $cwyears; ?>"/><br/> <strong>Coach Name: *</strong> <input type="text" name="cwname" value="<?php echo $cwname; ?>"/><br/> <strong>Wins: *</strong> <input type="text" name="cwname" value="<?php echo $cwwins; ?>"/><br/> <strong>Losses: *</strong> <input type="text" name="cwname" value="<?php echo $cwlosses; ?>"/><br/> <strong>Ties: *</strong> <input type="text" name="cwname" value="<?php echo $cwties; ?>"/><br/> <strong>Percent: *</strong> <input type="text" name="cwname" value="<?php echo $cwpercent; ?>"/><br/> <p>* Required</p> <input type="submit" name="submit" value="Submit"> </div> </form> </body> </html> <?php } // connect to the database include('connect-db.php'); // check if the form has been submitted. If it has, process the form and save it to the database if (isset($_POST['submit'])) { // confirm that the 'id' value is a valid integer before getting the form data if (is_numeric($_POST['cwid'])) { // get form data, making sure it is valid $id = $_POST['cwid']; $cwyears = mysql_real_escape_string(htmlspecialchars($_POST['cwyears'])); $cwname = mysql_real_escape_string(htmlspecialchars($_POST['cwname'])); $cwwins = mysql_real_escape_string(htmlspecialchars($_POST['cwwins'])); $cwlosses = mysql_real_escape_string(htmlspecialchars($_POST['cwlosses'])); $cwties = mysql_real_escape_string(htmlspecialchars($_POST['cwties'])); $cwpercent = mysql_real_escape_string(htmlspecialchars($_POST['cwpercent'])); // check that firstname/lastname fields are both filled in if ($cwyears == '' || $cwname == '' || $cwwins == '' || $cwlosses == '' || $cwties == '' || $cwpercent == '') { // generate error message $error = 'ERROR: Please fill in all required fields!'; //error, display form renderForm($cwid, $cwyears, $cwname, $cwwins, $cwlosses, $cwties, $cwpercent, $error); } else { // save the data to the database mysql_query("UPDATE coachwin SET cwyears='$cwyears', cwname='$cwname', cwwins='$cwwins', cwlosses='$cwlosses', cwties='$cwties', cwpercent='$cwpercent' WHERE cwid='$cwid'") or die(mysql_error()); // once saved, redirect back to the view page header("Location: coachwin-view.php"); } } else { // if the 'id' isn't valid, display an error echo 'Error!'; } } else // if the form hasn't been submitted, get the data from the db and display the form { // get the 'id' value from the URL (if it exists), making sure that it is valid (checing that it is numeric/larger than 0) if (isset($_GET['cwid']) && is_numeric($_GET['cwid']) && $_GET['cwid'] > 0) { // query db $id = $_GET['cwid']; $result = mysql_query("SELECT * FROM coachwin WHERE cwid=$cwid") or die(mysql_error()); $row = mysql_fetch_array($result); // check that the 'id' matches up with a row in the databse if($row) { // get data from db $cwyears = $row['cwyears']; $cwname = $row['cwname']; $cwwins = $row['cwwins']; $cwlosses = $row['cwlosses']; $cwties = $row['cwties']; $cwpercent = $row['cwpercent']; // show form renderForm($cwid, $cwyears, $cwname, $cwwins, $cwlosses, $cwties, $cwpercent, ''); } else // if no match, display result { echo "No results!"; } } else // if the 'id' in the URL isn't valid, or if there is no 'id' value, display an error { echo 'Error!'; } } ?> Any help would be greatly appreciated...
  • Create New...