Jump to content

james182

Members
  • Posts

    49
  • Joined

  • Last visited

Profile Information

  • Gender
    Not Telling

james182's Achievements

Member

Member (2/5)

0

Reputation

  1. I have a time array and a event array and i need the 2 to join, could i get some help. So basically the All the times need be there and if there is a match event then it shown and if not nothing. What i have so far: Time Array Array ( [06:00:00] => 06:00:00 [07:00:00] => 07:00:00 [08:00:00] => 08:00:00 [09:00:00] => 09:00:00 [09:30:00] => 09:30:00 [17:30:00] => 17:30:00 [18:00:00] => 18:00:00 [18:30:00] => 18:30:00 [19:30:00] => 19:30:00 ) Event Array Array ( [0] => stdClass Object ( [class_id] => 1 [class_name] => Fit Box [class_description] => Fitbox is a high energy aerobic workout utilizing focus pads, kick pads, heavy bags, and speed balls. This class increases muscle strength and cardiovascular fitness and also includes strength and endurance circuit style training. Excellent for co-ordination, reflexes and to pump out the adrenalin! The class is 1 hour in duration. [class_time] => 06:00:00 [class_day] => Tuesday [class_status] => active [class_colour] => blue ) [1] => stdClass Object ( [class_id] => 2 [class_name] => Hot Boxing [class_description] => test description [class_time] => 08:00:00 [class_day] => Wednesday [class_status] => active [class_colour] => grey ) [2] => stdClass Object ( [class_id] => 3 [class_name] => Punch Face [class_description] => test again [class_time] => 09:00:00 [class_day] => Thursday [class_status] => active [class_colour] => grey ) [3] => stdClass Object ( [class_id] => 4 [class_name] => MOS [class_description] => test again [class_time] => 19:30:00 [class_day] => Monday [class_status] => active [class_colour] => yellow ) [4] => stdClass Object ( [class_id] => 5 [class_name] => Yoga [class_description] => test description [class_time] => 08:00:00 [class_day] => Wednesday [class_status] => active [class_colour] => grey ) ) The Code that aims at displaying all the times and each time has all the days, then each day needs to show events if they have them. $result_array = array(); $days_array = array("Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"); foreach($timetable_times as $time_key => $time_value) { // initialize all the days of the week for each time entry $result_array[$time_value['time']] = array(); foreach($days_array as $day) { $result_array[$time_value['time']][$day] = ""; } if (array_key_exists($day, $timetable_classes)) { $event_entry = $timetable_classes[$time_value['time']]; foreach($event_entry as $event_day => $events) { $result_array[$time_value['time']][$day][] = $events; } } } print_r($result_array); My desired outcome is below $arr = array( "06:00:00" => array( "Sunday" => array( array( 'event_title' => "item_1", 'event_desc' => "item_1", 'event_link' => "item_1", ), ), "Monday" => array( array( 'event_title' => "item_1", 'event_desc' => "item_1", 'event_link' => "item_1", ), array( 'event_title' => "item_1", 'event_desc' => "item_1", 'event_link' => "item_1", ), ), "Tuesday" => "", "Wednesday" => "", "Thursday" => "", "Friday" => "", "Saturday" => "" ), "07:00:00" => array("Sunday" => "", "Monday" => "", "Tuesday" => "", "Wednesday" => "", "Thursday" => "", "Friday" => "", "Saturday" => ""), "08:00:00" => array("Sunday" => "", "Monday" => "", "Tuesday" => "", "Wednesday" => "", "Thursday" => "", "Friday" => "", "Saturday" => ""), "09:30:00" => array("Sunday" => "", "Monday" => "", "Tuesday" => "", "Wednesday" => "", "Thursday" => "", "Friday" => "", "Saturday" => ""), "17:00:00" => array("Sunday" => "", "Monday" => "", "Tuesday" => "", "Wednesday" => "", "Thursday" => "", "Friday" => "", "Saturday" => ""), );
  2. I have that too. but why is it adding the \' to it ??? the \' is stopping my query from working.. SELECT * FROM (`default_products_diamonds`) WHERE `shape` = 'Princess' AND `colour` IN ('\'D\',\'E\',\'F\'')
  3. i have a problem. $colours = implode("','", explode('-', substr_replace($colour ,"",-1))); // outputs: D','E','F "','" is getting placed in the query as "\',\'" need to change '\'E\',\'F\'' SELECT * FROM (`default_products_diamonds`) WHERE `shape` = 'Princess' AND `colour` IN ('\'D\','\'E\',\'F\'') Needs to be like this: SELECT * FROM (`default_products_diamonds`) WHERE `shape` = 'Princess' AND `colour` IN ('D','E','F')
  4. I don't seem to be having much luck with this any help would be great. Trying to select multiple colours. $query = "SELECT * FROM diamonds WHERE colour IN ('D', 'E', 'F')"; ... Not working My exact Code public function get_diamond_by_shape($shape,$scat_id,$colour,$clarity,$certification,$cut,$polish,$symmetry,$fluorescence,$min_carat,$max_carat,$min_price,$max_price) { //$colours = "'". implode("','", explode('-', substr_replace($colour ,"",-1))) ."'"; $colours = explode('-', substr_replace($colour ,"",-1)); $clarities = explode('-', substr_replace($clarity ,"",-1)); $certifications = explode('-', substr_replace($certification ,"",-1)); print_r($shape); $this->db->where('shape', $shape); $this->db->or_where_in('colour', $colours); $this->db->or_where_in('clarity', $clarities); $this->db->or_where_in('certification_type', $certifications); /* $this->db->where('cut', $cut); $this->db->where('polish', $polish); $this->db->where('symmetry', $symmetry); $this->db->where('fluorescence', $fluorescence); */ $this->db->where('carat >=', $min_carat); $this->db->where('carat <=', $max_carat) ; $this->db->where('cost BETWEEN ' . $min_price . ' AND ' . $max_price); $diamonds = $this->db->get('products_diamonds'); return $diamonds->result_array(); } Post data is: certi all, clarity all, colour = D-E-F-G-, cut = all, flou = all, maxprice = 100000, maxval = 5, minprice = 100, minval = 0.01, pg = 1, polish = all, scat_id = null, shape = Princess, sym = all Using CodeIgniter Framework
  5. i am trying to get this to format the data properly. I want it to format like this 'D',E','F','G','H' But this is what i get: "D"E","F","G","H","I",J" "", $colour = "D-E-F-G-H-I-J-"; // string to be formatted. $colours = explode('-', $colour); $num_items = count($colours); $colour_is = ''; $i = 0; foreach ($colours as $key => $value) { if ($i == 0) { // first $colour_is .= ' "'. $value; } else if ($i == $num_items - 1) { // last $colour_is .= $value. '" '; }else{ $colour_is .= '"'. $value .'",'; } $i++; } print_r($num_items .' - '. $colour_is); Help on this would be nice. Thanks.
  6. I am trying to get the script to insert the new order into the mysql db but don't know how any help. below is the working up down list but i need it to save / update the new positions. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" dir="ltr" lang="en-US"> <head profile="http://gmpg.org/xfn/11"> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>test list sort</title> <script type='text/javascript' src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script> <script> $(document).ready( function () { $('table tbody a.control').live('click', function (e) { e.preventDefault(); var tr = $(this); // Start with this link and work upwards from there, this allows the TR element itself to be the control if desired var iterations = 0; while(tr.attr('tagName') != 'TR') { tr = tr.parent(); iterations += 1; if (iterations == 100) { return false; // Bail out, surely something is wrong or there is lots and lots of html in there } } if ($(this).attr('rel') == 'up' && tr.prev().length) tr.fadeTo('medium', 0.1, function () { tr.insertBefore(tr.prev()).fadeTo('fast', 1); // If you want to do any more to the table after the move put it here, I am running the reorder function (defined below) reorder(); }); else if ($(this).attr('rel') == 'down' && tr.next().length) // Same as above only this is for moving elements down instead of up tr.fadeTo('fast', 0.1, function () { tr.insertAfter(tr.next()).fadeTo('fast', 1); // If you want to do any more to the table after the move put it here, I am running the reorder function (defined below) reorder(); }); else //Can't do anything with these return false; return false; }); function reorder () { var position = 1; $('table tbody tr').each(function () { // Change the text of the first TD element inside this TR $('td:first', $(this)).text(position); //Now remove current row class and add the correct one $(this).removeClass('row1 row2').addClass( position % 2 ? 'row1' : 'row2'); position += 1; }); } }); </script> </head> <body> <?php echo '<table> <thead> <tr> <th>Position</th><th>Name</th><th>Controls</th> </tr> </thead> <tbody>'; $con = mysql_connect("localhost", "*******", "*********") or die(mysql_error()); mysql_select_db("my_test", $con) or die(mysql_error()); $sql = "SELECT * FROM tbl_items ORDER BY item_order ASC"; $result = mysql_query($sql); $i = 1; while($r = mysql_fetch_assoc($result)): echo '<tr class="'.$i.'"> <td>'. $i .'</td><td>'. $r['item_name'] .'</td><td> <a href="#up" rel="up" class="control">Up</a> <a href="#down" rel="down" class="control">Down</a></td> </tr>'; $i++; endwhile; echo '</tbody></table>'; ?> </body> </html> db table: item_id | item_name | item_order ---------|--------------|------------- 1 | green | 1 2 | blue | 2 3 | red | 3
  7. ok here is my code it works great in Firefox but not at all in IE. The code should post the id of a item via ajax post method. Javascript: $(document).ready(function(){ $('a.addFavs').click(function(){ var favData = $(this).attr('id'); $.post("path/to/addFav.php",{ send_favData: favData }, function(data){ $('#msg').html(data.returnValue); }, "json"); }); addFav.php <?php include_once("config.php"); //addFavourite($_GET['send_favData']); // TESTING if (isset($_POST['send_favData'])){ $value = $_POST['send_favData']; }else{ $value = "No Data"; } echo json_encode(array("returnValue"=>"Value Returned: ".$value), true); ?> Function.php function addFavourite($favData){ global $link; $data = explode(",", $favData); $query = "INSERT INTO tbl_favourites (fav_id, fav_user_id, fav_item_id, fav_cat_id, fav_section_id) VALUES (NULL, '$data[0]', '$data[1]', '$data[2]', '$data[3]')"; $result = mysql_query($query, $link) or die("add Favourites fatal error: ".mysql_error()); if($result){ echo "<p>Successful!</p>"; }else{ echo "<p>Failed!</p>"; } }
  8. So probably the question i should be asking is how to send data to a var. Is this right?? class myClass { var myVar; echo $myVar; function test() { $myVar = "test"; } }
  9. ok let me say that my code all works except for the the storing of the array item number: if($value != self::show_page_name($page_name)): echo '<li><a class="h-ico ico-'. $menu_item_icon[$i] .'" href="'. parent::get_site_url() .'admin/'. $menu_item_link[$i] .'"><span>'. $value .'</span></a></li>'; else: echo ''; $this->item_key = $value; // PROBLEM IS HERE, IT'S NOT SENDING TO VAR OUTSIDE OF THIS FUNCTION. endif;
  10. function show_page_name($string) { $page_name = $string; $words = split("[/]", $page_name); $page_name = $words[3]; $page_name = substr($page_name, 0, strrpos($page_name, '.')); $page_name = ucfirst($page_name); return $page_name; } show page name just remove slashes in string eg: "/to/be/members.php" becomes "members". Have i gone about storing the data in a var the right way???
  11. The problem is that it's not storing the data. for example if i click the members btn (which is 8 in the array) the number 8 should be echo'd out, in my test echo (echo 'Key: '. $this->item_key; // Testing purpose only.).
  12. i am trying to pull out the correct item key in and array and store it in the "item_key" variable. class myClass{ var $item_key; function get_menu($page_name) { $menu_item = array("Dashboard", "Content", "Comments", "Media", "Syndication", "Newsletter", "Affiliate", "Appearance", "Members", "Settings"); $menu_item_link = array("dashboard", "content", "comments", "media", "syndication", "newsletter", "affiliate", "appearance", "members", "settings"); $menu_item_icon = array("dashboard", "edit", "comments", "media", "syndication", "send", "cash", "color", "users", "advanced"); echo 'Key: '. $this->item_key; // Testing purpose only. echo '<h2><span class="h-ico ico-'. $menu_item_icon[$this->item_key] .'"><span>'. self::show_page_name($page_name) .'</span></span> <span class="h-arrow"></span> </h2>'; echo '<ul class="clearfix">'; $i=0; foreach($menu_item as $key => $value): if($value != self::show_page_name($page_name)): echo '<li><a class="h-ico ico-'. $menu_item_icon[$i] .'" href="'. parent::get_site_url() .'cp/'. $menu_item_link[$i] .'"><span>'. $value .'</span></a></li>'; else: echo ''; $this->item_key = $key; endif; $i++; endforeach; echo '</ul>'; } }
  13. Well thats just it i'm not. nothing happens i should get a response either successful or failed. not getting anything.
×
×
  • 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.