Jump to content

jcjst21

Members
  • Posts

    37
  • Joined

  • Last visited

    Never

Everything posted by jcjst21

  1. I tried what you suggested and it changed everything to a 1... then I switched up the numbers to set it equal to something else and nothing was updated... here's my current code... //fix data $select=mysql_query("SELECT campGroupAssignments.camperID, campGroupAssignments.campGroupID, CamperMedicationInfo.camperGroupID FROM campGroupAssignments LEFT JOIN CamperMedicationInfo ON campGroupAssignments.camperID=CamperMedicationInfo.camperID WHERE campGroupID=2"); while($result=mysql_fetch_array($select)) { $update=mysql_query("UPDATE CamperMedicationInfo SET camperGroupID=2 WHERE campGroupID=2"); }
  2. Hi: My Update query below; is not updating either at ALL or it updates all records to the same number... Could someone please take a look and give me any suggestions? Thanks $select=mysql_query("SELECT campGroupAssignments.camperID, campGroupAssignments.campGroupID, CamperMedicationInfo.camperGroupID FROM campGroupAssignments LEFT JOIN CamperMedicationInfo ON campGroupAssignments.camperID=CamperMedicationInfo.camperID WHERE campGroupID=3"); while($result=mysql_fetch_array($select)) { $camper=$result['camperID']; $assignments=$result['campGroupID']; $needsSet=$result['camperGroupID']; echo $camper. " " .$assignments. " " .$needsSet. "</br>"; $update=mysql_query("UPDATE CamperMedicationInfo SET $needsSet=2 WHERE $assignments=2"); }
  3. Ok then... what do I use for my value to load for a form if it already pulls the id?? the "cMedID" from the response function?
  4. Thanks for looking at this... Here is the code for my main page: $("#addADose").click(function() { var cMedName=$("#cMedName").val(); var doseAmount=$("#doseAmount").val(); var doseMeasurement=$("#doseMeasurement").val(); var quantity=$("#quantity").val(); var doseMeasurement2=$("#doseMeasurement2").val(); var Sunday = $('#Sunday').attr('checked')?1:0; var Monday = $('#Monday').attr('checked')?1:0; var Tuesday = $('#Tuesday').attr('checked')?1:0; var Wednesday = $('#Wednesday').attr('checked')?1:0; var Thursday = $('#Thursday').attr('checked')?1:0; var Friday = $('#Friday').attr('checked')?1:0; var Saturday = $('#Saturday').attr('checked')?1:0; var doseCount=$("#doseCount").val(); $.post( 'medicationInfoPost.php', { cMedName:cMedName, doseAmount:doseAmount, doseMeasurement:doseMeasurement, quantity:quantity, doseMeasurement2:doseMeasurement2, Sunday:Sunday, Monday:Monday, Tuesday:Tuesday, Wednesday:Wednesday, Thursday:Thursday, Friday:Friday, Saturday:Saturday, doseCount:doseCount }, function(response) { $("#displayMedicationInfo").load("medicationInfoPull.php"); $("#medicationNameID").val(""); $("#doseAmount").val(""); $("#medMeasureNameID").val(""); $("#quantity").val(""); $("#medMeasureNameID").val(""); $("#doseCount").val(""); $("#cMedID").val(""); $("#medID").load("getLastIDCreated.php"); $("#lastID").val($theMaxID); } Then here is the code for the page that does the mySQL insert $sql="INSERT INTO CamperMedicationInfo(userID, etc....) VALUES ('$userID', '$camperID', etc....')"; mysql_query($sql); $cMedNumber=mysql_insert_id(); Then the code that pulls the data $sql2=mysql_query("SELECT * FROM CamperMedicationInfo WHERE camperID=$camperID ORDER BY cMedID"); $maxid=mysql_query("SELECT MAX(cMedID) FROM CamperMedicationInfo WHERE camperID=$camperID"); $maxIDretrieve=mysql_fetch_array($maxid); $theMaxID=$maxIDretrieve[0];
  5. ok it's working now, BUT it's return the previously created ID... so when the id should be for instance "3", it's return "2"... i called it this way in the response function function(response) { $("#lastID").val($theMaxID); }
  6. Well I did a "POST" function on the main page to send the form data; but I want to GET the id created back... OK so use JSON...so on the main page...how would I call it...in the same response function for the button "on click" function that contains the POST function?
  7. I created a function using jquery to load data from another file to display on my main page. The user will fill out some information on the main page, and I post it to another file and perform the mysql INSERT. I would like to pass the last created id in that table back to the main page to insert it as the default value in another form on the main page... how would I do that with the jquery functions? I thought of the get function, but that didn't work:( Thanks, jcj
  8. If i did it this way where it only prints if the group id changes then how can i make a header for the group name?
  9. I'll try group concat but also, how could i indicate when the groupID changes in the while loop?
  10. I have been searching the forums to find how to group a table by ID and list each record associated with it. All I have been finding is how to group by and using it to do a sum or average or count. What I want to do is, Group By ID, and list each associated row... Example: Group A: -Person A -Person B Group B -Person C -Person D I tried multiple variations of a while loop without success... any advice?
  11. I have created a popup form to view customer data...I need to send an email from this popup page. I created a form to post data to the same popup page and when i click the submit button; it reverts completely back to the websites main index page... The form is set to "post" to another php page in my directory... I don't know why; can anyone help?
  12. Hello, I have a while loop that prints the contents of a field in one of the tables in my database. I would like the user to have the option to delete that record from the website. I created a button that is displayed with an icon image, but would like to call a php function onclick. Here is my code for the while loop generating a row in the table for each record: <table> <?php while($row = mysql_fetch_array($result)) { echo "<tr><td>" .$row['Name']. "</td><td><input type=\"image\" src=\"1340120170_edit.ico\"></td><td><input type=\"image\" src=\"1340120267_delete.ico\" onclick=\"deleteRecord(" .$row['nameID']. ")\"></td></tr>"; } mysql_close($con); ?> </table> I'm calling "deleteRecord()" from the last button..I want to pass in $row['nameID'] into the function deleteRecord().... am I setting up my echo or input statement incorrectly? Here is my deleteRecord() function: function deleteRecord(&$recordNum) { $nameID=$recordNum; $sql3=mysql_query("DELETE FROM utilityNames WHERE nameID=$nameID"); } When I click the button; nothing happens? Any advise? Thanks:) in advance.
  13. Hello, I have three scripts below that I was wondering if someone can look at as a second opinion. What they all have in common is they are supposed to append data to some tables in my database. They match the code on all my other scripts but for some reason these particular scripts will not append the data to the files. This first one... is supposed to insert the name of the doctor this person uses, and then gets the last ID created and inserts it into another table...no matter what I try, it will not do it. <?php session_start(); $userid=$_SESSION['userID']; $firstName=$_SESSION['fname']; $lastName=$_SESSION['lname']; $camperID=$_POST['camperID']; $physicianFName=$_POST['physicianFName']; $physicianLName=$_POST['physicianLName']; $physicianSuffix=$_POST['physicianSuffix']; $practiceName=$_POST['practiceName']; $physicianAddress1=$_POST['physicianAddress1']; $physicianAddress2=$_POST['physicianAddress2']; $physicianAddress3=$_POST['physicianAddress3']; $physicianCity=$_POST['physicianCity']; $physicianState=$_POST['physicianState']; $physicianZip=$_POST['physicianZip']; $physicianOfficeP=$_POST['physicianOfficeP']; $physicianOfficeF=$_POST['physicianOfficeF']; $physicianSpecialty=$_POST['physicianSpecialty']; echo $camperID. ' ' .$physicianFName. ' ' .$physicianLName; //htc information and physician $htcName=$_POST['htcInfo']; $htcPhysician=$_POST['htcPhysician']; $con=mysql_connect("xxx.xxx.xxx.xx", "xxx", "xxxx") or die ("cannot connect"); mysql_select_db("testcamp") or die ("cannot select database"); $sql="INSERT INTO Physicians(physicianFName, physicianLName, physicianSuffix, practiceName, physicianAddress1, physicianAddress2, physicianAddress3, physicianCity, physicianState, physicianZip, physicianOfficeP, physicianOfficeF, physicianSpecialty) VALUES ('$physicianFName', '$physicianLName', '$physicianSuffix', '$physicianAddress1', '$physicianAddress2', '$physicianAddress3', '$physicianCity', '$physicianState', '$physicianZip', '$physicianOfficeP', '$physicianOfficeF', '$physicianSpecialty')"; $result=mysql_query($sql,$con); $physicianID=mysql_insert_id(); $sql2="INSERT INTO CamperPhysicianInfo(physicianID, camperID) VALUES ('$physicianID', '$camperID')"; $result2=mysql_query($sql2,$con); $sql3="INSERT INTO CamperHTCInfo(camperID, htcID) VALUES ('$camperID', '$htcName')"; $result3=mysql_query($sql3,$con); $sql4="INSERT INTO camperHTCPhysicianInfo(camperID, htcPhysicianID) VALUES ('$camperID', '$htcPhysician')"; $result4=mysql_query($sql4,$con); ?> This next one...is supposed to enter data into the CamperRegistrations tables and also enter data into another table for a questionaire that was completed on the form previous to this page...same thing no matter what I try will not append data. <?php $question12=$_POST['question12']; $question12a=$_POST['question12a']; session_start(); $userid=$_SESSION['userID']; $firstName=$_SESSION['fname']; $lastName=$_SESSION['lname']; $camperID=$_SESSION['camperID']; $con=mysql_connect("xxx.xxx.xxx.xx", "xxx", "xxx") or die ("cannot connect"); mysql_select_db("testcamp") or die ("cannot select database"); $sql="INSERT INTO Question12(camperID, question12Answer, teaching) VALUES ('$camperID', '$question12', '$question12a')"; $result=mysql_query($sql,$con); $date=date("Y-m-d"); $defaultStatus=1; $sql2="INSERT INTO CamperRegistrations(userID, camperID, registrationDate, registrationStatus) VALUES ('$userid', '$camperID', '$date', '$defaultStatus')"; $result2=mysql_query($sql2,$con); ?> and then on this same page with this script... is it possible to carry session information when using HTML links instead of a submit form? I need the userid to carry to the next page with a link, but it won't do that either... Any help would be appreciated and thanks in advance for looking. ~jcjst21
  14. Thank you very much. This worked out very nicely. It is exactly what i was looking for.
  15. Thank you so much! So if I have an ajax request that continuously polls the server for price updates, like if another user bids on an item, and i want the price to automatically change... what parameter would i pass into that function? To refresh the page every 30 seconds or so?
  16. I want the user to be able to choose which one they want to update. It's basically an online bidding area. Where they pick an item to bid on and then click the "bid" button. However, when I test out the input box; the first record that displays; it allows me to place a bid, but then when I enter a bid in another listing. The button does nothing. I tried making it a form, but that didn't work before, but i forgot to take out the tags. I do not want the id field to be able to be updated, however i was using that for testing purposes for my update script. So how should i make this where when the user clicks the button and the update for that particular record is done, it will then allow me to update another listing?
  17. Hello, I have a script that displays that uses a while loop in php to display all of the records. For each record, I added an input text box with a button to update one of the fields in the record set. When I run the script only the first listing will update and the subsequent listings on the page will not update. Should I go about this set up differently? <html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <head> <?php session_start(); ?> <script language="JavaScript"> TargetDate = "11/18/2011 6:00 PM"; BackColor = "palegreen"; ForeColor = "navy"; CountActive = true; CountStepper = -1; LeadingZero = true; DisplayFormat = "%%D%% Days, %%H%% Hours, %%M%% Minutes, %%S%% Seconds."; FinishMessage = "It is finally here!"; </script> <script language="JavaScript" src="http://scripts.hashemian.com/js/countdown.js"></script> <!-- function timedRefresh(timeoutPeriod) { setTimeout("location.reload(true);",timeoutPeriod); } // --> <script type="text/JavaScript"> function showCurrentPrice(str,str1) { if (str=="") { document.getElementById("priceElement").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("priceElement").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getPrice.php?q="+str+"&s="+str1,true); xmlhttp.send(); } </script> <?php $con=mysql_connect("xxxx", "xxxx", "xxxx") or die ("cannot connect"); mysql_select_db("tab_test") or die ("cannot select database"); echo 'Welcome ' .$_SESSION['username']. '!'; echo '<br /><br /><br />'; echo '<a href="tab_logout.php">Sign Out</a>'; $result=mysql_query("SELECT treeID, treeName, treePicture, treeGiver, treeDesc, CurrentPrice FROM Trees ORDER BY treeName"); $treeID=$_POST['treeID']; $newPrice=$_POST['newBid']; $result2=mysql_query("UPDATE Trees SET CurrentPrice ='$newPrice' WHERE treeID = '$treeID'"); ?> </head> <body> <table> <tr> <td>Active Trees</td> </tr> </table> <?php while($row=mysql_fetch_array($result)) { $treeID=$row['treeID']; echo "<form>"; echo "<table>"; echo "<tr><td><img src=" .$row['treePicture']. "></td></tr>"; echo "<tr><td><input type=\"text\" name=\"treeID\" id=\"treeID\" value=\"" .$treeID. "\" /></td></tr>"; echo "<tr><td>Current Price: $" .$row['CurrentPrice']. "<div id=\"priceElement\"></div></td></tr>"; echo "<tr><td>New Bid: <input type=\"text\" id=\"newBid\" name=\"newBid\" \><button type=\"button\" name=\"bidNow\" value=\"Bid\" onclick=\"showCurrentPrice(document.getElementById('treeID').value,document.getElementById('newBid').value)\"></td></tr>"; echo "<tr><td>" .$row['treeName']. "</td></tr>"; echo "<tr><td>" .$row['treeGiver']. "</td></tr>"; echo "<tr><td>" .$row['treeDesc']. "</td></tr>"; echo "</table>"; echo "</form>"; } ?> </body> <?php mysql_close($con); ?> </html>
  18. Hello, I have two issues. I am creating a script that is a little online bidding area. I have all of my listings fetched by a while loop in PHP and then a <div></div> area to display the AJAX returned data. Problem #1: The data only updates for my first listing and not the consecutive others. Problem #2: I want the all of the listings to update periodically using AJAX, i tried using jQuery, but that didn't work out to well. I posted the code below: the treeAuctions.php file goes to the connects to the database and lists the available auction items and prices initially. It has an input box for each listing so the user can place a bid. Then the AJAX functions get information from getPrice.php and getPrices.php. I wanted to use getPrices.php to refresh the page and data every 30 seconds or so. The getprice.php file only is executed when a user places a bid. <html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <head> <?php session_start(); ?> <script type="text/JavaScript"> <!-- function timedRefresh(timeoutPeriod) { setTimeout("location.reload(true);",timeoutPeriod); } // --> function showCurrentPrice(str,str1) { if (str=="") { document.getElementById("priceElement").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("priceElement").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getPrice.php?q="+str+"&s="+str1,true); xmlhttp.send(); } </script> <?php $con=mysql_connect("xx", "xxx", "xxx") or die ("cannot connect"); mysql_select_db("tab_test") or die ("cannot select database"); echo 'Welcome ' .$_SESSION['username']. '!'; echo '<br /><br /><br />'; echo '<a href="tab_logout.php">Sign Out</a>'; $result=mysql_query("SELECT treeID, treeName, treePicture, treeGiver, treeDesc, CurrentPrice FROM Trees ORDER BY treeName"); $treeID=$_POST['treeID']; $newPrice=$_POST['newBid']; $result2=mysql_query("UPDATE Trees SET CurrentPrice ='$newPrice' WHERE treeID = '$treeID'"); ?> </head> <body> <table> <tr> <td>Active Trees</td> </tr> </table> <?php while($row=mysql_fetch_array($result)) { $treeID=$row['treeID']; echo "<table>"; echo "<tr><td><img src=" .$row['treePicture']. "></td></tr>"; echo "<tr><td><input type=\"text\" name=\"treeID\" id=\"treeID\" value=\"" .$treeID. "\" /></td></tr>"; echo "<tr><td>Current Price: $" .$row['CurrentPrice']. "<div id=\"priceElement\"></div></td></tr>"; echo "<tr><td>New Bid: <input type=\"text\" id=\"newBid\" name=\"newBid\" \><button type=\"button\" name=\"bidNow\" value=\"Bid\" onclick=\"showCurrentPrice(document.getElementById('treeID').value,document.getElementById('newBid').value)\"></td></tr>"; echo "<tr><td>" .$row['treeName']. "</td></tr>"; echo "<tr><td>" .$row['treeGiver']. "</td></tr>"; echo "<tr><td>" .$row['treeDesc']. "</td></tr>"; echo "</table>"; } ?> </body> <?php mysql_close($con); ?> </html> getPrice.php $q=$_GET["q"]; $s=$_GET["s"]; $con=mysql_connect("xxxx", "xxxx", "xxxx") or die ("cannot connect"); mysql_select_db("tab_test") or die ("cannot select database"); $result2=mysql_query("UPDATE Trees SET CurrentPrice =$s WHERE treeID = $q"); $sql=mysql_query("SELECT * FROM Trees WHERE treeID =$q"); //$result = mysql_query($sql); while($row = mysql_fetch_array($sql)) { echo $row['CurrentPrice']; } mysql_close($con); ?> getPrices.php <?php $q=$_GET["q"]; echo $q; $con=mysql_connect("xxxx", "xxxx", "xxxxx") or die ("cannot connect"); mysql_select_db("tab_test") or die ("cannot select database"); $sql=mysql_query("SELECT * FROM Trees); //$result = mysql_query($sql); while($row = mysql_fetch_array($sql)) { echo $row['CurrentPrice']; } mysql_close($con); ?>
  19. Thank you for replying. Since my request works correctly, it does not seem to be getting the parameters. Am I doing something wrong in my form where I input the bid and then button does not seem to be sending the information. Also the input textbox for the new bid does not clear out when I complete the button click. Any help would be appreciated. Thanks, Jessica
  20. Hello, I was wondering if someone could look at my code. Basically I'm making an auction site where when I enter a new bid into a text box, I would be able to click the "Bid" button next to it, and then that button will update the bid in the database and then AJAX will return it and display it. The button isn't working and the AJAX request isn't working. The treeAuctions.php file calls the getPrice.php file here is my code; I was wondering if someone would be able to look at it and see if they can guide me in the right direction to get the code to work. treeAuctions.php <html> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <head> <script type="text/JavaScript"> function showCurrentPrice(str,str1) { if (str=="") { document.getElementById("priceElement").innerHTML=""; return; } if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById("priceElement").innerHTML=xmlhttp.responseText; } } xmlhttp.open("GET","getPrice.php?q="+str&&s=str1,true); xmlhttp.send(); } </script> <?php $con=mysql_connect("xxxx", "xxxxx", "xxxx") or die ("cannot connect"); mysql_select_db("tab_test") or die ("cannot select database"); session_start(); echo 'Welcome ' .$_SESSION['username']. '!'; echo '<br /><br /><br />'; echo '<a href="tab_logout.php">Sign Out</a>'; $result=mysql_query("SELECT treeID, treeName, treePicture, treeGiver, treeDesc, CurrentPrice FROM Trees ORDER BY treeName"); $treeID=$_POST['treeID']; $newPrice=$_POST['newBid']; $result2=mysql_query("UPDATE Trees SET CurrentPrice ='$newPrice' WHERE treeID = '$treeID'"); ?> </head> <body> <table> <tr> <td>Active Trees</td> </tr> <?php while($row=mysql_fetch_array($result)) { $treeID=$row['treeID']; echo "<tr><td><img src=" .$row['treePicture']. "></td></tr>"; echo "<tr><td><input type=\"text\" name=\"treeID\" id=\"treeID\" value=\"" .$treeID. "\" /></td></tr>"; echo "<tr><td>Current Price: $" .$row['CurrentPrice']. "<div id=\"priceElement\"></div></td></tr>"; echo "<tr><td>New Bid: <input type=\"text\" id=\"newBid\" name=\"newBid\" \><button type=\"button\" name=\"bidNow\" value=\"Bid\" onclick=\"showCurrentPrice(document.getElementById('treeID').value,document.getElementById('newBid'))\"></td></tr>"; echo "<tr><td>" .$row['treeName']. "</td></tr>"; echo "<tr><td>" .$row['treeGiver']. "</td></tr>"; echo "<tr><td>" .$row['treeDesc']. "</td></tr>"; } ?> </table> </body> <?php mysql_close($con); ?> </html> getPrice.php <?php $q=$_GET["q"]; $s=$_GET["s"]; $con=mysql_connect("xxxx", "xxxx", "xxxx") or die ("cannot connect"); mysql_select_db("tab_test") or die ("cannot select database"); $result2=mysql_query("UPDATE Trees SET CurrentPrice ='$s' WHERE treeID = '$q'"); $sql="SELECT * FROM Trees WHERE id = '".$q."'"; $result = mysql_query($sql); while($row = mysql_fetch_array($result)) { echo $row['CurrentPrice']; } mysql_close($con); ?>
  21. ok so I can use the php variable in place of a field name in a mysql statement? That will work? If it will that's great, that's what i need to avoid tons of if statements.
  22. Ok. So I can't use the php variable "today" to place the field name in the $schedule['today'] field? I have seven fields for Sunday through Saturday, by using the $today variable it will place what day of the week it is so the mysql will know what field in the table to look at... so I don't have to have a bunch of if statements to look at each field for each day of the week.
  23. I am using this function to get the day of the week and placing it into a variable called $today $today=date("l"); I have a mysql table that has 7 fields one for each day of the week, and in that field if a checkbox on the form selects that day, a "1" is placed in the table and "0" of it is not I want to easily look for that field using the $today variable Can I do this in my mysql statement when i use a while loop? $getSchedule=mysql_query("SELECT * FROM schedule"); $schedule=mysql_fetch_array($getSchedule); while($schedule[$today]=="1") { /* where $today will place the value for instance $today will place "Sunday" for $schedule[sunday] */ } Will this work or do I need to it another way? Thanks, jcjst21
  24. ok so if I place that into a variable...like $today=date("l"; the variable will hold "Thursday?" so if I want to match the data field Thursday which would be like If($thursday==$today && $thursday==1) { then this person takes their medicine today } or do I need to use a string compare?
  25. Hello, I have a list of people that have to have their medications on certain days of the week... I would like to use PHP to get the current date but extract what day it is, like Monday, Tuesday, wednesday, etc... How I have the medication schedule setup is 7 different checkbox fields, where each field is a day of the week. If for instance someone takes a medication on a Wednesday, a "1" is entered into the table. I want to be able to get the current day of the week to match up with the fields for that specific day.. any suggestions would be great. jcjst21
×
×
  • 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.