text filed to tables

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
rami
Forum Contributor
Posts: 217
Joined: Thu Sep 15, 2005 8:55 am

text filed to tables

Post 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
User avatar
jwalsh
Forum Contributor
Posts: 202
Joined: Sat Jan 03, 2004 4:55 pm
Location: Cleveland, OH

Post 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;
	}
rami
Forum Contributor
Posts: 217
Joined: Thu Sep 15, 2005 8:55 am

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
alexmaster_2004
Forum Commoner
Posts: 35
Joined: Wed Sep 14, 2005 8:44 am

Post 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
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post 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
Post Reply