mgtm3
asked on
i want to search the database mysql and i want to find similar links
lets say i have this links in the database
-------------------------- ---------- ---------- ---------- ----
www.dsdxa.com/23432324/dswd2.rar
www.dsdxa.com/2423432/dswd4.rar
www.dsdxa.com/34242/dswd3.rar
www.dsdxa.com/34242/dsadsad3.rar
www.dsadwa.com/34242/dssqasd3.rar
-------------------------- ---------- ---------- ---------- ------
and i want to search for all the links that look like
www.dsdxa.com/34242/dswd1.rar
want the command to output
www.dsdxa.com/23432324/dswd2.rar
www.dsdxa.com/2423432/dswd4.rar
www.dsdxa.com/34242/dswd3.rar
and not
www.dsdxa.com/34242/dsadsad3.rar
www.dsadwa.com/34242/dssqasd3.rar
-------------------------- ---------- ---------- ---------- ----------
i know this command the like command but its not working as u want
-------------------------- ---------- ---------- ---------- ---------- ----
thanks
--------------------------
www.dsdxa.com/23432324/dswd2.rar
www.dsdxa.com/2423432/dswd4.rar
www.dsdxa.com/34242/dswd3.rar
www.dsdxa.com/34242/dsadsad3.rar
www.dsadwa.com/34242/dssqasd3.rar
--------------------------
and i want to search for all the links that look like
www.dsdxa.com/34242/dswd1.rar
want the command to output
www.dsdxa.com/23432324/dswd2.rar
www.dsdxa.com/2423432/dswd4.rar
www.dsdxa.com/34242/dswd3.rar
and not
www.dsdxa.com/34242/dsadsad3.rar
www.dsadwa.com/34242/dssqasd3.rar
--------------------------
i know this command the like command but its not working as u want
--------------------------
thanks
In deed you need the "LIKE" command to get those values. Can you show me the query you originally created that doesn't work?
ASKER
$query = " SELECT * FROM ddd WHERE d_link LIKE '%$link%'; ";
ASKER
soo anyone?
Because you want to search for links in a database that start with a certain string you'd like to split the string before searching for it.
The code below creates an array with all the pieces of the url split by the "/". Than a query is set up to get all the needed results. After that the results are displayed.
The code below creates an array with all the pieces of the url split by the "/". Than a query is set up to get all the needed results. After that the results are displayed.
<?php
$link = "www.dsdxa.com";
$pieces = explode("/", $link);
$query = "SELECT * FROM {tablename} WHERE {column} LIKE \"%$pieces[0]%\";";
$results = mysql_query($query);
while($row = mysql_fetch_array($results)){
echo "$row['{column}']";
}
?>
ASKER
no thats to long i want something fast like the match command
How do you man it is too long. I only gave an example how you can test it. You don't have to use the whole code. You only have to use the the first 5 rows. The rest is just meant as an example.
By the way you'd have to use the rest in some way because you'd have to execute the query against the database.
By the way you'd have to use the rest in some way because you'd have to execute the query against the database.
ASKER
i mean it takes alout of time i have a huge database
now its 6 million rows
now its 6 million rows
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.