-
Posts
969 -
Joined
-
Last visited
Everything posted by Destramic
-
i took the div tag and its contents out of the table tags and the html was read then...why cant it read whilst in the table tags?
-
yep the div id is user_rows and ive tried $('#user_rows').html(); like you said and it returns empty aswell when alerting it...im confused why <div id="user_rows"> <tr> <td>destramic</td> <td>destramic@hotmail.com</td> </tr> <tr> <td>process</td> <td>process@hotmail.com</td> </tr> </div>
-
hey guys im sure this is possible im wondering how a user can execute a mysql query by a click of a button but without the page reloading...thanks guys
-
hey guys im having a little problem with this script ive been writing. how the script works is when a search is made if match then the data will show in the table. the problem im having is: 1. this line isnt getting the div content var div_contents = $('div#user_rows').html(); and 2. this line isnt replacing the content of the div but is showing the results above the <table> tags...how on earth! $('div#user_rows').html(content); ive been running the script on firefox so if anyone can help me please...thank you <!DOCTYPE html> <html> <head> <script src="media/scripts/library/jquery.js" type="text/javascript"></script> </head> <body> <form> <script> $(document).ready(function() { var search_value; var div_contents = $('div#user_rows').html(); alert(div_contents); var rows = [{"username":"destramic", "email":"destramic@hotmail.com"}, {"username":"process", "email":"process@hotmail.co.uk"}]; $('#search_query').keyup(function () { var search_value = $('#search_query').val(); var found_entries = new Array(); $.each(rows, function(index, row) { $.each(row, function(column, column_value) { if (column_value.indexOf(search_value) !== -1) { if ($.inArray(row, found_entries) == -1) { found_entries.push(row); } } }); }); if (found_entries.length > 0) { var content = ""; $.each(found_entries, function(index) { content += "<tr>"; content += "<td>" + found_entries[index]['username'] + "</td>"; content += "<td>" + found_entries[index]['email'] + "</td>"; content += "</tr>"; }); $('div#user_rows').html(content); } }); $('#search_query').focusout(function () { search_value = $('#search_query').val(); if (search_value == "") { $('#search_query').val("Search..."); } }); $('#search_query').click(function () { search_value = $('#search_query').val(); if (search_value == "Search...") { $('#search_query').val(""); } }); }); </script> <input type="text" name="search_query" id="search_query" value="Search..." /> <table> <tr> <th id="username">Username</th> <th id="team">E-mail</th> </tr> <div id="user_rows"> <tr> <td>destramic</td> <td>destramic@hotmail.com</td> </tr> <tr> <td>process</td> <td>process@hotmail.com</td> </tr> </div> </table> </body> </html>
-
that worked a dream thanks jcbones
-
ok all updated and these errors come up which i never seen before Fatal error: Uncaught exception 'Exception' with message 'DateTime::__construct() [<a href='datetime.--construct'>datetime.--construct</a>]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Europe/London' for '1.0/DST' instead' in C:\www\private\application\controllers\tournaments_controller.class.php:30 Stack trace: #0 C:\www\private\application\controllers\tournaments_controller.class.php(30): DateTime->__construct('2011-10-06') #1 [internal function]: Tournaments_Controller->tournament('counter-strike', 'test') #2 C:\www\private\library\action\action.class.php(47): call_user_func_array(Array, Array) #3 C:\www\private\library\dispatcher\dispatcher.class.php(101): Action->dispatch('tournament', Array) #4 C:\www\private\library\front_controller\front_controller.class.php(132): in <b>C:\www\private\application\controllers\tournaments_controller.class.php</b> on line <b>30</b><br /> help please
-
silly me...i best get with the times then...thank you
-
looks like you've got your parameters mixed up...try: mysql_select_db($connection, $db);
-
hey days im trying to get the differnce between the two dates but $start_date = new DateTime($start_date); $todays_date = new DateTime("now"); $interval = $start_date->diff($todays_date); echo $interval->format('%R%a days'); but the error im getting is Fatal error: Call to undefined method DateTime::diff() i dont see what im doing wrong if someone could help please thank you
-
hey guys im tring to add entries to an array but im doing something wrong here is the code ive tried...if anyone can help please var found_entries = {"users":[]}; found_entries['users'].push("test"); var found_entries = Array(); found_entries.push("users" : "test"); the result im looking for is var array = {"users":[{"value1", "value2"}]}; thank you
-
hey guys ive been trying to design this form validation class for my framework but im having a problem with the line public static function is_valid($method = $_POST) if anyone can help please <?php class Form extends Form_Exception { protected $_fields = array(); protected $_validation_messages = array(); protected $_form_errors = 0; public function add_validation($field_name, $valiidation_type, $validation_message = null) { $this->_fields[$field_name]['name'] = $field_name; $this->_fields[$field_name]['validation_type'] = $validation_type; $this->_fields[$field_name]['validation_message'] = $validation_message; } public static function is_valid($method = $_POST) { $fields = $this->_fields; foreach ($fields as $field) { $field_value = $method[$field['name']]; $validation_type = $field['validation_type']; $validation_message = $field['validation_message']; $validation = $validation_type. '_validation'; if ($this->$validation($field_value)) { $this->set_validation_message($validation_message); } } $validation_messages_count = count(get_validation_messages()); $this->set_form_errors($validation_messages_count); } public static function display_errors() { $validation_messages = $this->_validation_message; foreach ($validation_messages as $validation_message) { echo $validation_message; } } protected function set_validation_message($validation_message) { $this->_validation_messages[] = $validation_message return $this; } protected function set_form_errors($form_errors) { $this->_form_errors = $form_errors return $this; } protected function get_fields() { return $this->_fields; } protected function get_validation_messages() { return $this->_validation_messages; } }
-
thanks guys...one last thing...how can i convert a php array to a javascript array please?
-
is there a way to sort the array to please?
-
i have an array from a database that looks like this (below) but what i want is for the array to be sorted assedningly by the start position so the team with start position 1 will be 1st and so on...if anyone can help me on what i should do please...thank you Array ( [1] => Array ( [team_name] => A Team [team_nationality] => British [start_position] => 2 ) [2] => Array ( [team_name] => B Team [team_nationality] => British [start_position] => 1 ) [3] => Array ( [team_name] => C Team [team_nationality] => British [start_position] => 4 ) [4] => Array ( [team_name] => B Team [team_nationality] => British [start_position] => 3 ) )
-
oh i see now that its javascript i need thank you...can i still use that array for javascript?
-
im already using json_encode...im just having a problem running the script on value change
-
hey guys what im trying to do is to get the value from the query input field and when value changes it will load the json and just throw an alert...but its not...i know what im doing after the alert works its just im new to json and everything ive done looks right if anyone can help me to where i am going wrong please....thank you <!DOCTYPE html> <html> <head> <script src="media/scripts/library/jquery.js" type="text/javascript"></script> </head> <body> <form> <?php $array = array("users" => array("username" => "Destramic", "username" => "Process"), array("email" => "destramic@hotmail.co.uk", "email" => "pro@whatever.com")); ob_clean(); header('Content-Type: application/json'); json_encode($array); ?> <script> $(document).ready(function() { $('#query').keyup(function () { var post_string = 'query=' + $(this).val(); $.ajax({ type: 'POST', data: post_string, cache: false, dataType: 'json', url: 'json.php', timeout: '2000', error: function(data) { console.log(data); }, success: function(data) { alert('hi'); // match field value with array above } }); }); }); </script> <input name="query" id="query" type="text" /> </form> </body> </html>
-
hey guys i have a __call method in my class...the probelm im having is how to get the arguments into this line return $this->_db->$method($arguments); if arguments where "test1" and "test2" i want the call to do return $this->_db->$method("test1", "test2"); the code below will put all arguments into one if anyone can help me on how i can seperate please public function __call($method, $arguments) { if (method_exists($this->_db, $method)) { $arguments = implode(', ', $arguments); return $this->_db->$method($arguments); } }
-
yeah thats what i meant haha sorry...but this is what i decided to use afterall instead of having $this->_db as whatever the dabase type is ie. $this->_mysql etc <?php class Model { protected $_db; public function __construct() { $config = Registry::singleton()->config; $db_type = $config->db_type; $db_host = $config->db_host; $db_username = $config->db_username; $db_password = $config->db_password; $db_name = $config->db_name; $db_table = $this->get_table_name(); $this->_db = DB::factory($db_type, array('host' => $db_host, 'username' => $db_username, 'password' => $db_password, 'database' => $db_name), $db_table); } public function __set($column, $value) { $this->_db->$column = $value; } public function __call($method, $arguments) { if (method_exists($this->_db, $method)) { return $this->_db->$method($arguments); } } public function __get($property) { $property = '_' . $property; if (property_exists($this, $property)) { if ($property !== '$this->_request' || $property !== '$this->_responce') { return $this->$property; } } } protected function get_table_name() { $config = Registry::singleton()->config; $model_name = get_class($this); $model_prefix = $config->model_prefix; $prefix_length = strlen($model_prefix); $table_name = substr($model_name, 0, - $prefix_length); $table_name = strtolower($table_name); $table_name = Inflection::pluralize($table_name); return $table_name; } } ?>
-
thorpe im thinking it is possibly json i need? what i wanna do it get data from my mysql database...say users for instance...when typed into the search box the user will display in a table below search bar...like so user email -------- destramic email etc...
-
ok thank you i think that is what i need...bascially i dont want the data you enter to show under the text filed as shows but i want the data to show in a table underneath the form field where you type the search...and the data will come from mysql database http://www.devbridge.com/projects/autocomplete/jquery/#demo
-
hey guys i want to create a script a bit like how google operates on its home page....you type in a search and before you know it the data is there without pressing enter. i would like to know how this can be done please if anyone can help me please
-
oh ok thanks...i was just wondering if i could assing a value to a static property without actually defying it like protected static $_static;
-
yeah you did sorry judda...ok well ive been trying to work how to merge both together on what you've said and at the moment ive only dont team and single tounranaments singlerly hear you'll find a query for single tounrnaments then team tournaments...if you can explain or help me on how i can merge to create one query which having a where torunament_type = 'Single' / 'Team' and it just selects from a possible id thanks for your help judda SELECT t.tournament_id, t.game_id, t.tournament_name, t.tournament_type, t.tournament_size, ptm.player_id, ptm.starting_position, p.player_name, u.user_nationality FROM tournaments t LEFT JOIN player_tournament_mappings ptm ON ptm.tournament_id = t.tournament_id LEFT JOIN players p ON p.player_id = ptm.player_id LEFT JOIN user_player_mappings upm ON upm.player_id = ptm.player_id LEFT JOIN users u ON u.user_id = upm.player_id WHERE t.tournament_Type = 'Single' AND t.tournament_id = 1 SELECT t.tournament_id, t.game_id, t.tournament_name, t.tournament_type, t.tournament_size, ptm.player_id, ptm.starting_position, tm.team_name, tm.team_nationality FROM tournaments t LEFT JOIN player_tournament_mappings ptm ON ptm.tournament_id = t.tournament_id LEFT JOIN player_team_mappings ptm2 ON ptm2.player_id = ptm.player_id LEFT JOIN teams tm ON tm.team_id = ptm2.team_id WHERE t.tournament_Type = 'Team' AND t.tournament_id = 2
-
hey guys im trying to produce a tournament bracket and im having a problem with the query below... basically when a tournament is created you can select single or team if single then get the player id and match to a player if team then match team to player_id if someone could help me on why the query is returning errors SELECT t.tournament_id, t.game_id, t.tournament_name, t.tournament_type, t.tournament_size, CASE t.tournament_type WHEN 'Single' THEN ptm.player_id, ptm.starting_position p.player_name, u.nationality, FROM tournaments t LEFT JOIN player_tournament_mappings ptm ON ptm.tournament_id = t.tournament_id LEFT JOIN players p ON p.player_id = ptm.player_id LEFT JOIN user_player_mappings upm ON upm.player_id = ptm.player_id LEFT JOIN users u ON u.user_id = upm.player_id WHEN 'Team' THEN END WHERE t.tournament_id = 1 thank you