Jump to content

using first letter


brown2005

Recommended Posts

hi i have stored in my database a url

say http://www.thisisatest.com

say i call it from the database

$sql = "SELECT * FROM tableInMysql;";

then i have

while
{

echo $sql

}

it echos http://www.thisisatest.com

but wat i want is, to remove the http://www. which i already have a function for and when the page says

index.php?letter=t

it will select the website cause it beggings with t

and echo

thisisatest.com

any ideas of how i can get the $sql to select the letter?

thanks...
Link to comment
https://forums.phpfreaks.com/topic/34805-using-first-letter/
Share on other sites

How many websites will be in the database that start with t? or any particular letter.

Your sql would want to look like this.

SELECT * FROM table WHERE wwwfield like 'http://www.t%'

If you only want 1 result then you would add

SELECT * FROM table WHERE wwwfield like 'http://www.t%' limit 1

if the "http://www." is not stored in the database then you can just say: where wwwfield like 't%'

Dave.
Link to comment
https://forums.phpfreaks.com/topic/34805-using-first-letter/#findComment-164039
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.