d2jsp
Log InRegister
d2jsp Forums > Off-Topic > Computers & IT > Programming & Development > Breaking Up A In-line Html File With If Statements
Add Reply New Topic New Poll
Member
Posts: 18,138
Joined: May 31 2010
Gold: 7.27
Feb 13 2017 10:25am
Hey guys quick question..

I have some in line html in my php file and I need to break it to put in if statements but im not sure how to keep all its info but broken up

for example (i shortened some code)
Code


$myLocationId



$header .= "<body>

<div class='invoice-box'>
<div style='float:right; font-size:14px;'>
<h2>Purchase Order</h2>
<strong>Po Number</strong> : $myPO->id<br>
<strong>Date</strong>: $myPO->date<br>
<strong>Date Needed</strong> : $myPO->date_needed<br>
<strong>Chg/Can</strong>: $myPO->status

</div>
<img src='../images/$myLogoName->config_value'>



<table>

<tr class='information'>
<td colspan='2'>
<table>
<tr>
<td>
<strong>Supplier: </strong> <br> $mySupplier->company <br>
$mySupplier->address <br>
$mySupplier->city, $mySupplier->state $mySupplier->zip<br><br>
<strong>Attn</strong> <br>
$mySupplier->first_name $mySupplier->last_name <br>
$mySupplier->email<br>

</td>


<td>
<strong>Deliver To:</strong> <br>
$myLocation->name<br>
$myLocation->address<br>
$myLocation->city , $myLocation->state, $mySupplier->zip
<br>
<br>
<strong>$doc_appt_needed</strong>
<strong>$myPO->delivery_locating </strong>

" . $myPO->getLocationPOtext() . "
</td>




</tr>
</table>

";



and I need it to look like this

Code


$myLocationId



$header .= "<body>

<div class='invoice-box'>
<div style='float:right; font-size:14px;'>
<h2>Purchase Order</h2>
<strong>Po Number</strong> : $myPO->id<br>
<strong>Date</strong>: $myPO->date<br>
<strong>Date Needed</strong> : $myPO->date_needed<br>
<strong>Chg/Can</strong>: $myPO->status

</div>
<img src='../images/$myLogoName->config_value'>



<table>

<tr class='information'>
<td colspan='2'>
<table>
<tr>
<td>
<strong>Supplier: </strong> <br> $mySupplier->company <br>
$mySupplier->address <br>
$mySupplier->city, $mySupplier->state $mySupplier->zip<br><br>
<strong>Attn</strong> <br>
$mySupplier->first_name $mySupplier->last_name <br>
$mySupplier->email<br>

</td>

IF( $myLocationID == 1){
<td>
<strong>Deliver To:</strong> <br>
$myLocation->name<br>
$myLocation->address<br>
$myLocation->city , $myLocation->state, $mySupplier->zip
<br>
<br>
<strong>$doc_appt_needed</strong>
<strong>$myPO->delivery_locating </strong>

" . $myPO->getLocationPOtext() . "
</td>
}


else{

you use delivery location 2.
}


</tr>
</table>

";

any help <3 :hail:
Member
Posts: 18,138
Joined: May 31 2010
Gold: 7.27
Feb 13 2017 10:48am
nevermind, I am an idiot on a monday morning. If admin see's, please close.

my fix:
$location_address = " ";
if($myPO->location_id == 1){
$location_address = " address code ";
}
else if ($myPO->location_id == 2) {
$location_address = "see other location";
}
and passed the variable to the area of the html.

sorry for spam post.
Member
Posts: 3,197
Joined: May 4 2013
Gold: 1,457.00
Feb 13 2017 01:26pm
Don't mix php and html, use templates
Member
Posts: 18,138
Joined: May 31 2010
Gold: 7.27
Feb 13 2017 03:18pm
Quote (nuvo @ Feb 13 2017 03:26pm)
Don't mix php and html, use templates


the company I work for does (to an extent) but some of the older files still are straight PHP, with design in-line HTML.
Member
Posts: 5,167
Joined: Nov 23 2006
Gold: 11.01
Feb 14 2017 03:28pm
Quote (Trig @ Feb 13 2017 04:18pm)
the company I work for does (to an extent) but some of the older files still are straight PHP, with design in-line HTML.


Fix it. Don't leave it for someone else to fumble around in later :)
Member
Posts: 10,570
Joined: May 24 2016
Gold: 0.00
Feb 21 2017 10:20am
git gud
Go Back To Programming & Development Topic List
Add Reply New Topic New Poll