Jump to content

dadamssg87

Members
  • Posts

    218
  • Joined

  • Last visited

Everything posted by dadamssg87

  1. finally figured it out...not sure if its the cleanest but it works <?php if(isset($_POST['add_ons'])) { foreach($_POST['add_ons'] as $key => $id) { $addons[] = $id; //create array of checked add_ons } } if(isset($add_ons)) { echo "<fieldset><legend>Add-Ons</legend>"; foreach($add_ons as $id => $title) { if(isset($addons)) //see if any add_ons were checked { if(in_array($id,$addons)){$check = TRUE;}else{$check = FALSE;} //if this add_on is in the addons array -> check, else -> don't } else //no addons were checked { $check = FALSE; } echo "".form_checkbox("add_ons[]", $id, $check)." $title.<br><br>"; } echo "</fieldset>"; } ?>
  2. I've been working on this for some time and can't seem to get it. I have take and array with the id and title as items in it. Like the following (using codeigniter) <?php $username = (int) $this->session->userdata('username'); $query = $this->db->query("SELECT * FROM Add_ons WHERE username = '$username' ORDER BY created DESC"); foreach($query->result() as $row) { $add_ons[$row->id] = $row->title; } if(isset($add_ons)) { return $add_ons; } ?> now i'm trying to display a form where each add_on has its own checkbox. like the following <?php if(isset($add_ons)) { echo "<fieldset><legend>Add-Ons</legend>"; foreach($add_ons as $id => $title) { $check = TRUE; // <-- part i need help with. echo form_checkbox("add_ons[$id]", "yes", $check)." $title.<br><br>"; } echo "</fieldset>"; } ?> codeigniter takes the $check value and if its true will check the box, if false, leave it unchecked. Also, the first parameter in codeigniter's form_checkbox() function is the input name. Now i'm trying keep the correct value (true/false) based on the user's selection if the user submits the form and there's an error. So i tried this...but it's not working <?php if(isset($add_ons)) { echo "<fieldset><legend>Add-Ons</legend>"; $num = 0; foreach($add_ons as $id => $title) { $num++; if($_POST["add_ons[$id]"] == "yes")// || strtolower($_SERVER['REQUEST_METHOD']) !== 'post') { $check = TRUE; } else { $check = FALSE; } echo form_checkbox("add_ons[$id]", "yes", $check)." $title.<br><br>"; } echo "</fieldset>"; } ?> i'm getting an "Undefined index: add_ons[2]" php error. anybody have suggestions?
  3. awesome thanks...i also figured out i could do it this way...but in() is cleaner. thanks!
  4. I remember doing this a while back just can't remember how. It would delete all rows that matched the group and any date defined in the query. Yeah i'm using mysql_error and also double checking in the phpadmin sql box. It doesn't return any errors. Just no rows get deleted.
  5. I have the table with the following structure id bigin(11) auto_increment group bigint(11) date date I'm trying to delete several dates within the same group. So i may be deleting one row or 100..who knows. I use a function that takes a dates array and then converts into into sql language. Its below <?php function array_to_sql($array) { $first = $array['0']; $sql = "AND date = '$first' "; $shift = array_shift($array); if(!empty($array)) { foreach($array as $key => $date) { $sql .= "AND date = '$date' "; } } return $sql; } ?> So if i have an array like the following Array ( [0] => 2011-07-27 [1] => 2011-07-28 [2] => 2011-08-03 [3] => 2011-08-05 ) using my function will spit out this query doesn't delete anything and i don't know why. If only use one date the deletion works for that one date but i want to be able to input several dates anybody know what im doing wrong?
  6. ehh i just used a foreach. don't know why the heck i was trying to use implode or explose. so much easier this way, except apparently my sql syntax isn't correct...on to the mysql board <?php function array_to_sql($array) { $first = $array['0']; $sql = "AND date = date($first) "; $shift = array_shift($array); if(!empty($array)) { foreach($array as $key => $date) { $sql .= "AND date = date($date) "; } } return $sql; } ?>
  7. I had help writing the function below which takes an array and converts into "AND date = '$array_item'" for each item in the array. I'm trying to figure out how to change the function to output this instead: "AND date = date($array_item)". Anybody know how to do this? <?php function array_to_sql($array) { $count = count($array); if($count == 1) { $one = $array['0']; return "AND date = '$one'"; }else { $one = $array['0']; $shift = array_shift($array); return "AND date = '$one' AND date = '".implode("' AND date = '",$array)."'"; } } ?>
  8. oh ok..so its based on your system and theres not a set numerical limit for items in an arrays?
  9. very true. Thanks for advice
  10. What do you guys recommend the biggest file size to be uploaded for images? I'm getting started developing a sort of slideshow app. I don't really know what's a normal image file size and whats a gigantic image file size.
  11. wow...didn't think about that. thanks!
  12. how would i sort the $room array by $room[$key]['available']?
  13. no, i know that script that won't work. I think it needs to be some kind of loop instead of a foreach. I can't wrap my head around how to put it in a loop though.
  14. I'm trying to order a foreach based on a certain item in the array of an array. So like <?php foreach($room as $key => $value) { if($room[$key]['available'] == "Open") { //code to display array }else { //wait till all "Open" items are displayed and then display non-"open" items } } anybody have any suggestions on the best way to tackle this?
  15. I am very unfamiliar with working with php and images. Can php parse through an image pixel by pixel and return the hex value of it?
  16. Absolutely nothing. I only want to store Customer name, transaction ID, and the amount but since the POST has cardholder data, that requires my server and code to be PCI compliant...which is a headache.
  17. i can't modify authorize.net's code...
  18. This may be a long shot but is there a way to configure your server to disable certain POSTs? I'm working with the Authorize.net SIM API which after a successful transaction you can get authorize.net to POST data to a particular web page. The POST sends back customer name, amount of transaction, date, billing information, shipping information, and it also post back the credit card like so "XXXXXXXX3043". To limit my exposure to any kind of credit card information i'd rather just disable the $_POST['x_card_number'] that gets posted. Is that possible?
  19. hmm i never thought of that @xylex. I looked at hostgator's reseller program but i couldn't find the the how much money you make per hosting account sold...
  20. Is it illegal for me to obtain a hosting account from a company and then design a client's website and then charge them for me to host it onto my hosting account? Obviously the hosting provider would like to have each website have their own account. I'm wondering if it's legal or not.
  21. I'm trying to embed a simple google map on my web page. Have they removed the simple way to do this now? You use to be able to type in the address of a place in google and it would show the map and there was a "Link" button and it would show you some code to copy/paste(an iframe) into your web page. Is that gone? do you have to use their map API now?
  22. Is there a line of code or something you can use to check if you have Mcrypt installed?
×
×
  • 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.