Jump to content

dreampho

Members
  • Posts

    96
  • Joined

  • Last visited

Everything posted by dreampho

  1. Hi. I have a simple math line, and I cant work out why its subtracting the $extra_cost variable, where as it should be adding it? <?php $deposit = substr("300"); $full_price = "1000"; $extra_cost = "10"; $remaining_balance = $deposit - $full_price + $extra_cost; $remaining_balance = substr("$remaining_balance",1); ?> Thank you
  2. Thank you. I can see I was making it much more difficult than it needed to be.
  3. Okay, I have removed strotime and now $date is formatted correctly. But I dont understand how to remove the 14 days off this. Could you possibily give me an example? I have read in the php manual for datetime, but its throws an error when I try and use it. Again an example would be great. Thank you
  4. Hi all. Okay, so I have a date saved in UNIX format, so the date looks like this: 1346689843 - {start} is just my CMS variable. I am trying to first convert the date to dmY format, then remove 14 days. $date = date('dmY',strtotime("{start}")); $due_date = strtotime('-14 day',strtotime($date)); $due_date = date('dmY',$due_date); echo $date; echo $due_date; The $date variable displays 1/1/1970 which is the first day of the UNIX I think. $due_date displays 18/12/1969 So the minus 14 days is working, just not the formatting for $date. How can I get the $date variable to format the date correctly? Am I making some stupid error here?
  5. Thank you kicken for explaining this, and PFMaBiSmAd for your help! This was the issue, I am slowly getting to grips with this... I am very greatful for your help!
  6. I tried with the fields set to 'date' and it didnt work either. The field names are not chosen by me, I am working through a content management system that dicatates this. Does this mean to say that nobody can see any reason why the below doesnt work? AND matrix.col_id_3 > (DATE_FORMAT(NOW(), '%Y%m%d'))
  7. Sorry, I misread your post. The problem is not that it is returning nothing, its that it is returning everything even if its before the date and I am completey stumped as to why. Any further help would be fantastic.
  8. Sorry, I thought you meant the format, the data would be after todays date to display a result so: 20120930 or 20130112
  9. Thanks for your replys. jesirose - I am not quite sure where I would need to do this, in phpmyadmin? Here is the entire query: SELECT titles.entry_id, titles.title, matrix.entry_id, data.field_id_11 as tour_description, data.field_id_13 as ref, data.field_id_8 as tour_price, titles.url_title, titles.status, assets_entries.asset_id, matrix.col_id_3 as start_date, matrix.col_id_4 as end_date, data.field_id_157 as inventory, data.field_id_158 as last_places_available_limit, SUBSTR( assets.file_path, 12 ) as file_path, matrix.col_id_3 FROM exp_channel_titles as titles LEFT JOIN exp_channel_data AS data ON data.entry_id = titles.entry_id LEFT JOIN exp_assets_entries AS assets_entries ON assets_entries.entry_id = data.entry_id LEFT JOIN exp_assets AS assets ON assets_entries.asset_id = assets.asset_id LEFT JOIN exp_matrix_data AS matrix ON matrix.entry_id = data.entry_id WHERE titles.channel_id = '4' AND titles.status = 'Active' AND assets_entries.field_id = '84' AND matrix.col_id_3 > (DATE_FORMAT(NOW(), '%Y%m%d')) AND MONTH(matrix.col_id_3) = '{segment_4}' OR MONTH(matrix.col_id_4) = '{segment_4}' GROUP BY titles.entry_id ORDER BY matrix.col_id_3 ASC A sample of the data in cold_id_3 is : 20120903 Thank you
  10. Hi. Thanks for getting back to me. The field with the date is set as TEXT. I have tried the code wtith % and it still isnt working. Is there something else I could use?
  11. Hi. I have a database field (col_id_3) with a dat in Ymd format (YYYYMMDD). I am trying to have the query only display results that have the 'col_id_3' field with a date after todays date. The code below isnt working, can anyone help? AND matrix.col_id_3 > (DATE_FORMAT(NOW(), 'Ymd')) Thank you
  12. Ah I see, thank you. But how would I add this into the WHERE? Thanks
  13. Hi. I have a date in format YYYYMMDD. I want to display results where the MM is equal to something. How can I do this without it checking against the YYYY or DD? Thank you
  14. Thank you Barand. I have been trying to get this to work all afternoon, but my lack of knowledge is showing. For my foreach statment I am getting an error: Warning: Invalid argument supplied for foreach() in /home/chrisdav/public_html/template/process-sortable.php on line 12 foreach ($_GET['listItem'] as $sortorder => $id) { $id = intval($id); $sortorder = intval($sortorder); mysql_query("UPDATE exp_channel_data SET field_id_90 = $sortorder WHERE entry_id = $id"); } Can you see what I have done wrong, and possibly explain what it is to me? Many thanks
  15. Thanks Barand. Now that I have the details, and am posting to php script, I have opened a connection to the database, but am not entirely sure how to post the array information. Could you possibly give me an example? Thank you
  16. Thanks Barand. I see, so each list item will have a form input which has something like: <input type="text" name="sort_order[$entry_id]" value="$sort_order" /> My next question would be, is there a way to assign an order. So the first li item is 1, then the next is 2, and so on? Thank you
  17. Hi. I need some advice on how would be best to achieve the below: I have a list of database entries. Each entry is a row in the database, and has an entry_id assigned to it. I am loading each entry into a unordered list item and using jQuery ui to drag and drop their order. In the database I have a column in the same table as the entries, named sort_order. I need to update the sort_order column. I think the best way would be to submit a form which would send the entry_id and sort_order to a php script that then updates the database for each row. The problem is I am not sure how I should send the data for multiple rows at once, and then not sure how to enter the sort_order for each row separately. I would be very grateful if someone can give me some advice on this. Thank you
  18. Thank you very much! Just to understand it a little more, how would I take a number, for example, 52, and want to make it add one, and then make the overall length 4, so 0053? Thank you!
  19. Hi all. I am trying to add 1 to a number. The problem I have is that the number is 4 digits long. So for example the number could be 0007. I add one and it returns 8. I need it to return 0008. <?php $next = 0007 + 1; echo $next; ?> Can anyone show me how I can get the number to be 4 digits? Thank you
  20. Hi. Thanks for getting back to me. Okay, how would I validate? I am a complete newbie. I want the row with the id of the post variable to be deleted. I can echo the post variable, so I know its passing over the correct id, it just doesnt actually delete. I think I have the wrong quotes or something around the post variable. Thanks
  21. Hi. What am I doing wrong here: mysql_query("DELETE FROM availability WHERE id = '$_POST['id']'"); I am able to echo the id but I must be entering the post item incorrectly into the delete string. Can anyone show me my mistake? Thanks
  22. Thank you to both of you. How would I redirect to a certain page for the if or else statements? Thanks
  23. Hi. I am new to PHP and trying out database connections. I am trying to query the database, to see if the date matches a record in the field 'date'. If it does echo yes, if there are no matches 'no'. Can anyone tell me what is missing from my code: <?php $con = mysql_connect("localhost","root","root"); if (!$con) { die('Could not connect: ' . mysql_error()); } mysql_select_db("date_picker", $con); $date= $_POST['date']; $new_date = date('Y-m-d',strtotime($date)); $sql = 'SELECT date FROM availability' if (date = $new_date) echo "Yes"; else echo "No"; mysql_close($con) ?>
×
×
  • 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.