Jump to content

sw45acp

Members
  • Posts

    67
  • Joined

  • Last visited

    Never

Everything posted by sw45acp

  1. Ok that looks like it will do the trick. Thanks!
  2. So you mean encode javascript in the server side where the response text comes from? Is http://www.prototypejs.org/learn/json this what you mean?
  3. Ahh, youre right i posted this in the wrong forum. I hate it when I do that. yes this needs to be done with javascript since its being handled in the ajax request. Sorry im kind of a noob.
  4. Its an ajax response text, from an ajax request using prototype. The text comes back from the request from the server like "part1=true;part4=false". I need to be able to break it into an array for sorting.
  5. Hi, I have an ajax response text string that looks something like this: "part2=true;part7=false;part9=false;..." I would like to turn this string into an array, that looks like this: part2 = true part7 = false part9 = false I know to use the explode function, but that will only break it into an array either by using the "=" or ";" as a delimiter.... Thank you for any help.
  6. I just wanted to reply to you again and say thank you for your help. You're outline pointed me in the correct direction and yes I had to use array_key_exists() instead of in_array(). It is very annoying that unchecked checkboxes are not sent to the php script, and because they are all dynamically generated, making a hidden field for each one would be impossible. This was my finished code, and it works great! $item_id = $_POST['item_id']; $q = mysql_query("SELECT * FROM table"); //create an array to hold keys (id of each checklist item) from database $array_keys = array(); while($rows = mysql_fetch_array($q)) { /*make it an associative array, filling it with the id of the item as its key, and the value as blank*/ $array_keys[$rows['id']] = ''; } //now its time to do the comparison with the array from the database and from the form foreach ($array_keys as $key => $value) { if (array_key_exists($key,$item_id)) { /*check if the key exists from the database in the form array 'haystack' if it does, and its id and a value of 1 (meaning its complete), to a new array, if not, and its id and a value of 0*/ $new_array[$key] = '1'; }else{ $new_array[$key] = '0'; } } //print_r($new_array); foreach($new_array as $id=>$complete) { //here, for every checkbox, update database }
  7. Ok, thank you, I'll work on this for a while.
  8. would it be too much to ask if you could provide an example to start me off? thank you so much.
  9. Let me show you an example of what I mean. From the new grand theft auto IV video game, there is a checklist to complete stuff (missions, etc). http://www.gta4.tv/100percent.php This website has it set up so users can check off what they have done. What if they accidently checked off one by mistake? So naturally you would uncheck it because it is not complete and resubmit, but php does not recognize checkboxes that are not checked. Sorry I'm really bad at wording things.
  10. while that is true, what do I do if the item is already checked as complete when it is written to the page. I have it set so that if it is already complete it is checked off. If the person decides its not complete, and unchecks it, php will not recognize a checkbox that is unchecked so it will skip over it
  11. Hi, I have a checklist that is generated from a server that allows users to check stuff off as they get them done. Because each user will have a different number of checkboxes, I use an array in the checkbox name like we are all supposed to do and put the id of that item inside the brackets when its generated from the server, like this: <input type="checkbox" name="item[9]" value="1" /> 1 stands for the item being complete, 0 stands for the item being incomplete And I process it like this: $item_list = $_POST['item']; foreach($item_list as $id => $item) { $q = mysql_query("UPDATE completion SET `complete` = '$item' WHERE `id` = '$id'"); } The problem here is that when someone decides that an item is not complete and unchecks it, the loop skips over it, and it still stays as complete. That is what I'm trying to fix. Thank you for any help
  12. I've gotten a little bit farther... function wordWrap(string,width) { var output = ''; for (var i = 0; i < string.length; i ++) { output += string.substr(i,1); if (i == width) { if (string.charAt(i) == ' ' ) { output += '<br />'; }else{ //takes the current position and pulls out everything before it var part = string.substr(0,i); //from that string, pulls out the last space var pos = part.lastIndexOf(' '); //show it alert(pos); //how to insert it into that position? } } } alert(output); } var stuff = "one two three four five six seven eight nine ten eleven twelve thirteen fourteen fifteen sixteen seventeen"; wordWrap(stuff,20);
  13. Hi, I wish to write a function to word-wrap a string to a certain width, and if a word breaks that width, I want it to reverse course and find the nearest space, so that way no words are broken apart. I've gotten far, I just can't figure out how to go backwards with it. function wordWrap(string,width) { var output = ''; for (var i = 0; i < string.length; i ++) { output += string.substr(i,1); if (i == width) { if (string.charAt(i) == ' ' ) { output += '<br />'; }else{ //go backwards and try to find a space //HOW?? } } } alert(output); } Thank you for your help.
  14. Ok that's good advice. Keeping two files updated and having to switch back and forth between them is a lot of needless work.
  15. Yes I will make sure to remove that from anything that is not in development. I will probably keep two classes, one for development and one for the real deal.
  16. Hi, I am looking for a way to shorten the amount of code that I have to write when only querying and retrieving from a database, so I have created this very simple class to do so. I've looked at several other classes for this, however they are all to complex. I would like your opinion on what I have written, and if it can be revised/rewritten I am all ears and open for suggestions/criticism. Thank you. class queryHelper { function __construct() {} /** * Simply executes a query * @param q: A query string * @param type: 0 = Just the query, nothing more * 1 = Return mysql_fetch_array * 2 = Return mysql_num_rows */ public function query($q,$type = 0) { $query_id = mysql_query($q); if (!$query_id) { die('The following query was attempted: '.$q.'<br />Error: '.mysql_error()); } switch($type) { case 0: return $query_id; break; case 1: return $this->fetch($query_id); break; case 2: return $this->numRows($query_id); break; } } /** * Returns a mysql_fetch_array result. */ public function fetch($q_id) { $recordset = array(); while($rows = mysql_fetch_array($q_id)) { $recordset[] = $rows; } return $recordset; } /** * Returns a mysql_num_rows result. */ public function numRows($q_id) { return mysql_num_rows($q_id); } }
  17. Hi, I have the following javascript: function createDiv() { var newDiv = document.createElement("div"); newDiv.setAttribute("id","box"); document.body.appendChild(newDiv); var box = document.getElementById("box"); } and html: <input type="button" value="Create Div" onclick="createDiv()" /> that creates a new div on the page. What I would like is for this div to completely disappear when a user clicks anywhere else on the page. What I mean can generally be seen on any javascript date picker/calendar for forms. Any help is appreciated, thank you.
  18. Ok this appears to work great. Thank you both for your help.
  19. time() spits out something like "1269007275". Should I format the date columns to be "TIME" instead? When I insert something from time() it says data type fractured (in phpMyAdmin). So should I format the "date" and "due_date" columns to simply be an integer with 10 as a length?
  20. I have a table that stores college assignments. In the table there are three columns: assignments, date, and due date, where the "date" is the date that it was assigned or handed out, and the "due date" is the date that the assignment is due. Both the "date" and "due date" columns are formatted with the mysql date format. What I would like to do is retrieve all assignments where today's date is between those two date columns. This doesn't work: $date = date("Y-m-d"); $q = mysql_query("SELECT * FROM `table_college` WHERE `date` >= '$date' AND `due_date` <= '$date'"); Any help would be appreciated, thank you.
  21. ahh, that worked. Thank you.
  22. Hi, I wish to align my tab menu all the way to the left or center it. It aligns fine to the right fine with no extra space, but on the left it leaves extra space. I'm happy with it so far, but I just can't seem to figure this one out. It is not a float left menu, either. Here is a link to the page where the tabs are on so it can be seen. Here is my css: body { margin:0px; padding:0px; font-family:Tahoma, Geneva, sans-serif; background-color:#000000; } ul.menu_tabbed { margin:10px 0px 0px 0px; list-style-type:none; border-bottom:2px solid #0F0; padding-bottom: 1px; text-align:left; } ul.menu_tabbed li { display:inline; } ul.menu_tabbed li a:link, ul.menu_tabbed li a:active, ul.menu_tabbed li a:visited { color:#09F; text-decoration: none; background: #000000; border: 1px #CCCCCC solid; border-bottom: none; padding: 3px 14px 1px 14px; } ul.menu_tabbed li a.selected { color:#C60; background:#000; border: 1px #999999 solid; border-bottom: 1px #000000 solid; padding: 7px 14px 2px 14px; } ul.menu_tabbed li a:hover { color:#09F; text-decoration:underline; padding: 7px 14px 2px 14px; } And my html: <ul class="menu_tabbed"> <li><a href="#">Home</a></li> <li><a href="#">Preferences</a></li> <li><a href="#" class="selected">Search Transactions</a></li> <li><a href="#">Add Transaction</a></li> <li><a href="#">Logout</a></li> </ul> I appreciate any help offered.
  23. Well, what is your means of data storage for this? If you are using mysql, you could have a separate table for students, and another for alumni/mentors, with each of your descriptions being the column headers. From there, you could extract information and sort based on criteria from that information.
  24. True, I think I will just use the php optimize table syntax after any deletion is made.
  25. I'm interested in knowing which is a better alternative when working with mysql. If a record needs to be deleted using a php script, is it better to actually delete the record itself or instead mark it as deleted, such as having an extra column where deleted = 1 and active = 0. Advantages of not actually deleting the record means that if the deletion was accidental, its still there. However, a disadvantage is that more space is taken up. Fully deleting a record leaves overhead in the table, and if the records have an index that is auto incremented, a number is wasted, not that it means very much. But if records will be deleted frequently the overhead will get quite large, and can be annoying to have to optimize the table. What do you guys think is the better alternative?
×
×
  • 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.