Jump to content

karenn1

Members
  • Posts

    177
  • Joined

  • Last visited

    Never

About karenn1

  • Birthday 02/23/1984

Profile Information

  • Gender
    Female
  • Location
    South Africa

karenn1's Achievements

Member

Member (2/5)

0

Reputation

  1. Hey everyone, I hope someone can help me. I have a form with a table like this: <table width="850" border="0" align="left" cellpadding="5" cellspacing="0" id="mytable"> <tr> <td width="5%" align="left"><strong>Date</strong></td> <td width="21%" align="left"><input name="admission-date[]" id="admission-date" size="15"/></td> <td width="10%" align="left"><strong>Hospital</strong></td> <td width="16%" align="left"><input name="admission-hospital[]" id="admission-hospital" type="text" size="15" /></td> <td width="8%" align="left"><strong>Doctor </strong></td> <td width="17%" align="left"><input name="admission-doctor[]" id="admission-doctor" type="text" size="15" /></td> <td width="8%" align="left"><strong>Details</strong></td> <td width="15%" align="left"><input name="admission-details[]" id="admission-details" type="text" size="15" /></td> </tr> </table> And this is the PHP to store the info: //multiple entries for admission history //admission-date $array1 = $_POST["admission-date"]; $counter1 = 0; $string_to_db1 = ""; $separator1 = ""; foreach($array1 as $item1){ if($counter1 <> 0) { $separator1 = "|"; } $string_to_db1 .= "$separator1$item1"; ++$counter1; } /////// //admission-hospital $array2 = $_POST["admission-date"]; $counter2 = 0; $string_to_db2 = ""; $separator2 = ""; foreach($array2 as $item2){ if($counter2 <> 0) { $separator2 = "|"; } $string_to_db2 .= "$separator2$item2"; ++$counter2; } /////// //admission-doctor $array3 = $_POST["admission-doctor"]; $counter3 = 0; $string_to_db3 = ""; $separator3 = ""; foreach($array3 as $item3){ if($counter3 <> 0) { $separator3 = "|"; } $string_to_db3 .= "$separator3$item3"; ++$counter3; } /////// //admission-details $array4 = $_POST["admission-details"]; $counter4 = 0; $string_to_db4 = ""; $separator4 = ""; foreach($array4 as $item4){ if($counter4 <> 0) { $separator4 = "|"; } $string_to_db4 .= "$separator4$item4"; ++$counter4; } /////// I've used jQuery to add a row to the table by clicking on a Plus sign. All of this works perfectly and the data is stored separated with a pipe, ie. 2012-08-12|2012-08-21, etc. The issue I'm having is pulling this back into a page where it can be edited. I'm thinking of using explode but I don't know how to get the table layout as I had it originally as shown above. How do I get it to loop as such and have the label next to the value? Thanks in advance, Karen
×
×
  • 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.