Page 1 of 1

text filed to tables

Posted: Sun Nov 13, 2005 3:14 am
by rami
i have a text field in mysql that takes text though php file and displays the entered data in php files .
My question is while displaying those data from text area can i display text in tables in php page.
Or while entering data in database ,can i activate html so that i can use html codes like <table><tr>....(which will display table in result page)
can it be done?

or are there any way to display the data from TEXT column of database to table while displaying in php file.
thanks

Posted: Sun Nov 13, 2005 10:12 am
by jwalsh
I don't follow what you are asking... maybe you could explain in more detail, and someone could help you.

You want to convert your mysql table data into a visual table on the screen?

Code: Select all

/* 
	listing menu with 2 default columns
	*/
	function menuList($items, $tag='li', $cols=2){
		// set up table and column widths
		$table_width = 600;
		$width = intval($table_width / $cols);
		
		//define the tr and td tags
		$tr = '<tr align="left">';
		$td = "<td width=\"$width\">%s</td>";
		
		// start the table
		$grid = "<table align=\"center\" width=\"$table_width\">$tr";
		
		// loop through entries and display in rows of $cols columns
		$i =0;
		foreach($items as $e){
			$grid .= sprintf($td, "<$tag>$e</$tag>");
			$i++;
			
			// check for end of row and start a new one
			if(!($i % $cols)){
				$grid .= "</tr>$tr";
			}
		}
		
		// pad remaining table cells with blanks
		while($i % $cols){
			$grid .= sprintf($td, '&nbsp;');
			$i++;
		}
		
		// close the tr tag
		$end_tr_len = strlen($tr) * -1;
		if(substr($grid, $end_tr_len) != $tr){
			$grid .= '</tr>';
		}else{
			$grid .= substr($grid, 0, $end_tr_len);
		}
		
		// close the table
		$grid .= '</table>';
		
		return  $grid;
	}

Posted: Sun Nov 13, 2005 10:39 am
by rami
no i am trying to retrive data from a single text field of mysql table to table in php file
suppose remarks text filed of mysql table contains

this is the file abc
this is .. xyz


those data should be appear in table ie
this is the file ...here cell ends next cell starts then abc


so on

can it be done..
thanks for reply

Posted: Sun Nov 13, 2005 12:26 pm
by twigletmac
If you post the code that you're using to just display the information then I'm sure someone can help you adjust it to include the table.

Mac

Posted: Sun Nov 13, 2005 2:39 pm
by alexmaster_2004
I think it will be good to save it as html into the database.
this will help you to display it in a table in eassy way

Posted: Sun Nov 13, 2005 3:01 pm
by twigletmac
alexmaster_2004 wrote:I think it will be good to save it as html into the database.
this will help you to display it in a table in eassy way
This isn't neccesarily helpful as you can't store your data in separate fields, nor can you store them as the correct data types in all cases. Plus you could only use the data in one way...

Mac