Jump to content


  • Posts

  • Joined

  • Last visited


About suttercain

  • Birthday 04/01/1978

Contact Methods

  • Website URL

Profile Information

  • Gender
  • Location
    San Dimas, CA

suttercain's Achievements

Advanced Member

Advanced Member (4/5)



  1. Right now it's simply echo "Hello!"; But I will change this to a mysql SELECT query and display the inputs of the most recent record to reflect the form inputs.
  2. Hi everyone, I hame a basic web application which uses jQuery to add a first name and last name to a MySQL database via AJAX. This part works. But what I would like to happen after they click submit and the data is added; is for a div to output the records, via ajax, from the database table so they can see the new record. So they add their name and last name to the form, click submit, it's added to the database via AJAX (this part works, then below the form in a div the new record would display. The last part has got me stuck. <script src="js/jquery-1.2.6.js" type="text/javascript"></script> <script type="text/javascript"> $(document).ready(function(){ $("form#submit").submit(function() { // we want to store the values from the form input box, then send via ajax below var fname = $('#fname').attr('value'); var lname = $('#lname').attr('value'); $.ajax({ type: "POST", url: "ajax.php", data: "fname="+ fname +"& lname="+ lname, success: function(){ /*$(function(){$('div.success').fadeIn();});*/ <--Works for static content $('div.success').load("echo.php"); <--thought this would work, doesn't... } }); return false; }); }); </script> //THE FORM & DIV WHERE I WOULD LIKE THE NEW RECORD(S) TO DISPLAY <div class="container"> <form id="submit" method="post"> <fieldset> <legend>Enter Information</legend> <label for="fname">Client First Name:</label> <input id="fname" class="text" name="fname" size="20" type="text"> <label for="lname">Client Last Name:</label> <input id="lname" class="text" name="lname" size="20" type="text"> <button class="button positive"><img src="images/butup.gif" alt=""></button> </fieldset> </form> </div> <div class="success" style="display: none;">sd</div> I thought the load after a success was returned would work, but no luck. Any ideas? Thanks.
  3. Hi everyone, I need to be able to show a new form field based on an option selected in the select menu. The show works fine, but when I select another option the revealed form field (div) won't hide. Any ideas? <script type="text/javascript"> $(document).ready(function(){ $("#parent1").css("display","none"); $("#reveal_add").click(function(){ if ($('option[name=add_mfr]:selected').val() == "add_new" ) { $("#parent1").slideDown("fast"); //Slide Down Effect } else { $("#parent1").slideUp("fast"); //Slide Up Effect } }); }); </script>
  4. Hi everyone, Please bear with me as I try and write this in a concise manner. I have three tables: TABLE A | group | name | ---------------------- | 1 | Yellow | | 2 | Yellow | | 3 | Blue | ---------------------- TABLE B | group | code | date_created | --------------------------------------- | 1 | j7uw | 2009-10-10 | 1 | op0i | 2009-10-10 | 1 | hw7i | 2009-10-09 | 1 | usp1 | 2009-10-10 | 2 | eiu2 | 2010-07-21 | 2 | y9oi | 2009-12-25 | 2 | j7uw | 2009-12-25 --------------------------------------- TABLE C | code | size | ------------------ | j7uw | Large | op0i | Large | hw7i | Medium | usp1 | Small | eiu2 | Medium | y9oi | XLarge | j7uw | Large ------------------ What I'm doing is an INNER JOIN on these tables: SELECT * FROM table_a INNER JOIN table_b (table_a.group = table_b.group) INNER JOIN table_c (table_b.code = table_c.code) WHERE table_b.group = 1 With the above query I'll get this expected output: | 1 | j7uw | 2009-10-10 | Yellow | Large | 1 | op0i | 2009-10-10 | Yellow | Large | 1 | hw7i | 2009-10-09 | Yellow | Medium | 1 | usp1 | 2009-10-10 | Yellow | Small My desired results however are only the MOST RECENT date_created from the date column based on the selected group. Meaning, I'd like to get these results instead: | 1 | j7uw | 2009-10-10 | Yellow | Large | 1 | op0i | 2009-10-10 | Yellow | Large | 1 | usp1 | 2009-10-10 | Yellow | Small Because the other date was October, 9 2009 and "newer" date(s) have occured within that group, that record(s) will be omitted. So if tomorrow a new record is added with GROUP 1 and a date of 2009-10-11, only that newest record will appear. There may also be multiple records with the same date and group and I need them all to display. Any ideas? Thanks ahead of time. -SC
  5. Hi Premiso, I changed the extension column over to integer and am still having an issue, I think because of the group clause. Here is the SQL statement: "SELECT *, MAX(eo_engine_family.executive_order_extension) AS ext FROM executive_order INNER JOIN eo_engine_family ON ( executive_order.executive_order = eo_engine_family.executive_order_new ) INNER JOIN engine_family_offroad_cal ON ( eo_engine_family.engine_family_name = engine_family_offroad_cal.engine_family_name ) WHERE executive_order.date_eo_rescinded IS NULL AND executive_order.date_eo_rescinded IS NULL AND eo_engine_family.engine_family_name = '".$engine_family_name."' eo_engine_family.id ORDER BY engine_year This is outputting ALL results and not just the "highest" value in the extension column. Thanks in advance. -SC
  6. Hi everyone, I have a table set up as such: name | extension | id de01 | NULL | 1 de01 | NULL | 2 de01 | 01 | 3 de01 | NULL | 4 de01 | 01 | 5 de01 | 02 | 6 de01 | 02 | 7 What I am trying to do is output only the records with the highest value in the "extension" column. So based on the table above I would like to output the following: de01 | 02 | 6 de01 | 02 | 7 Additionally, this would have to be a query that can handle higher extensions that may be entered in the future. Example: if a new record was added that contained de01 | 03, that would now need to be shown and the previous two de01 | 02 records would no longer show up. I tried MAX() but I can't seem to get it to function that way I need it. Thanks in advance for your time.
  7. I switched the type to decimal and it converted all the data to whole numbers?!?!?
  8. Hi everyone, I have a column which stores a total price (i.e. 15.81). Using the following query, what should the column type be? Decimal, Float, Double? Right now I have it set to varchar and the following query won't work with it this way. SELECT * FROM accounts WHERE totalPrice <= '15.81' Thanks.
  9. Hi everyone, I have a column with the following records: UCLA YALE HARVARD USC I want USC to always appear first, or outputted at the top of the list. If I ORDER BY it will alphabetize the results and I won't get the desired result. I looked into using CASE but couldn't get it. Does anyone know a way to have a specified result appear at the top of the list all the time? Thanks!
  10. Oh man.. SHOW is a reserved word.. DOH! Thanks so much... agree w/ the addslashes, this is someone else's code and I'm not going to step on their feet Thanks again.
  11. Hi everyone, I've spent nearly two hours on this and am going mad. I am trying to do a basic update, which I've done millions of times, but one line of code kicks me out an error. See two slightly different scripts below. The first one works if I take out one column, the second one doesn't work if I attempt to update the column. WORKS: $sql = "UPDATE theater SET ". "Date='".$Date."',". "EventType='".addslashes($EventType)."',". "City='".addslashes($City)."',". "Venue='".addslashes($Venue)."',". "URL='".addslashes($URL)."'". " WHERE id=$id"; DOESN'T WORK $sql = "UPDATE theater SET ". "Date='".$Date."',". "EventType='".addslashes($EventType)."',". "Show='".addslashes($Show)."',". // <--This line prevents it from working... "City='".addslashes($City)."',". "Venue='".addslashes($Venue)."',". "URL='".addslashes($URL)."'". " WHERE id=$id"; The error: 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 'Show='test',City='City1',Venue='Venue1',URL='Tickets1' WHERE id=2' at line 1 Thanks in advance for the help.
  12. I've never used the MySQL LEFT() function before, so I apologize in advance. Here is a very basic script I write while experimenting with this: $q4 = $_POST['q4']; $q5 = $_POST['q5']; $q6 = $_POST['q6']; $q7 = $_POST['q7']; $q8 = $_POST['q8']; $allTogether = $q4.$q5.$q6.$q7.$q8; $sql = "SELECT * FROM tableA INNER JOIN hhdd_small ON ( tableA.link_id = tanleB.link_id ) WHERE tableB.selection = '".$q4.$q5.$q6.$q7.$q8."'"; echo "<ul>"; $reults = mysql_query($sql) or die(mysql_error()); while ($row = mysql_fetch_array($reults)) { echo "<li>".$row['title']."</li>"; } echo "</ul>"; How would I use LEFT() to accomplish what you suggested? Thanks.
  13. HI everyone, I have pleaded with the manager that this is a horrible table, but he won't listen. So now I'm left with this layout. There is a form with 5 questions, all of which are radio buttons. Depending on the radio button selected, the value will change. Question 4 = q4 (contains either value A, B, C) Question 5 = q5 (contains either value D, E) Question 6 = q6 (contains either value F, G, H, I) Question 7 = q7 (contains either value J, K) Question 8 = q8 (contains either value L, M) The MySQL Table is as follows. The left column is the values of the radio buttons from the form, and each number is an answer. SELECTIONS | LINKS A 5 BD 34 BE 3 CDFJL 1234 CDFJM 34 CDFKL 134 CDFKM 34 CDGL 34 CDGM 34 CDHL 346 CDHM 346 CDIL 5 CDIM 5 CEPJL 123 CEPJM 3 CEPKL 13 CEPKM 3 CEGL 3 CEGK 3 CEHL 36 CEHM 36 CEIL 5 CEIM 5 My issue is this. If the user selects Value A and nothing else, the link will come up. If they select AD, the answer won't come up because there is no record for AD... or ADF, or ADFK and so on. Same goes for if they select BD, they'll get 34 but if they select BDF nothing will come up. Is there any logic that would solve this issue without giving all possible configurations of selected values, or without having to change the structure? Thanks.
  14. Thanks! Ya, I agree sadly there is no "end time" per say because if an id isn't added or removed from a specific date to the next, it's a continuation or a "no change." I ran the code and I got the following out put when echoing 'status_update' 3 was added 2009-09-01 - 1 was added 2009-09-01 -
  • 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.