Jump to content

hfheuhf

Members
  • Posts

    13
  • Joined

  • Last visited

hfheuhf's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Hello, thanks so much for replying! Didn't know how to approach this been trying to find a solution for weeks! I will have a go at your code later today and let you know how it goes
  2. Could someone help me out on how I would go about importing an excel sheet that is set up like this 13/02/2015 14/02/2015userid starttime endtime starttime endtime1 12:00 16:00 15:00 20:002 15:00 20:003 16:00 20:00 There are a lot of scripts out there on importing excel files however, there arent many where you could for instance merge two fields i.e i need the date and starttime to be one field so it could be inserted into the table into a field called "starttime" which is a DATETIME. I can't seem to find anything online. I've come accross PHPExcel, however, I can't get the grisp of it/understand it.
  3. I've deleted the hidden input and added echo "<option value=".$row['fruitid'].">".$row['datefrom']." - ".$row['dateto']."</option>"; and it's fixed now! Thanks for your help everyone!
  4. I've given it a name attribute and an id of "fruitid" and now the array is Array ( [fruitid] => 9 [submit] => Submit ) how can i fix this please help
  5. If I treat it as a string would I use the msqli_escape string function then? But, I have tried this solution originally, it would show the message that the type has been updated but not actually updating in the database. Also, it's still showing the Undefined index:fruitid error.
  6. Basically, the table for fruits has 4 fields - fruitd which is a primarykey, user, dateto, datefrom and type. I need to update the type to "banana" when the Submit button is pressed. So, the fruitid field contains the id numbers. I have removed mysqli_real_escape_string but it is still displaying the errors. I have used "print_r($_POST);" which printed and array of the select data and in displays the fruitid in the array which is 9. Array ( [select] => 9 [submit] => Submit )
  7. I have done, it says... UPDATE `fruits` SET `type`='banana' WHERE `fruitid` = Error: You have an error in your SQL syntax; How do I solve this please. I have read over 15 different posts today but nothing seems to be working.
  8. Keep getting these two errors when trying to UPDATE a field called "type" to 'banana' based on the fuitid. Why is this happening? Undefined index: fruitid in update.php 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 '' at line 1 <form method="POST" action="update.php"> <select> <option value="">Select</option> <?php $sql = "SELECT fruitid, datefrom, dateto FROM fruits"; $sqlresult = $link->query($sql); $sqllist = array(); while($row = mysqli_fetch_array($sqlresult)) { echo "<option>".$row['datefrom']." - ".$row['dateto']."</option>"; } ?> </select> <input type="hidden" value="<?php echo $fruitid;?>" name="fruitid"/> <input type="submit" value="Submit" name="submit"/> </form> <?php if(isset($_POST['submit'])) { $fruitid= mysqli_real_escape_string($link,$_POST['fruitid']); $sql = "UPDATE `fruits` SET `type`='banana' WHERE fruitid = $fruitid"; if (mysqli_query($link, $sql)) { echo "updated"; } else { echo "problem: " . mysqli_error($link); } } ?>
  9. thank you, i will consider this. by any chance do you know how to get start and end days for a week number in php where Sunday is the start day instead of monday??
  10. i never knew that, it's always in php books and everythin could you please tell me why, ill change it asap
  11. Sorry that doesn't work, well it shows the date it just doesn't change when i press next or previous what im trying to do is i have a calendar and i am trying to put the week range dates at the top
  12. The url shows the current weeks when you click prev or next, so currently is week 4, if i click again it shows week 5. However, the week date range doesn't change along with the next/previous
  13. I have the week date range displaying the week range from sunday - saturday $current_dayname = date("0"); // return sunday monday tuesday etc. echo $date = date("Y-m-d",strtotime('last sunday')).'to'.date("Y-m-d",strtotime("next saturday")); Which outputs in the following format 2015-01-25to2015-01-31 However, when I press next or previous, the dates don't change. <?php $year = (isset($_GET['year'])) ? $_GET['year'] : date("Y"); $week = (isset($_GET['week'])) ? $_GET['week'] : date('W'); if($week > 52) { $year++; $week = 1; } elseif($week < 1) { $year--; $week = 52; } ?> <a href="<?php echo $_SERVER['PHP_SELF'].'?week='.($week == 52 ? 1 : 1 + $week).'&year='.($week == 52 ? 1 + $year : $year); ?>">Next Week</a> <!--Next week--> <a href="<?php echo $_SERVER['PHP_SELF'].'?week='.($week == 1 ? 52 : $week -1).'&year='.($week == 1 ? $year - 1 : $year); ?>">Pre Week</a> <!--Previous week--> <table border="1px"> <tr> <td>user</td> <?php if($week < 10) { $week = '0'. $week; } for($day= 1; $day <= 7; $day++) { $d = strtotime($year ."W". $week . $day); echo "<td>". date('l', $d) ."<br>". date('d M', $d) ."</td>"; } ?> </tr> </table>
×
×
  • 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.