Data Trimming Hlp me plz

Status
Not open for further replies.

Butterfly

Broken In
Hellow,
I am retriving data from MySql database into table.. the width of the table is 281 so small so i wanted to cut the text say eg. : Today Mr. X-Men is visiting Thimphu for his lates show off movie traillers. I wanted to trim it in this formate : Today Mr. X-Men is visiting Thimphu for ... The rest of the data i can hyperlink this sentence and show it in the another page.. Just like the Yahoo News for ur kind information.


Below is my Source code + table if u need it incase..


<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conn = "localhost";
$database_conn = "tol";
$username_conn = "root";
$password_conn = "";
$conn = mysql_pconnect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR);
?>


<?php
$maxRows_Recordset1 = 5;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_conn, $conn);
$query_Recordset1 = "SELECT sb_img, cont FROM news";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $conn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<table border="1" cellspacing="0" bordercolor="#ECE9D8">
<tr bgcolor="#ECE9D8">
<td>img</td>
<td>Content</td>
</tr>
<?php do { ?>
<tr>
<td><?php echo $row_Recordset1['sb_img']; ?></td>
<td><?php echo $row_Recordset1['cont']; ?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

*****************************************************************************************************************************************

CREATE TABLE `news` (
`id` int(10) unsigned NOT NULL auto_increment,
`extr_frm` varchar(100) NOT NULL default '',
`sb_img` varchar(100) NOT NULL default '',
`title_link` varchar(100) NOT NULL default '',
`cont` longtext NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=24 ;

#
# Dumping data for table `news`
#

INSERT INTO `news` VALUES (18, 'cool', '<img src = http://localhost/tol.com/news/sb_img/side_button.gif>', 'Bow Bow', 'The Portuguese sighted the coast in 1512, and in 1545 the Spanish claimed the island. The first colony was founded in 1793 by the British. In 1828 the Dutch claimed the western half as part of the Dutch East Indies. In 1884 Britain annexed the southeastern part and Germany took over the northeastern sector. The British part became the Territory of Papua in 1906 and passed to Australia, which also governed the German sector after World War I. After World War II, Australia governed both sectors as the Territory of Papua and New Guinea. Dutch New Guinea was annexed to Indonesia in 1969 as the province of IrianJaya. Papua New Guinea achieved independence in 1975 and joined the British Commonwealth. It moved to resolve its war with Bougainville independence fighters in 1997; the peace treaty between Bougainville and the government of Papua New Guinea was signed in 2001.\r\n');
INSERT INTO `news` VALUES (17, 'cool', '<img src = http://localhost/tol.com/news/sb_img/side_button.gif>', 'pool', 'Private university in New York City.It was established in 1919 as an informal centre for adult education and soon became the first American university to specialize in continuing education. In 1934 it established a graduate faculty of political and social sciences, staffed mainly by refugee academics from Nazi Germany. It also includes a liberal arts college, a graduate school of management and urban policy, the Mannes College of Music, and the Parsons School of Design.\r\n');
INSERT INTO `news` VALUES (16, 'HELLOW WORLD', '<img src = http://localhost/tol.com/news/sb_img/side_button.gif>', 'Tommorow the chief guest is going', 'Morning daily tabloid newspaper published in New York City.\r\n\r\nIt was founded in 1919 by Joseph Medill Patterson and his cousin Robert McCormick as a subsidiary of the Tribune Co. of Chicago. The first successful tabloid-format newspaper in the U.S., it quickly attracted a large readership with sensational coverage of crime, scandal, and violence; it also included lurid photographs, cartoons, and entertainment features. It was an early user of wirephotos and developed a large staff of photographers. In 1993 it was bought by Mortimer B. Zuckerman.\r\n\r\n\r\nNeed More? Access the full 32-volume Encyclop‘dia Britannica online FREE! Click here to learn more.');
INSERT INTO `news` VALUES (15, 'BBS', '<img src = http://localhost/tol.com/news/sb_img/side_button.gif>', 'today the weatherr fore cast on the line', 'Organization that gathers, writes, and distributes news to newspapers, periodicals, radio andtelevision broadcasters, government agencies, and other users.\r\n\r\nIt does not publish news itself but supplies news to subscribers, who, by sharing costs, obtain services they could not otherwise afford. All the mass media depend on agencies for the bulk of thenews they carry. Some agencies focus on special subjects or on a local area or nation. Many news agencies are cooperatives, with members providing news from their area to a pool for general use. The largest news agencies are United Press International, Associated Press, Reuters, and Agence France-Presse.\r\n');
INSERT INTO `news` VALUES (20, 'Business', '<img src = http://localhost/tol.com/news/sb_img/side_button.gif>', 'Meowwwwwwwww', 'The Portuguese sighted the coast in 1512, and in 1545 the Spanish claimed the island. The first colony was founded in 1793 by the British. In 1828 the Dutch claimed the western half as part of the Dutch East Indies. In 1884 Britain annexed the southeastern part and Germany took over the northeastern sector. The British part became the Territory of Papua in 1906 and passed to Australia, which also governed the German sector after World War I. After World War II, Australia governed both sectors as the Territory of Papua and New Guinea. Dutch New Guinea was annexed to Indonesia in 1969 as the province of IrianJaya. Papua New Guinea achieved independence in 1975 and joined the British Commonwealth. It moved to resolve its war with Bougainville independence fighters in 1997; the peace treaty between Bougainville and the government of Papua New Guinea was signed in 2001.\r\n');
INSERT INTO `news` VALUES (21, 'skdj', '<img src = http://localhost/tol.com/news/sb_img/side_button.gif>', 'Ham', 'The Portuguese sighted the coast in 1512, and in 1545 the Spanish claimed the island. The first colony was founded in 1793 by the British. In 1828 the Dutch claimed the western half as part of the Dutch East Indies. In 1884 Britain annexed the southeastern part and Germany took over the northeastern sector. The British part became the Territory of Papua in 1906 and passed to Australia, which also governed the German sector after World War I. After World War II, Australia governed both sectors as the Territory of Papua and New Guinea. Dutch New Guinea was annexed to Indonesia in 1969 as the province of IrianJaya. Papua New Guinea achieved independence in 1975 and joined the British Commonwealth. It moved to resolve its war with Bougainville independence fighters in 1997; the peace treaty between Bougainville and the government of Papua New Guinea was signed in 2001.\r\n');
INSERT INTO `news` VALUES (22, 'cool', '<img src = http://localhost/tol.com/news/sb_img/side_button.gif>', 'PPPPPPPPPPPPPPPPPPPPPPPPP', 'hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa');
INSERT INTO `news` VALUES (23, 'fff', '<img src = http://localhost/tol.com/news/sb_img/side_button.gif>', 'fff', 'fff');
 

Deep

Version 2.0
I had mentioned about it in ur earlier post also...

anyways quoting the same here..


Code:
<?php 
$orig_string ="1234567890"; 
$cut_string = substr("$orig_string", 0,5); // will return 12345 
$final_string = $cut_string. "... ". [url="#"]click for more[/url]"; // shall show 12345... click more 
?>

Regards
Deep
 
Status
Not open for further replies.
Top Bottom