PhpSnip.com

User Stats

tablestr.php - html tables in php

This is the string-returning form of tables.php. It can work together with htmlstr.php, liststr.php, and formstr.php. It can be included with any/all related files, but remember that if included along with tables.php, the function names that return strings are postfixed with a "_str". See example code for details.

Info

 Download  View Source (print view)
 Rating : 4.7  Views : 498

Source Code ( 87 lines )

<?
	/* tablestr.php
	 *
	 * functions to create html tables
	 *
	 * Refer HTML questions to http://www.w3.org/TR/REC-html40/
	 *
	 * Returns strings instead of printing output. Contains no formatting.
	 */

	if(defined("USING_TABLES")) {

		function table_str($border=0, $width="", $spacing="", $padding="", $args="") {
			$temp = "<TABLE border=$border";
			if($width != "")
				$temp .= " width="$width"";
			if($spacing != "")
				$temp .= " cellspacing=$spacing";
			if($padding != "")
				$temp .= " cellpadding=$padding";
			if($args != "")
				$temp .= " $args";
			$temp .= ">";
			return($temp);
		}

		function tr_str($args="") {
			$temp = "<TR";
			if($args != "")
				$temp .= " $args";
			$temp .= ">";
			return($temp);
			/* possible tr $args: id, class, lang, title, style, align, char, charoff, valign, intrinsic events */
		}

		function td_str($args="") {
			$temp = "<TD";
			if($args != "")
				$temp .= " $args";
			$temp .= ">";
			return($temp);
			/* possible $args: id, class, lang, title, style, bgcolor, align, char, charoff, valign, rowspan, colspan, etc */
		}

		function table_close_str() {
			print("</TABLE>");
		}

	} else {

		function table($border=0, $width="", $spacing="", $padding="", $args="") {
			$temp = "<TABLE border=$border";
			if($width != "")
				$temp .= " width="$width"";
			if($spacing != "")
				$temp .= " cellspacing=$spacing";
			if($padding != "")
				$temp .= " cellpadding=$padding";
			if($args != "")
				$temp .= " $args";
			$temp .= ">";
			return($temp);
		}

		function tr($args="") {
			$temp = "<TR";
			if($args != "")
				$temp .= " $args";
			$temp .= ">";
			return($temp);
			/* possible tr $args: id, class, lang, title, style, align, char, charoff, valign, intrinsic events */
		}

		function td($args="") {
			$temp = "<TD";
			if($args != "")
				$temp .= " $args";
			$temp .= ">";
			return($temp);
			/* possible $args: id, class, lang, title, style, bgcolor, align, char, charoff, valign, rowspan, colspan, etc */
		}

		function table_close() {
			print("</TABLE>");
		}
	}
?>

Search

Subscribe

  Rss Feeds

Sponsors

Advertise