Forum Moderators: coopster
If anyone can spot the error, please tell! I get nothing from the default!
<?php
// get subs
switch ($strip[0]) {
case "cl":
$Query2 = "SELECT * FROM Clients where pgname LIKE 'cl%' AND pgname NOT LIKE 'cl_index'";
break;
case "sv":
$Query2 = "SELECT * FROM $TableName where pgname LIKE 'sv%' AND pgname NOT LIKE 'sv_index'";
break;
case "cn":
$Query2 = "SELECT * FROM $TableName where pgname LIKE 'cn%' AND pgname NOT LIKE 'cn_thanks, cn_index'";
break;
default:
$Query2 = "SELECT * FROM $TableName where pgname LIKE 'pr_part1, pr_whywebsite, privacy, accessibility'";
break;
}
// do DB script:
// start 2nd query
$counter = "1";
$Result2 = mysql_db_query ($DBName, $Query2, $Link);
while ($Row2 = mysql_fetch_array ($Result2)) {
// do strip for the cl images and stuff
$strip2 = explode("_",$Row2[pgname]);
// done DB now do a loop...
print ("<li><a href=\"index.php?goto=$Row2[pgname]\" style=\"text-transform:capitalize;\" title=\"$Row2[title]\" accesskey=\"" . $counter . "\">$Row2[title]</a></li>");
$counter++; // for the tabindex
// close query...
}
mysql_free_result($Result2);
?>
Try it, right after your switch statement. By the way, the mysql_db_query() [php.net] function has been deprecated since PHP 4.0.6. Do not use this function. Use mysql_select_db() [php.net] and mysql_query() [php.net] instead:
} // this is the end of your switch statement.
// This next statement doesn't have to be here,
// it could be with your connection stuff
// Just wanted to show you how it is used.
mysql_select_db($DBName, $Link);
// now see if we got anything returned:
$Result2 = mysql_query($Query2, $Link);
if (mysql_num_rows($Result2) == 0) {
print "I didn't get any rows returned with this:<br />'$Query2'";
}
SELECT * FROM $TableName << I don't want everything!
SELECT * FROM $TableName where pgname LIKE 'pr%' << Ive used that before and still don't want that!
And this works:
SELECT * FROM $TableName where pgname LIKE 'pr_part1'
BUT this:
SELECT * FROM $TableName where pgname LIKE 'pr_part1' AND pgname LIKE 'pr_whywebsite'
AND this:
SELECT * FROM $TableName where pgname LIKE 'pr_part1, pr_whywebsite'
Don't work!
What is up with that?!?!?!
Note, even the mysql_num_rows thingy doesn't work with those!
Nothing shows up... :'(
$Result2 = mysql_query($Query2, $Link) or
exit('Error: ' . mysql_errno() . ' : ' . mysql_error());
ahmedtheking, both of these folks, and olwen as well, have offered you sound advice. You have changed your query statements from the original in message #1. I guess we have determined that your issue is not syntax nor code related, but query statement related. Why don't you give a small example of the data in the table and what you are trying to accomplish. It will help get you a much quicker solution. Thanks.
pgnamecolumn. So why not show us some example data in that column and some examples of what rows you would like to retrieve based on the data in that column. Don't try to write it in SQL format yet. For example:
This is my sample data in the table. The
pgnamecolumn is CHAR(100), meaning it is a 100 character field and it contains a group of words separated by commas:
pgname
---------------------------------------------------
cl_data, cl_something, cl_index, sv_index, pr_part1
pr_part1, privacy, sv_index
privacy, accessibility
sv_part1, cl_index
'cl_', but not those that are
'cl_index'. How might I go about this?