Jump to content
Larry Ullman's Book Forums


  • Posts

  • Joined

  • Last visited

bnorcom's Achievements


Newbie (1/14)



  1. Tried in more simplified and straightforward way. $(document).ready(function() { $('select').on('change',function() { var returnVal = $(this).val(); var curRow = $(this).closest('tr'); curRow.find('td:eq(5)').text(returnVal); }); // end change }); // end ready Reminds me of studying a book years ago where "chaining" seemed so complicated that in order to understand an example you had to work your way back through the chain to understand. My mind back then was not set up for chaining. But I did remember a solution had a certain level of elegance which shows there is a way.
  2. To try something else. <script type="text/javascript"> $(document).ready(function() { $('select').on('change',function() { var returnVal = $(this).val(); $(this).parent('td: eq(6)').text(returnVal); }); // end change }); // end ready </script> Doesn't work. $(this) represents the selection from a list which we know works. Parent() should be theoretically the containing row. If successfully displayed a button could be included to accept/submit and another function could update the database.
  3. Since its a test a step by step procedure prevents me from biting off more than I can chew and some of the steps would be unnecessary in the final version anyway. When you're figuring something out the first time it pays to be cautious. The concern is that the event is precipitated from a selection within one of the table row's columns as in a lower level. But if looking for the current row, the jQuery search goes upward from the current location which is the way the event is set up here without using "parent" because "current row" might be more straightforward. It seemed more common sense that way than using "parent" which would start from the lesson selection and work its way back to the row it was in in an unpredictable way.
  4. The page's purpose for one thing is to let the student record the lesson he's working on. There is a lesson table with lessons for each course, each lesson having an id and name. The page is set up now to test only a single student, The last two columns o the page's table are the current id being studied and a lesson list for the particular cours. echo "<td align='center' id='progress'>" . $row['headway'] . "</td>"; $course = $row['crsnum']; $sqlL = "SELECT coursenum, lessonid, lessonname FROM lesson WHERE coursenum = $course"; if ($occurs = mysqli_query($dbc,$sqlL)) { if (mysqli_num_rows($occurs) > 0) { echo '<td> <select> <option value="">select</option>'; while($row = mysqli_fetch_array($occurs, MYSQLI_ASSOC)) { echo '<option value="' . $row['lessonid'] . '">'; echo $row['lessonname'] . '</option>'; } // EndW Listing echo '</select></td></tr>'; When a lesson is selected the "work" column (id=progress) should be updated and later the student's course record will be updated. Once the table's column is updated the field should be available to update the database.
  5. I need to carry this further by traversing the DOM and don't know the trick. I have to update a column in the table with the selected data. This is my first try which doesn't work. <script type="text/javascript"> $(document).ready(function() { $('select').on('change',function() { var returnVal = $(this).val(); var curRow = $(this).closest('tr'); curRow.('td: eq(6)').text(returnVal); }); // end change }); // end ready </script> $(this) is the selection from the "subtable" in the column which should be able to find the current row. From there it should be easy to find the right column. But that's easier said than done.
  6. That was the reason. At the start I thought it was in the event, but discovered by an Alert that it was elsewhere. Your answer put the icing on the cake.
  7. I've created an EMS system and the latest page is to let a user mark his progress by choosing a chapter from a list echoed into a table from a mysql database. I've used on.change successfully before but the syntax here is different and not working. The event handler and page is displayed at www.biblebookletschool.com/sessionprogress.php. Perhaps you've solved this problem before. <script type="text/javascript"> $(document).ready(function() { $(document).on('change','option',function() { var returnval = $(this).val(); $('#hway').val(returnval); }); // end change }); // end ready </script> $sql = "SELECT recnum,usernum,crsnum,pernum,DATE_FORMAT(signdte, '%m %d %Y') AS dte,status,headway FROM session WHERE usernum = 1"; if ($result = mysqli_query($dbc,$sql)) { if (mysqli_num_rows($result) > 0) { while($row = mysqli_fetch_array($result, MYSQLI_ASSOC)) { echo "<tr><td align='center'>" . $row['crsnum'] . "</td>"; echo "<td align='center'>" . $row['pernum'] . "</td>"; echo "<td>" . $row['dte'] . "</td>"; echo "<td align='center'>" . $row['status'] . "</td>"; echo "<td>" . $inA . $row['recnum'] . $inB . "</td>"; echo "<td align='center' id='progress'>" . $row['headway'] . "</td>"; $course = $row['crsnum']; $sqlL = "SELECT coursenum, lessonid, lessonname FROM lesson WHERE coursenum = $course"; if ($occurs = mysqli_query($dbc,$sqlL)) { if (mysqli_num_rows($occurs) > 0) { echo '<td> <select> <option value="">select</option>'; while($row = mysqli_fetch_array($occurs, MYSQLI_ASSOC)) { echo '<option value="' . $row['lessonid'] . '">'; echo $row['lessonname'] . '</option>'; } // EndW Listing echo '</select></td></tr>'; } else { echo 'No records found.'; } // End ROWS } else { echo 'Error: ' . $sql . '<br>' . mysqli_error($dbc); } // End QUERY } // EndW Tabling echo '</tbody></table>'; echo "<div id='hway'>9</div>";
  8. Created a contact form based on all the forms instruction you've provided. On page 650 you talk about setting SMTP. My web host had a setting of "localhost" and "port 25" so there was an error. They opened a ticket so they could put the proper mail server address in their php.ini (I wonder why it wasn't set properly in the first place). You talk about restarting the server after making the setting change. It seems that a client/user couldn't fix php.ini himself anyway, and a host doesn't reboot his server just any old time he wants to make a change. But apparently the program based upon your example would have worked if the setting was correct. Is there anything else I have to make sure is set properly with the web host before I continue?
  9. Just used a cookie and it worked the first time. Used "header" to redirect which raises one question. In your examples you use the absolute path. You'd think if the destination was in the same directory that you could just address that page instead all the way from the root. Discovered from reading In your book about sessions that the browser itself handles the back and forth transferring of the cookie. I suppose there's a lot to learn about all the things browsers do. A subtle question in my earlier request had to do with getElementById and jQuery. I was wondering if PHP existed mostly in its own world and would interact with JavaScript and JQuery just like HTML, or maybe it had certain relationships built in developmentwise.
  10. Thanks for the answers. Since I've never used cookies I just have the idea of the word in my mind that it's just simple for misc things. In Asp.Net I used sessions and the cache which seem more solid. So when I saw an author using Header I thought he was going to a more secure level by having more control by passing the data that way even though I was thinking it still wasn`t very secure. So I'll start studying sessions to go for more security. I'll keep in mind that cookies aren't just floating around if you can find them.
  11. One question leads to another. Script 12:1 posts to itself with <form action='login.php'>. Then if successful there is setcookie('user_id', $userid). But a cookie is on the client, so when redirected to loggedin.php (script 12:4) there is "if(!isset($_COOKIE['user_id]))" which means the client has passed the cookie to the php server for the test. I read somewhere that the user id value can be passed in a querystring with "header('Location: whereto.php?user_id' .$userid);" Then a cookie is unnecessary because of "$user_id=$_REQUEST['user_id]" Cookies probably aren't that secure, but I suppose parameters being passed aren't either. That is why you say on page 404 "for most web apps use sessions."
  12. I tested according to the book's example and it worked the first time. I thought there might be duplicate emails so it made sense to search for both email and password at the same time. It occurred to me that PASSWORD_DEFAULT would use different salt codes each time and I'm happy to find out my logic is working. What's helped me with validation is jquery.validate.min.js and jquery.validate.password.js so thought I'd pass it on. But I must say the bootstrap-navbar css you use would take some study to fully understand it. Do large groups of people use all of that as if it's an industry standard? Also your other book with sticky forms uses the syntax <input name='eaddr' type='email' id='eaddr' value='<?php print $eaddr; ?>'> However I encountered in another book <a href='<?php echo $email; ?>> etc. Are the commands echo and print exactly synonymous so is it just a matter of programmers' preference? Here they save directly in the value property via the php script. But in JavaScript you'd use getElementById, or with jQuery via Ajax responding to an event, you could use $('#eaddr').val(obj.eaddr). However you can't "call" an event so php's echo/print becomes more powerful than it's nomenclature connotes. Also I read about Immediately Invoked Function Expressions. But since php has server-side interpreter scripting it seems that an IIFE would be unnecessary.
  13. OOPS. There's a typo in the above sql stmt of an extra $pwd= that shouldn't be there.
  14. Chapter 13's login_functions.inc.php uses: $q = "SELECT user_id, first_name FROM users WHERE email = '$e'"; if(password_verify($p,$row['pass'])) I coded something different which should be the same: $eaddr = filter_input(INPUT_POST, 'eaddr', FILTER_SANITIZE_EMAIL); $pwdkey = filter_input(INPUT_POST, 'pwdkey', FILTER_SANITIZE_STRING); $pwd = password_hash($pwdkey, PASSWORD_DEFAULT); $sql = "SELECT user FROM student WHERE eaddr='" . $eaddr. "' AND pwdkey='" .$pwd='" .$pwd. "'"; if($result = mysqli_query($dbc,$sql)) I have to test it more ,but since the query didn't return any rows, it makes me think that a hashed form input being compared to a 256 byte hashed data field in the database is too much to ask. Perhaps your approach is less intensive and/or easier.
  15. In the beginning it seemed to me that PHP was creatively free-form. In Applesoft Basic they progressed to top-down design and ASP.Net has serverside processing and ViewState. In a PHP book I read an author saying "a script that submits to itself means . . . you're not going to get a true MVC pattern. You might need to simply accept that PHP is often going to cause you to sacrifice really clean MVC at the altar of getting things done." I guess that means that a PHP shop doesn't necessarily have an industry standard as long as it works.
  • Create New...