Jump to content

jeeves245

Members
  • Posts

    145
  • Joined

  • Last visited

Everything posted by jeeves245

  1. Ok i'm getting there, got rid of all the errors, i'm just still a bit confused on the WHERE clause. WHERE estimatedDelivery = '".$key."'"; Could you please elaborate on how this works? Thanks
  2. Wait... mysql_query("UPDATE smail SET estimatedDelivery = '".$val."' WHERE id = '".$key."'"); id? Where did that come from? I have no id column... If $key is just a number, how will the WHERE = clause work? Wouldn't it need to reference the date that I am updating?
  3. I can't set it to varchar as it's a date and I'm using some format date functions to format it. But I'll try using the update query in phpmyadmin and see if I get any errors. Thanks.
  4. UPDATE smail SET estimatedDelivery = '16-07-2009' WHERE id = '0' UPDATE smail SET estimatedDelivery = '17-07-2009' WHERE id = '1' UPDATE smail SET estimatedDelivery = '18-07-2009' WHERE id = '2' UPDATE smail SET estimatedDelivery = '19-07-2009' WHERE id = '3' UPDATE smail SET estimatedDelivery = '20-07-2009' WHERE id = '4' UPDATE smail SET estimatedDelivery = '21-07-2009' WHERE id = '5' UPDATE smail SET estimatedDelivery = '22-07-2009' WHERE id = '6' UPDATE smail SET estimatedDelivery = '23-07-2009' WHERE id = '7' Error: Query was empty
  5. Ok. I tried this to see what was being echoed: foreach ($_POST['estimatedDelivery'] as $key => $val) { echo "<br>"; echo $val; echo "<br>"; echo $key; } And I get this result which is correct: 16-07-2009 0 17-07-2009 1 18-07-2009 2 19-07-2009 3 20-07-2009 4 21-07-2009 5 22-07-2009 6 23-07-2009 7 But when I insert the SQL statement in the for loop I still get "Error: Query was empty".. I'm using this query: foreach ($_POST['estimatedDelivery'] as $key => $val) { mysql_query("UPDATE smail SET estimatedDelivery = '".$val."' WHERE id = '".$key."'"); } } I also tried your modified for loop that you posted above but I got the same result.
  6. Thanks again for the info. I gave that code a go but when I click submit i'm just getting a blank page with "Error: Query was empty". Chances are i've done something wrong.. i'll keep at it
  7. Ok been thinking (haven't looked at your code yet). With the code i've already written, wouldn't the while loop put the $new_date value into the $_POST['estimatedDelivery'] array each time it passes? So isn't $_POST['estimatedDelivery'] all I need for the process.php page to update the row? I don't actually see why I need to modify the code below... But that said, i'm no expert while($row = mysql_fetch_array($result)) { $date2 = $row['estimatedDelivery'];; $timestamp2 = strtotime($date2); $new_date2 = date("d-m-Y",$timestamp2); echo "<td> <form action='process.php' method='post'><input type='text' name='estimatedDelivery' value=".$new_date2."></td>"; } echo "<input type='submit' name='submit' value='Submit updated delivery dates'></form>";
  8. I'll have a go at incorporating the code you posted above and let you know how it goes. Thanks
  9. Alllright. I'm completely lost. This is way over my head haha. Thanks anyway.
  10. Sorry what do you mean by structured? I'm still pretty new to all this
  11. Thanks for that.. but I still don't know how to actually use it to update the DB on the process.php page
  12. Well the original code (that I posted above) is in a while loop and it creates a text box for each date stored in the estimatedDelivery field in the database. The user can change the dates and then click submit to save them back So there could be 20 or so dates in that field at any given time, therefore there will be 20 or so text boxes containing each date. Sorry if that makes little sense. I can post a screenshot to go with the code? The code is basically all written i'm just having trouble with the part where they click submit and save all the dates back to the field in the DB.. Here's the code that creates the text boxes: while($row = mysql_fetch_array($result)) { $date2 = $row['estimatedDelivery'];; $timestamp2 = strtotime($date2); $new_date2 = date("d-m-Y",$timestamp2); echo "<td> <form action='process.php' method='post'><input type='text' name='estimatedDelivery' value=".$new_date2."></td>"; } echo "<input type='submit' name='submit' value='Submit updated delivery dates'></form>";
  13. Hey all, another question (I know I know, i'm full of questions). Having some problems uploading a file to my server. I have no issues on my local Apache server, but when I saved the files to my web host's FTP server I get the following errors: Here is the form code: <form enctype="multipart/form-data" action="uploader.php" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="100000" /> Choose manifest from computer:<br> <input name="uploadedfile" type="file" /><br /><br> <input type="submit" value="Click here to upload" /> And here is the actual code that handles it (uploader.php): <?php $target_path = "http://www.example.co.nz/folder/uploads/"; $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { //more code here but it doesn't related to the errors ?> This code should uploaded the file to the /uploads folder. As I said, it worked fine on my local server, just not on my web host. Any ideas appreciated
  14. Thanks for that. But why does there not have to be a while loop for the insert part of the code? Wouldn't the code that you gave me just update one line of the database? $_POST['estimatedDelivery']; contains about 20 different dates in the array.
  15. Thanks for the help guys. How do I actually modify this to suit my needs though? <input type="hidden" name="id" value="<?php echo $id?>" /> I haven't done this type of thing before and i'm still a bit lost. Just not too sure how to link $id to the row ID. And this this is all in a while loop which makes it even harder.
  16. This is what i'm trying to use for the process.php page: <?php $con = mysql_connect("localhost","",""); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("db", $con); while(not sure what goes here) { mysql_query("UPDATE 'deliveries' SET 'estimatedDelivery' = '$new_date var from previous page"); } if (!mysql_query($sql,$con)) { die('Error: ' . mysql_error()); } mysql_close($con); ?> I dunno.. probably way off track
  17. I'll just post the code, as it's a bit hard to explain in plain English. while($row = mysql_fetch_array($result)) { $date2 = $row['estimatedDelivery'];; $timestamp2 = strtotime($date2); $new_date2 = date("d-m-Y",$timestamp2); echo "<td> <form action='process.php' method='post'><input type='text' name='estimatedDelivery' value=".$new_date2."></td>"; } echo "<input type='submit' name='submit' value='Submit updated delivery dates'></form>"; So using the code "The Little Guy" posted above, I need to get $new_date2 put back in the same DB field it came from in the right order. It's confusing as hell haha. Cheers in advance for any info.
  18. That's really helpful, thanks. One part i'm a bit confused about though. My original line of code was in a while loop. So let's assume that clicking the submit button goes to a process.php page which includes the line of code you wrote above - how do I write it so each value stored in $_POST['estimatedDelivery'] is inserted into the correct field?
  19. Hi guys, quick question. I have this line of code (below) that is basically a text box that shows a value pulled from a database. The point of that is the user can change what's in the textbox and save it back to the database. However I can't figure out how to actually save it back to the database. Any ideas? echo "<td> <form action='process.php' method='post'><input type='text' name='estimatedDelivery' value=".$new_date2."></td>"; The $new_date2 var has a value from the database stored in it. So when the user changes what is in the textbox, I want it put in a different variable and sent back to the same field that $new_date2 came from. Cheers in advance.
  20. Hey guys, another question I currently use this code to open a CSV file (from a folder on the server) and insert it into a database: $file_handle = fopen("file.csv", "rb"); while (!feof($file_handle) ) { $line_of_text = fgets($file_handle); $parts = explode(',', $line_of_text); Then the SQL querys come after that. How hard would it be to modify that to upload the CSV file using a form? (I.e. browse to the file on the computer and submit it). I don't want the whole file just to be chucked in the database though, I need the code to save pieces into an array like the above code does. I've done a lot of research on Google but most pre-made scripts are too complex for my needs. Would this be hard to do? Thanks in advance.
×
×
  • 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.