Displaying a user's social media information This is for a page where it displays some social media information for that user.

I would like to improve the following code that I posted below.  It does the job perfectly, but I just feel like it could definitely be improved.  I could easily leave it the way it is but I am trying to learn and that's why I would like to get suggestions from experienced programmers.

&lt;?php
if($facebook &amp;&amp; !$twitter_username || !$facebook &amp;&amp; $twitter_username) {
    $width = "490";
} else {
    $width = "930";
}
?&gt;

&lt;div id="content"&gt;
&lt;div style="width:&lt;?=$width;?&gt;px;margin:auto;"&gt;
    &lt;?php if($facebook) { ?&gt;&lt;div class="buttons"&gt;&lt;img src="images/facebook_icon.png" class="fb" /&gt; &lt;p&gt;&lt;em&gt;Like Us&lt;/em&gt;&lt;br /&gt;on Facebook&lt;/p&gt;&lt;/div&gt;&lt;?php } ?&gt;
    &lt;?php if($twitter_username) { ?&gt;&lt;div class="buttons"&gt;&lt;img src="images/twitter_icon.png" class="twitter" /&gt; &lt;p&gt;&lt;em&gt;Follow Us&lt;/em&gt;&lt;br /&gt;on Twitter&lt;/p&gt;&lt;span&gt;@&lt;?=$twitter_username;?&gt;&lt;/span&gt;&lt;/div&gt;&lt;?php } ?&gt;
&lt;/div&gt;
&lt;br class="clear" /&gt;

&lt;?php 
if($twitter_username) {
    if($display_tweets) {
 ?&gt;
&lt;div class="tweet"&gt;
    &lt;h2 class="twitter_feed white_textshadow"&gt;Latest Tweet&lt;/h2&gt;
    &lt;div class="feed"&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;?php 
    }

} 
if(!$display_tweets || !$twitter_username) {
    if($website_url) { 
?&gt;
    &lt;h2 class="visit white_textshadow center"&gt;&lt;em&gt;Visit Our Website&lt;/em&gt;&lt;br&gt;www.&lt;?=$website_url;?&gt;&lt;/h2&gt;
&lt;?php 
    }
}
?&gt;
&lt;/div&gt;


In the database there are 4 fields:  


Facebook (NULL or 1)
Twitter username (NULL or username)
display_feed (NULL or 1)
Website URL (NULL or URL domain.com format)
Style (PHP)


At the beginning, the test seems pretty weird but in any case, I usually prefer  

$var = (condition) ? val1 : val2;


over 

if(condition) {
    $var = val1;
} else {
    $var = val2;
}

You can replace

if(condition1) {
    if(condition2) {
        stuff();
    }
}


with

if(condition1 &amp;&amp; condition2) {
    stuff();
}



On top of that, the if(!$display_tweets || !$twitter_username) test would then be useless as it would correspond to the else case.


There's no point in closing php tags just before reopening them. Remove the ? &gt; &lt; ? php tags.


Style (HTML)


Do you really want to use the em markup inside the h2 one?


What you are actually doing/trying to do


The code at the beginning seems to be assuming that we have a least facebook or twitter (sometimes both).


If this is indeed the case, the
$width = ($facebook &amp;&amp; !$twitter_username || !$facebook &amp;&amp; $twitter_username) ? "490" : "930";
at the beginning could become
$width = ($facebook &amp;&amp; $twitter_username) ? "930" : "490";
If it is not the case, could the beginning be behind an if (twitter || facebook) test as creating an empty div (and giving it an arbitrary width) might not be relevant. If you want to keep it, for the definition of the width, I'd rather have someting like : 
$width = ($facebook &amp;&amp; $twitter_username) ? "930" : (($facebook || $twitter_username) ? "490" : "1");

It might be interesting to use &lt;a href="&lt;?= $website_url; ?&gt;" &gt; or something like that to display the url as an actual link to make things easier from a user point of view (here I assumed that the input has been sanitized properly). On top of that, I don't understand why you hardcode the www. string (have a look at your current adress bar for more details). If there was anything to be hardcoded (and I personally wouldn't go for that), it's more likely to be the http:// part.