PHP: Making cleaner & shorter code
<p>I have this:</p>

<pre><code>&lt;?php
if($_GET['wE'] &amp;&amp; is_numeric($_GET['wE'])){
$we = mysql_real_escape_string($_GET['wE']);
$query_find_we = "SELECT id FROM users_wall WHERE id = '$we' AND uID = '$showU[id]'";
$query_find_we = mysql_query($query_find_we)or die(mysql_error());
$grab_wall_comment = (mysql_num_rows($query_find_we) == 1) ? "window.location.hash = '#comment$we';" : "alert('Vägginlägg kunde ej hittas.');";
?&gt;
&lt;script&gt;
$(function() {
&lt;?php echo $grab_wall_comment; ?&gt;
});
&lt;/script&gt;
&lt;?php
}elseif($_GET['sE'] &amp;&amp; is_numeric($_GET['sE'])){
$se = mysql_real_escape_string($_GET['sE']);
$query_find_se = "SELECT id FROM users_statuslog WHERE id = '$se' AND uID = '$showU[id]'";
$query_find_se = mysql_query($query_find_se)or die(mysql_error());
$grab_status_comment = (mysql_num_rows($query_find_se) == 1) ? "window.location.hash = '#comment$se';" : "alert('Status kunde ej hittas.');";
?&gt;
&lt;script&gt;
$(function() {
&lt;?php echo $grab_status_comment; ?&gt;
});
&lt;/script&gt;
&lt;?php
    }
?&gt;
</code></pre>

<p>checks if any $_GET['we'] or $_GET['se'], and if it exists. and runs the <code>&lt;script&gt;</code>. </p>

<p>Is there a way to make this shorter? I tried myself alittle with making a boolean, but maybe you could short it even more? Any ideas, as I would like to make cleaner coding in the future..</p>
