Jump to content

thecase

Members
  • Posts

    63
  • Joined

  • Last visited

Everything posted by thecase

  1. Thanks CroNiX and DavidAM you were both correct I could only mark one. Works perfectly. I will take into consideration about using the array keys Thanks.
  2. Hi I am reading in data from a csv file if (($handle = fopen("data.csv", "r")) !== FALSE) { while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) { echo "User Name: $data[0]"; echo "Booking IDs: $data[1]"; } echo "<hr>"; The problem is some of the usernames are duplicated so get outputted the same user name 20 times but with different IDs, obviously but I am unsure how to group them together. I can't seem to figure out how to write if the next username is the same as current then just add another ID not go through the entire loop. Any ideas? Thanks
  3. Hi I have this date in my database 11/06/2013 12:00 This is my code and the format I would like it in $dateformatstart = date_format(date_create($row['datestart']), 'D j M y H:i'); Although it comes back as Wed 6 Nov 13 12:00, Think the month is the day and day is the month I don't know why
  4. I'm trying to comapre the two arrays for duplicates and set up an array with the dates that arent duplicated. I don't have control over the 1st array as it comes from the database but I can change the 2nd array. I'll try what you suggested Barand thanks
  5. Hi, I'm trying to compare arrays but they have different levels of keys I've tried to compare using array_diff but this only finds a difference on the first entry for array 1 I assumed due to the different way it set up. Any ideas how I can get this to work Thanks
  6. Thank you works great and learnt some new conditions
  7. It comes back with string 'SELECT TRUE FROM studiorota WHERE date='2012-09-19' AND starttime <= '17:30' AND endtime > '16:30' ' (length=99) There is no error just coming back with the wrong results. The $_POST data is from a dropdown like this echo '<p>Start: <select name="timestart">'; for ($i = $start; $i <= $end; $i += 1800) { echo '<option>' . date('G:i', $i); } echo "</select></p>";
  8. Sorry I didn't know how much info was necessary is this any better? The Code: -- -- Table structure for table `studiorota` -- CREATE TABLE IF NOT EXISTS `studiorota` ( `id` int(11) NOT NULL AUTO_INCREMENT, `show` varchar(100) NOT NULL, `date` date NOT NULL, `starttime` time NOT NULL, `endtime` time NOT NULL, `volunteer1` int(11) NOT NULL, `volunteer2` int(11) NOT NULL, `volunteer3` int(11) NOT NULL, `volunteer4` int(11) NOT NULL, `removedate` int(10) NOT NULL, PRIMARY KEY (`id`), KEY `volunteer2` (`volunteer2`), KEY `volunteer3` (`volunteer3`), KEY `volunteer4` (`volunteer4`), KEY `volunteer1` (`volunteer1`) ) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ; -- -- Dumping data for table `studiorota` -- INSERT INTO `studiorota` (`id`, `show`, `date`, `starttime`, `endtime`, `volunteer1`, `volunteer2`, `volunteer3`, `volunteer4`, `removedate`) VALUES (1, 'An Hour Of Fun', '2012-09-05', '17:00:00', '18:00:00', 1, 38, 48, 16, 1348763388), (2, 'Talk', '2012-09-19', '10:00:00', '12:00:00', 19, 8, 53, 29, 1348763532); mysql_query("SELECT TRUE FROM studiorota WHERE date='$_POST[date]' AND starttime <= '$_POST[timestart]' AND endtime > '$_POST[timeend]' "); The problem is for example ID 1 the system must come back as TRUE when the user selects a start/end time between 1700 and 1800 although the query I already tried lets the user start at 1730 or end at 1730 clashing with ID 1. As for SQL Injections and Data verification I can implement this when the query is fully working but any pointers? Hope this is clearer
  9. This is how the database is set up `starttime` time NOT NULL, `endtime` time NOT NULL All the $_POST data comes from a drop down (as I limit the user to only certain times) so I know that I am going to be getting the exact format I need. Thanks
  10. Hi, I'm creating a booking form but am having problems. In the table I have two fields set to Time: starttime and endtime. I am trying to create a query that checks in between these times to stop double bookings so something like this mysql_query("SELECT TRUE FROM studiorota WHERE date='$_POST[date]' AND starttime <= '$_POST[timestart]' AND endtime > '$_POST[timeend]' "); Although it doesn't work as expecting resulting FALSE when it should be TRUE so how do I set the query up correctly to compare the two time fields. Thanks
  11. I have fixed this but I have added another cell to display the comments of each record from the table. The problem is it only displays the every third record in the database three times, how do I get it to get the correct comment. Hope this makes sence. echo " <table width='70%' cellspacing='0' cellpadding='0' border='1' align='center'> <tr> <td align='center' width='25%'><b><p>Date</p></b></td> <td align='center' width='25%'><b><p>Presenter 1</p></b></td> <td align='center' width='25%'><b><p>Presenter 2</p></b></td> <td align='center' width='25%'><b><p>Engineer</p></b></td> </tr> "; $colors = array("#df8700", "#006700", "#cf0000"); $count = 0; while ($row = mysql_fetch_assoc($query)) { if ($count == 0) { echo '<tr>'; $bg = ($bg == '#FFD5A8' ? '#BBBBBB' : '#FFD5A8'); echo "<td bgcolor=\"$bg\" align=\"center\" width='25%' ><p class='table'>{$row['show']}</p> </td>"; } if ($row['userid'] == '31') { echo "<td bgcolor=\"$bg\" align=\"center\" width='25%' ><font color=\"{$colors['1']}\"><p class='table'>None</p> </font></td>"; } else { echo " <td bgcolor=\"$bg\" align=\"center\" width='25%' ><font color=\"{$colors[$row['status']]}\"><p class='table'>{$row['user']} </font></p> </td>"; } if ($count + 1 == 3) { echo "</tr> <tr> <td></td> <td bgcolor=\"$bg\" align=\"center\" width='25%'><p class='table'>{$row['comment']}</p></td> <td bgcolor=\"$bg\" align=\"center\" width='25%'><p class='table'>{$row['comment']}</p></td> <td bgcolor=\"$bg\" align=\"center\" width='25%'><p class='table'>{$row['comment']}</p></td> </tr> "; $count = '0'; } else { ++$count; } } echo "</table><BR>";
  12. I think I get it now, so I set the $count back to 0 when the $count reaches 4. It looks fine in the view source but now the date has got stuck in the loop and inserts itself between every cell instead of just the first cell on each row. Version 2 echo " <table width='70%' cellspacing='0' cellpadding='0' border='1' align='center'> <tr> <td align='center' width='25%'><b><p>Date</p></b></td> <td align='center' width='25%'><b><p>Presenter 1</p></b></td> <td align='center' width='25%'><b><p>Presenter 2</p></b></td> <td align='center' width='25%'><b><p>Engineer</p></b></td> </tr> "; $colors = array("#df8700", "#006700", "#cf0000"); $count = 0; while ($row = mysql_fetch_assoc($query)) { $bg = ($bg == '#FFD5A8' ? '#BBBBBB' : '#FFD5A8'); if ($count == 0){ echo '<tr>'; } echo "<td bgcolor=\"$bg\" align=\"center\" width='25%' ><p class='table'>{$row['date']}</p> </td>"; if ($row['userid'] == '31'){ echo "<td bgcolor=\"$bg\" align=\"center\" width='25%' ><font color=\"{$colors['1']}\"><p class='table'>None</p> </font></td>"; } else { echo " <td bgcolor=\"$bg\" align=\"center\" width='25%' ><font color=\"{$colors[$row['status']]}\"><p class='table'>{$row['user']}</p> </font></td>"; } if ($count + 1 == 4){ $count = '0'; echo "</tr> "; }else{ ++$count; } } echo "</table><BR>"; Thanks [attachment deleted by admin]
  13. I thought the if ($count == 0){ echo '<tr>'; } Will do the trick
  14. The code is throwing weird results, see image attached. [attachment deleted by admin]
  15. Hi, I'm trying to populate an HTML table horizontally, so each new record on the table is inserted in the next cell until it reaches the fouth one, then an new row is added and the cycle repeats hopefully the code I have started will explain better echo " <table width='70%' cellspacing='0' cellpadding='0' border='1' align='center'> <tr> <td align='center' width='18%'><b><p>Date / Time</p></b></td> <td align='center' width='25%'><b><p>Presenter 1</p></b></td> <td align='center' width='25%'><b><p>Presenter 2</p></b></td> <td align='center' width='25%'><b><p>Engineer</p></b></td> </tr> "; $colors = array("#df8700", "#006700", "#cf0000"); $count = 0; while ($row = mysql_fetch_assoc($query)) { $bg = ($bg == '#FFD5A8' ? '#BBBBBB' : '#FFD5A8'); if ($count == 0){ echo '<tr>'; } echo "<td bgcolor=\"$bg\" align=\"center\" width='25%' ><p class='table'>{$row['date']}</p></td>"; if ($row['userid'] == '31'){ echo "<td bgcolor=\"$bg\" align=\"center\" width='25%' ><font color=\"{$colors['1']}\"><p class='table'>None</p> </font></td>"; } else { echo " <td bgcolor=\"$bg\" align=\"center\" width='25%' ><font color=\"{$colors[$row['status']]}\"><p class='table'>{$row['user']}</p> </font></td>"; } if ($count + 1 == 4){ echo "</tr> "; }else{ ++$count; } } echo "</table><BR>"; unset($colors, $row); } Although this does not work. It adds extra cells and doesn't complete all before starting the next, can anyone see the problem. Thanks
  16. For each person that is echoed I want them to be inserted into members tables. I tried doing mysql_query ("INSERT INTO `current_members` (`id`, `membername`) VALUES ('', '$personfetch[first_name]') "); Although this simply inserts just the first name and not all of the list. Hope this is clearer
  17. Hi, Here is an extract of my while loop while ($personquery = mysql_fetch_array($personfetch, MYSQL_ASSOC)) { echo "$personfetch[first_name]"; } This will list each person now I want to do an INSERT to the database on every single member that is being listed I can only get it to INSERT for the one. Thanks
  18. Hi, Im trying to make a shopping cart. Here is an extract while ($shoppingbasket = mysql_fetch_array($shoppingbasket2, MYSQL_ASSOC)) { echo " <form action='?' method='post'> <td><input type='text' value='$shoppingbasket[qty]' name='qty' /></td> </form> "; } The problem is if there are more than two entries in the cart so I have more than one textbox. I need each textbox assigned to the shopping cart ID to include in the WHERE cause to update the qty otherwise they all get updated the same qty. I hope this makes sences
  19. Got it working now. Had a blank value in the Imagejpeg function to define the name. Thanks for your help in pointing out the direction of the problem
  20. Im new to GD so not really sure what it all means
  21. Code I found around the web header("Content-Type: image/jpeg"); $im = ImageCreateFromGif("images/crimbo.gif"); $black = ImageColorAllocate($im, 255, 255, 255); $start_x = 10; $start_y = 20; Imagettftext($im, 12, 0, $start_x, $start_y, $black, 'verdana.ttf', "test text"); Imagejpeg($im, '', 100); ImageDestroy($im);
  22. Hi, Im trying to create text over an image and ive tried this on alot of other GD functions, all GD is doing is stopping the rest of the site from running and converting the sites url to a gd image which the script is not telling it to do, anyone know why Thanks
  23. So if the user selects 10 out of the 50 checkboxes will all the same name im not sure how I can take the selected data and input it into the database for example if checked update table users feild admin and make it 1.
  24. I know this but the problem is there will be like 50 records with 50 checkboxs so how can I define all 50 of them
×
×
  • 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.