Jump to content

totalx

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

totalx's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Ah ha! I had to do some massive surgery on the way I had it set up but it's now functioning. I had an idea like that in my mind but I guess I couldn't exactly see it in my head until you posted it. Thanks for your assistance!
  2. Quite frankly they both do the same thing. By standards, I believe yes, it should be checked="checked" and I have made that change. But it is still populating every box as checked, and I am stumped as to why. Each of those values in the array are columns in my database. I wasn't sure how to effectively go about getting the value of each one, individually. I feel like I am just missing something small, seeing as how $value is returning all 4 that I have marked in the DB. I'm going to keep plugging away at it. Any other suggestions or ways to possibly clean this up would be appreciated
  3. Hello again, I have a form that has several options to select features of a computer (vga, dvi, ethernet, modem, zip, etc.) through checkboxes. In the database, it is stored as a 0/1 (false/true). What I am working on is an edit form to make changes if necessary, but I am having trouble populating the checkboxes that are marked as true already. while($cmp = $_SESSION['DB']->fetch_array($cmpQ)){ $chkbxs = array('vga', 'ps2', 'usb', 'firewire', 'ethernet', 'cddvd', 'fdd', 'zip', 'dvi', 'serial', 'sound', 'wireless', 'modem', 'smartm'); foreach ($chkbxs as $value) { $check=""; if ($cmp[$value] == 1) { $check = "checked"; echo ''.$value.' <br/>'; } ...more code, form below This does it it should. I have an entry with vga, firewire, smartm, and zip selected, and $value returns that properly. In the form, this is how I have it set up. echo '<input type="checkbox" name="hardware[]" value="vga" '.$check.'>'; Right now, every checkbox is selected, meaning that for some reason, $cmp[$value] == 1 is affecting all checkboxes in the form, even though it is only returning the 4 that are marked as selected when I echo $value. Am I missing something minor or am I going about this the wrong way?
  4. Alright. I will give that a shot. I have found a temporary work around but I'll definitely try that, because the work around is not all that efficient. Thanks for your help
  5. Thank you, Psycho. I've made a few changes, but still needs some work. Here's what I have - I originally only have the option for 1 harddrive to be added. If another one is needed, the user can press a button and a javascript function makes an additional set appear. Where I am having trouble is if I have more than 1 harddrive trying to be added. I need it to distinguish between 2 different drives. They each have their own column in the database. So hdd[0] cannot be mixed with hdd[1], and so forth. I'm sorry if this is confusing and I'm not explaining it well. Somehow in my foreach loop I need to include the drive number (for inserting into the table) and looping through ALL of the inputs, not just the last that I submitted. Right now, I am only getting the 2nd or 3rd harddrive's info even if the 1st form is filled out.
  6. beegro: Thank you. I will try that and see what results I receive. Laffin: I see that I am getting the correct data outputted when I only have ONE harddrive. When there are two harddrives, it does not seem to iterate through the first and instead only returns the second. I will keep toying with it and let you know if I come to a conclusion. I just want to make sure that I am not missing something. Like I said, I am not overly experienced with multidimensional arrays, and I am having trouble returning values from two different harddrives. I suppose I failed to mention that I am trying to submit this into a MySQL database, too. I have been programming for several years now and have strangely never come across a scenario like this and I just feel like I'm missing something very minute! Thanks again.
  7. Hi everybody, I generally find any assistance that I need on various sites, but this one has me stumped. I'm not overly advanced with my use of arrays, so I'd like some help here if anyone knows what I am looking for. I have a form that I would like to submit to a MySQL database. In that form, there is the ability to add up to 3 harddrives: Brand: <input type="text" name="hdds[0][hddbrand]" id="hddbrand"><br/> Model and/or size,type: <input type="text" name="hdds[0][hddtype]" id="hddtype"><br/> SN: <input type="text" name="hdds[0][hddsn]" id="hddsn"><br/> Notes: <input type="text" name="hdds[0][hddnotes]" id="hddnotes" size="50"> Obviously the next harddrive would be hdds[1][hddbrand], etc. I am having an awful time looping through this to get more than 1 harddrive's information, however. I've tried foreach embedded in foreach and been messing around with this for a good 3-4 hours now and I feel like I am just missing something. I've got this right now to debug: foreach($_POST['hdds'] as $key => $a) { $hddbrand = $a['hddbrand']; } my print_r($a) comes up with the following: Array ( [hddbrand] => Toshiba [hddtype] => Shaba 500gb [hddsn] => 5fu8bvw4 [hddnotes] =>none ) 1 Good. That's what I want. But I need some help constructing my array/loop to get the values of more than 1 drive should I have to enter information for more than 1 drive. I feel like I am close, but I am just not getting what I need. I have not had to work with multidimensional arrays before and they are proving to be more trickier than I expected. Any help would be enormously appreciated! Patrick
×
×
  • 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.