run query if explode is found
Please help, Im not sure how the result Im looking for is possible.
The query below will work ok, however it is possible that the url does not contain any trailing slashes after:
domain.com/index.php
This will run the query and all results from the field 'male' will be returned.
Is it possible to check and stop the query if no slashes are found or $first is not a valid letter??
list($first) = explode('/', substr($PATH_INFO,1));
$query = "SELECT DISTINCT `male`
FROM `model`
WHERE 1
AND `male` LIKE '$first%'";
$result = mysql_query($query);
$number = mysql_numrows($result);
{
for ($i=0; $i<$number; $i++) {
$male=mysql_result($result,$i,"male");
echo "$male";
Greg K posted this at 18:24 — 21st April 2005.
He has: 2,145 posts
Joined: Nov 2003
why not do something like:
list($first) = explode('/', substr($PATH_INFO,1));
<strong>if ($first)
{</strong>
$query = "SELECT DISTINCT `male`
FROM `model`
WHERE 1
AND `male` LIKE '$first%'";
$result = mysql_query($query);
$number = mysql_numrows($result);
{
for ($i=0; $i<$number; $i++) {
$male=mysql_result($result,$i,"male");
. . .
<strong>}</strong>
rayzun posted this at 18:29 — 21st April 2005.
They have: 18 posts
Joined: Feb 2005
yes this is what I was looking for.
thankyou
Want to join the discussion? Create an account or log in if you already have one. Joining is fast, free and painless! We’ll even whisk you back here when you’ve finished.