Jump to content

Making this procedural code more readable/pleasing to the eye...


cgm225

Recommended Posts

I have the following code for generation of the footer on my photo/video pages.  It contains a drop down form, and some links I am outputting.  I want to know how to make the code more readable/pleasing to the eye.  Generally I indent the code nicely, etc., but because I am outputting this form, and don't want to echo each line individually (I would have to escape all the quotations which is less than ideal), I am using the PRINT <<<END method, which I feel makes my code look like it's all over the place.

 

Any ideas?

 

Thank you all in advance!

 

 

<?php

if ($id == "videos") {

print <<<END
				<form method="post" action="" style="margin:0;padding:0;">
		    		  <div style="float:right;padding:0 28px 4px 0;margin:0 0 0 0;">
END;

} elseif ($id == "photos") {

print <<<END
		                <form method="post" action="" class="number_displayed">
		                  <div class="number_displayed">
END;

}

if (permission_for("delete_album") == TRUE) {echo "\t\t\t\t<a href=\"http://www.example.com/albums/delete/$album\">Delete Album</a> | ";}

?>Display
		     		    <select name="number_displayed" size="1" class="number_displayed" onchange="form.submit()">
		       		     <option value="2" class="number_displayed" <?php if ($number_displayed == 2) {echo "selected=\"selected\"";} ?>>2</option>
		           		 <option value="4" class="number_displayed" <?php if ($number_displayed == 4) {echo "selected=\"selected\"";} ?>>4</option>
		          		  <option value="6" class="number_displayed" <?php if ($number_displayed == 6) {echo "selected=\"selected\"";} ?>>6</option>
		          		  <option value="8" class="number_displayed" <?php if ($number_displayed ==  {echo "selected=\"selected\"";} ?>>8</option>
		          		  <option value="10" class="number_displayed" <?php if ($number_displayed == 10) {echo "selected=\"selected\"";} ?>>10</option>
		          		  <option value="20" class="number_displayed" <?php if ($number_displayed == 20) {echo "selected=\"selected\"";} ?>>20</option>
		          		  <option value="40" class="number_displayed" <?php if ($number_displayed == 40) {echo "selected=\"selected\"";} ?>>40</option>
		     		    </select>

<?php

if ($id == "photos") {

    if ((mysql_num_rows(mysql_query("SELECT * FROM images WHERE album = $album_id ORDER BY timestamp DESC LIMIT $upper_limit, 1",$mysql_server_connection_1))) > 0) { 
            echo "\t\t\t\t\t<a href='http://www.example.com/photos/$album/" . ($page + 1) . "'>Next</a>\n";
        } elseif (file_exists("$server_video_album_location/$album")) {          
            echo "\t\t\t\t\t<a href=\"http://www.example.com/videos/$album\">Next</a>\n";
        } else {
            echo "\n";
        }

} elseif ($id == "videos") {

    //If there are more video entries beyond the upper MySQL limit a "Next" link will be provided
    if ((mysql_num_rows(mysql_query("SELECT * FROM videos WHERE album = $album_id ORDER BY timestamp DESC LIMIT $upper_limit, 1",$mysql_server_connection_1))) > 0) { 
            echo "\t\t\t\t\t\t<a href='http://www.example.com/videos/$album/" . ($page + 1) . "'>Next</a>\n";}

}

print <<<END

		     		    <noscript><p class="no_style">(JavaScript Required)</p></noscript>
		    		  </div>
		                </form>

END;

if ($id == "videos") {
    echo "\t\t\t\t\t<div class=\"spacer\"></div>\n";    
    echo "\t\t\t\t</div>\n";
    echo "\t\t\t</div>\n";
}

    include_once "gallery.footer.inc.php";

?>

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.