how is limit row to databse for display to user? (like limit filde textarea for display)
like:
1)
WebMatrix makes it easy to create, customize and publish to the internet—and it’s free. Start from open source web applications, built-in web templates or just write the code yourself.
to:
2)
WebMatrix makes ...
After clicking (2) to display the full text(1)
Well, first you need to display a list of links to the user. Each of these links need to pass the id of the record they would like to see and the shortened down version of the text.
list.php
<?php
$res = mysql_query("SELECT id, CONCAT(SUBSTR(content, 5), ' ...') AS content FROM table;");
while($record = mysql_fetch_assoc($res)){
printf(
'<a href="view.php?id=%d">%s</a>',
$record['id'],
$record['content']
);
}
Will display a list similar to:
<a href="view.php?id=1">Foo ...</a>
<a href="view.php?id=2">Bar ...</a>
<a href="view.php?id=3">Ying ...</a>
<a href="view.php?id=4">Yang ...</a>
These links point to view.php, which would use the id sent to fetch and display the record chosen.
view.php
<?php
$res = mysql_query(sprintf(
'SELECT id, content FROM table WHERE id = %d LIMIT 1;',
$_GET['id']
));
while($record = mysql_fetch_assoc($res)){
echo $record['content'];
}
That’s a pretty general overview of the process.
Hi,
If I understand you correctly, you’d use LEFT(column, x) to return x characters from a column, eg:
SELECT LEFT(column_name, 30) FROM table