MYSQL Question
#1
Posted 16 March 2007 - 03:28 PM
#2
Posted 16 March 2007 - 06:22 PM
substr ( $var, 0, 150 );
#3
Posted 19 March 2007 - 06:21 AM
SELECT SUBSTRING(field, 1, 150) FROM table;
#4
Posted 19 March 2007 - 08:09 AM
yep, just query the result as you normally would, and when you are using it, just use substr ();
substr ( $var, 0, 150 );
I needed this too. Thanks. But one question, where does it go??
Hold on lol. OK here is an example:
If i wanted to display names from my db and i used:
$names
Then to limit the name size, i would use:
substr ( $name, 0, 150 );
??????????
#5 _*Creative Insanity_*
Posted 19 March 2007 - 02:55 PM
#6
Posted 19 March 2007 - 03:46 PM
yep, just query the result as you normally would, and when you are using it, just use substr ();
substr ( $var, 0, 150 );
I needed this too. Thanks. But one question, where does it go??
Hold on lol. OK here is an example:
If i wanted to display names from my db and i used:
$names
Then to limit the name size, i would use:
substr ( $name, 0, 150 );
??????????
If you were to use it like that, it would look like this.
echo substr($name, 0, 150);
If you are using an array, you would have to iterate the array with either a loop, or a function like array_map().
#7
Posted 22 March 2007 - 01:32 PM
You could, but having php do it is by far faster than having sql do it. In fact, having mysql use any "functions" slows things down quite a bit.Or you could have MySQL do it for you.
SELECT SUBSTRING(field, 1, 150) FROM table;
http://php.net/substrI needed this too. Thanks. But one question, where does it go??
Hold on lol. OK here is an example:
If i wanted to display names from my db and i used:
$names
Then to limit the name size, i would use:
substr ( $name, 0, 150 );
??????????
http://php.net/manua...fetch-array.php
Please try doing a little research. You'll be surprised how many questions have been answered before you even think to ask them.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users