Jump to content

suttercain

Members
  • Posts

    887
  • Joined

  • Last visited

    Never

Everything posted by suttercain

  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 -
  15. Hi Artacus, Basically need the same 'comparison' like I did before when it was between two tables, but this time using just one table. The output result of the table I posted above should state something similar to this: 2 was removed on 09-02-2009. 4 was added on 09-02-2009. 5 was added on 09-02-2009. So ya, taking the most recent date, and comparing the id's to the previous date. Comparing any changes made between the two dates and listing them similar to that of the list above. Thanks again for your time! -SC
  16. Hi everyone, Artacus was nice enough to help me with an issue last week when comparing data from two separate tables using a union. See: Original Post Now I want to do the same thing, kind of, using a single table in lieu of two tables. I need to compare id's based on the date the id was added or removed. Example of Table ------------------ | ID | Date | | 1 | 09-01-2009 | | 2 | 09-01-2009 | | 3 | 09-01-2009 | | 1 | 09-02-2009 | | 3 | 09-02-2009 | | 4 | 09-02-2009 | | 5 | 09-02-2009 | ------------------- So the MySql result would need to state: Id 2 was removed on 09-02-2009. Id 4 and 5 were added on 09-02-2009. Any help or suggestions would be greatly appreciated. Thanks in advance.
  17. Artacus, So far so good. I ran the query you provided and it echos 2 4 5. This is good because 2 and 4 were the numbers deleted and 5 was the number added. My question would now be this, is there away to echo that 2 and 4 were the numbers deleted and that 5 was the number added? Thanks!
  18. Hi everyone, I can't seem to wrap my head around a need of a current project. Let's save I have two tables, Table A and Table B, and all of the columns are identical. What I need to do is compare these two tables and find out if any of the Records were added or deleted since Table A, in table B. TABLE A ---------- | column | ---------- | 0001 | ---------- | 0002 | ---------- | 0003 | ---------- | 0004 | ---------- TABLE B ---------- | column | ---------- | 0001 | ---------- | 0003 | ---------- | 0005 | ---------- So the report I would need to see, after comparing TABLE A against TABLE B is that, Records 0002 and 0004 have been dropped, and Record 0005 has been added. Does anyone know the best way to approach this? Thanks. -SC
  19. Hi Axeia, I gave it a go and sadly it didn't work. The "show" still worked fine but when selecting a different radio button the DIV did not hide. Anyone else know of a possible solution? Thanks.
  20. Hi everyone, I want to be able to show a div cotnainer based on the radio button selected. Example 3 options Yes, No, Don't Know. If yes is clicked a DIV is hown (I have this part working), but if Yes is clicked and the user changes it to No or Don't Know, I want to hide that DIV. This is the part I don't have working, the hide. Here is the code I am using that work with show, but not hide. $("#14a").click(function(){ // If checked if ($("#14a").is(":radio")) { //show the hidden div $("#extra").show("fast"); } else { //otherwise, hide it $("#extra").hide("fast"); } }); <input id="14a" type="radio" name="14" value="Yes" class="style1" /> Yes<br /> <input id="14b" type="radio" name="14" value="No" class="style1" /> No<br /> <input id="14c" type="radio" name="14" value="Don't Know" class="style1" /> Don't Know <div id="extra"> <br /><label>If yes, please specify.</label> <input id="email" type="text" class="style" /> </div> Any help would be much appreciated. Thank you.
  21. Thanks Fenway, I have 6 records I am trying to query at the moment with more to be added once I validate this works. I am concerned about the "too many" statement you quoted. That's scary because people may not find what they want. "doesn't always return "everything" you would expect" makes me wonder if I should use this form of search because that seems like a big pit fall. Thanks again.
  22. Thanks Fenway. That solved that issue But now when I run the following code I don't get any results: <?php $sql = "SELECT body, title FROM faq1 WHERE MATCH (body, title) AGAINST ('vehicles')"; ?> But this code does work, but is not a full-text search: <?php $sql = "SELECT * FROM faq1 WHERE title LIKE '%Vehicles%'"; ?> What am I doing wrong in the first query statement? Thanks again!
×
×
  • 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.