Jump to content

explode a large array to make a table + form


Beazer

Recommended Posts

Hey all, i'm pretty new to PHP so my boss threw me into the deep end with a project and I'm kinda stuck on one spot.

I have a table with about 20 fields to update a MySQL table.  The original values are plugged into the fields and users can update them with the Update button.

This is all Car data and I just wanted an easier way to code the table instead of typing out each <td> etc.

It was suggested I explode an array and make a foreach loop to accomplish this but being the newbie I am, I'm not sure how.

[code]
while(list($CARID, $TRIM_ID, $POSITION, $OE_TIRESIZE_DISP, $OVERALL_TIRE_DIA, $GROSS_WT, $SERVICE, $AIRPRESS, $RIM_DIAMETER, $RIM_WIDTH, $MIN_RIM_WIDTH, $MAX_RIM_WIDTH, $OE_WHEEL_DISP, $TORQUE, $BOLTS, $BOLT_CIRCLE_MM, $BOLT_CIRCLE_INCH, $WHEEL_BOLT_CIRCLE_TEXT, $LUGSIZE, $BOLT_HEX_SIZE, $HUB_BORE, $OFFSET, $OFFSET_MIN, $OFFSET_MAX) = mysql_fetch_row($result1)) {
    $bgcolor = (++$cnt % 2 == 0) ? "bgcolor=#E6E6E6" : "";
            $front_info = array($CARID, $TRIM_ID, $POSITION, $OE_TIRESIZE_DISP, $OVERALL_TIRE_DIA, $GROSS_WT, $SERVICE, $AIRPRESS, $RIM_DIAMETER, $RIM_WIDTH, $MIN_RIM_WIDTH, $MAX_RIM_WIDTH, $OE_WHEEL_DISP, $TORQUE, $BOLTS, $BOLT_CIRCLE_MM, $BOLT_CIRCLE_INCH, $WHEEL_BOLT_CIRCLE_TEXT, $LUGSIZE, $BOLT_HEX_SIZE, $HUB_BORE, $OFFSET, $OFFSET_MIN, $OFFSET_MAX);

            $html .= "<td align=right><table width=100%><tr><td align=right>Position</td><td>\n$POSITION</td></tr>";
            $html .= "<tr><td align=right>OE Tiresize Disp.</td><td><input type=\"text\" name=\"OE_TIRESIZE_DISP\" value=\"$OE_TIRESIZE_DISP\"></td></tr>";
            $html .= "<tr><td align=right>Overall Tire Diameter</td><td><input type=\"text\" name=\"OVERALL_TIRE_DIA\" value=\"$OVERALL_TIRE_DIA\"></td></tr>";

[/code]

So I made an array with all of the fields that need to be in the form and below it is what I actually have now to make this table (I left out the other 20 fields but you get the idea). 

My question here is how do I use that array and "explode" to write one line that will echo out each value within that HTML to make the table row and form field?

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.