Need your help again guys!
- RichL
-
RichL
- Member since: Apr. 2, 2000
- Offline.
-
- Forum Stats
- Member
- Level 05
- Blank Slate
Just when ya thought u got rid of me-
I have a database full of information, but currently all titles in the database are in UPPER CASE (e.g. GRAND THEFT AUTO 3), but i have just finished a new design and really need to put the titles all into lower case (either at the DB end, or in the SQL that pulls the info from the DB). A friend said it would be something like "ucfirst(strtolower($string)", but im not sure if it works or where to put it!
I would really love to turn all my titles into lower case with a initial Upper Case Letter (e.g. Grand theft auto 3)
Im supposed to be uploading the new design sometime today, so if anyone knows- please reply asap!
Thanks
- liljim
-
liljim
- Member since: Dec. 16, 1999
- Offline.
-
- Send Private Message
- Browse All Posts (11,644)
- Block
-
- Forum Stats
- Staff
- Level 28
- Blank Slate
At 11/19/01 04:18 AM, RichL wrote:
A friend said it would be something like "ucfirst(strtolower($string)", but im not sure if it works or where to put it!
Your friend would be right (except you need another bracket after $string):
ucfirst(strtolower($string));
Just use that on the strings you're bringing back from the db call, and echo it out, so:
$string = ucfirst(strtolower($string));
Or
echo ucfirst(strtolower($string));
This really is simple stuff. Check this for an explanation on strings:
http://www.zend.com/zend/tut/using-strings.php
Or this:
http://www.php.net/manual/en/function.echo.php
For an explanation on the echo function. You'll see a list of useful string functions to the left of that manual entry.
- RichL
-
RichL
- Member since: Apr. 2, 2000
- Offline.
-
- Forum Stats
- Member
- Level 05
- Blank Slate
Thanks- Have been trying this:
? $results = mysql_query SELECT * FROM articles ORDER BY id ASC $db
$finalresults = ucfirst(strtolower($results));
if ($item = mysql_fetch_array($finalresults)) {
do {
printf(" A HREF=articles/?id=%s %s /a ", $item["id"], $item["title"]);
} while($item = mysql_fetch_array($finalresults));
}
?
But it just gives me a "Not a vaid mysql resource" error, unfortunately..whats wrong with the code?
- RichL
-
RichL
- Member since: Apr. 2, 2000
- Offline.
-
- Forum Stats
- Member
- Level 05
- Blank Slate
Thanks- heres what ive been trying,
? $results = mysql_query("SELECT * FROM articles ORDER BY id ASC", $db);
if ($item = mysql_fetch_array($results)) {
do {
$itemtwo = ucfirst(strtolower($item));
printf(" A HREF=articles/?id=%s %s /a br", $itemtwo["id"], $itemtwo["title"]);
} while($item = mysql_fetch_array($results));
}
?
But it just gives me this:
A
A
A
A
A
(in that order. lol) the link ID points to "?id=A" aswell..wassup with this?
- liljim
-
liljim
- Member since: Dec. 16, 1999
- Offline.
-
- Send Private Message
- Browse All Posts (11,644)
- Block
-
- Forum Stats
- Staff
- Level 28
- Blank Slate
At 11/19/01 06:04 AM, RichL wrote: (in that order. lol) the link ID points to "?id=A" aswell..wassup with this?
You're applying the functions to the array, and not the individual variables as you want.
- RichL
-
RichL
- Member since: Apr. 2, 2000
- Offline.
-
- Forum Stats
- Member
- Level 05
- Blank Slate
You're applying the functions to the array, and not the individual variables as you want.
Thanks, all done now

