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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

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