Jump to content

New to php, is there a way to simplify this code?


munchkinz

Recommended Posts

I don't think many people are going to go through 54kb and 8kb worth of code.  If you post specific examples then we could easily help you. 

 

There are general rules of thumb to optimize code.  Do a search on here for some useful tips, here is a recent thread:

http://www.phpfreaks.com/forums/miscellaneous/how-to-optimize-a-php-script/msg1514604/#msg1514604

ok thank you.

 

Here is a snippet of the code

<tr><td><label for="LRSofa" id="LRSofa">Sofas:</label></td><td><select name="LRSofa">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select></td>
<td><label for="LRArmChair" id="LRArmChair">Arm Chairs:</label></td><td><select name="LRArmChair">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select></td>
<td><label for="LROtherChair" id="LROtherChair">Other Chairs:</label></td><td><select name="LROtherChair">
<option value="0">0</option>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
</select></td>
<td><label for="LRSCabinet" id="LRSCabinet">Small Cabinets:</label></td><td><select name="LRSCabinet">

There are about 150 of these.

 

and this is some snippets of the code i am trying to simplify

$LRSofa = Trim(stripslashes($_POST['LRSofa'])); 
$LRArmChair = Trim(stripslashes($_POST['LRArmChair'])); 
$LROtherChair = Trim(stripslashes($_POST['LROtherChair'])); 
$LRSCabinet = Trim(stripslashes($_POST['LRSCabinet'])); 


$Body .= "Living Room: ";
$Body .= "\n";
$Body .= "Sofas: ";
$Body .= $LRSofa;
$Body .= "\n";
$Body .= "Arm Chairs: ";
$Body .= $LRArmChair;
$Body .= "\n";
$Body .= "Other Chairs: ";
$Body .= $LROtherChair;
$Body .= "\n";
$Body .= "Small Cabinets: ";
$Body .= $LRSCabinet;
$Body .= "\n";
$Body .= "Large Cabinets: ";
$Body .= $LRLCabinet;
$Body .= "\n";


// send email 
$success = mail($EmailTo, $Subject, $Body, "From: ". $FName ." ". $LName ." <". $Email.">");


 

please ask if you need any more info

 

thank you

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.