porko2004 Posted May 10, 2009 Share Posted May 10, 2009 WHERE c.profession = 45 AND c.name != '*[PM]' OR c.profession = 44 AND c.name != '*[PM]' OR c.profession = 43 AND c.name != '*[PM]' OR c.profession = 42 AND c.name != '*[PM]' OR c.profession = 41 AND c.name != '*[PM]' OR c.profession = 40 AND c.name != '*[PM]' i am making something appear i dont wont the database to show me accounts with name with something then [PM] eg home[PM] pime[PM] this is the script anyone know whast wrong c.name != '*[PM]' Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/ Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 You can use INSTR() function to check if c.name contains the string '[PM]' or not. Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830701 Share on other sites More sharing options...
porko2004 Posted May 10, 2009 Author Share Posted May 10, 2009 You can use INSTR() function to check if c.name contains the string '[PM]' or not. example? this is full script <?php require('config.php'); $rank = mysql_query("SELECT c.name as CharName, c.level as Level, c.mate as Spouse, f.name as GuildName, c.money as Money, c.money_saved as Money_Saved FROM cq_user as c LEFT JOIN cq_synattr as g ON (c.id = g.id) LEFT JOIN cq_syndicate as f ON (g.syn_id = f.id) WHERE c.profession = 45 AND c.name != '*[PM]' OR c.profession = 44 AND c.name != '*[PM]' OR c.profession = 43 AND c.name != '*[PM]' OR c.profession = 42 AND c.name != '*[PM]' OR c.profession = 41 AND c.name != '*[PM]' OR c.profession = 40 AND c.name != '*[PM]' ORDER BY c.level DESC, c.money + c.money_saved DESC LIMIT 0,15 ;"); $i=1; echo "<table border='0' bgcolor='#FFDC74'> "; echo "<font size='9'><tr> <th><center> Rank </center></th> <th><center> Character Name </center></th> <th> Level </th> <th> Spouse </th> <th> Guild Name ; </th> </tr>"; while($row = mysql_fetch_array($rank)){ echo '<tr style="background-color:#FFF2BD;"><td><div align="center" bgcolor="#FFFF00" >'.$i.'</td> <td><div align="center">'.$row['CharName'].'</td> <td><div align="center">'.$row['Level'].'</td> <td><div align="center">'.$row['Spouse'].'</td> <td><div align="center">'.$row['GuildName'].'</td> </tr> '; $i=$i+1; } ?> Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830706 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 WHERE INSTR('[PM]', c.name) = 0 ? Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830708 Share on other sites More sharing options...
porko2004 Posted May 10, 2009 Author Share Posted May 10, 2009 that doesnt work Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830711 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 that doesnt work That was helpful. Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830713 Share on other sites More sharing options...
porko2004 Posted May 10, 2009 Author Share Posted May 10, 2009 that doesnt work That was helpful. can u add it to the script maybe im adding it wrong Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830717 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 WHERE INSTR('[PM]', c.name) = 0 AND c.profession BETWEEN 40 AND 45 ? Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830724 Share on other sites More sharing options...
porko2004 Posted May 10, 2009 Author Share Posted May 10, 2009 still the same Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830727 Share on other sites More sharing options...
porko2004 Posted May 10, 2009 Author Share Posted May 10, 2009 i fixed my problem but got a little question to ask <?php require('config.php'); $rank = mysql_query("SELECT c.name as CharName, c.level as Level, c.mate as Spouse, f.name as GuildName, c.money_saved as Money_Saved, c.money as Money, c.profession as profession FROM cq_user as c LEFT JOIN cq_synattr as g ON (c.id = g.id) LEFT JOIN cq_syndicate as f ON (g.syn_id = f.id) IF c.profession = 15 THEN 'Trojan Master' WHERE c.name != 'UnKnown[PM]' AND c.name != 'Bling[PM]' AND c.name != '~G~I~S~M~O~[PM]' ORDER BY c.level DESC, c.money + c.money_saved DESC LIMIT 0,15 ;"); $i=1; echo "<table border='0' bgcolor='#FFDC74'> "; echo "<font size='9'><tr> <th><center> Rank </center></th> <th><center> Character Name </center></th> <th> Level </th> <th> Spouse </th> <th> Guild Name </th> <th> Class </th></tr>"; while($row = mysql_fetch_array($rank)){ echo '<tr style="background-color:#FFF2BD;"><td><div align="center" bgcolor="#FFFF00" >'.$i.'</td> <td><div align="center">'.$row['CharName'].'</td> <td><div align="center">'.$row['Level'].'</td> <td><div align="center">'.$row['Spouse'].'</td> <td><div align="center">'.$row['GuildName'].'</td> <td><div align="center">'.$row['profession'].'</td> </tr> '; $i=$i+1; } ?> for profession it currectly appears as a number how do i make it appear as a name. Please help me. Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830851 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 Change it in the DB? ??? Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830855 Share on other sites More sharing options...
porko2004 Posted May 10, 2009 Author Share Posted May 10, 2009 Change it in the DB? ??? i cant. this script is web based if i do it in db i mess everything is there any other way Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830856 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 Create an array that maps a profession number to some name? Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830858 Share on other sites More sharing options...
porko2004 Posted May 10, 2009 Author Share Posted May 10, 2009 ye Create an array that maps a profession number to some name? u know how to do it for example if there is a number 15 it appears as Novice Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830862 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 u know how to do it Yes. Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830864 Share on other sites More sharing options...
porko2004 Posted May 10, 2009 Author Share Posted May 10, 2009 u know how to do it Yes. can u show me please Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830866 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 can u show me please Here's an example of what the array should look like. $professionNameMap = array( // profession => name 1 => 'one' ); Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830868 Share on other sites More sharing options...
porko2004 Posted May 10, 2009 Author Share Posted May 10, 2009 ?? im confused where i put that Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830869 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 It was an example. You know PHP? Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830870 Share on other sites More sharing options...
porko2004 Posted May 10, 2009 Author Share Posted May 10, 2009 It was an example. You know PHP? yes i do. i usually know what im doing but im seriously confused Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830872 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 Okay so $row['profession'] returns a number right? Well if you were to call $professionNameMap[$row['profession']], then it should be the name specified. Get it now? Now you just have to set up the array. Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830875 Share on other sites More sharing options...
porko2004 Posted May 10, 2009 Author Share Posted May 10, 2009 $profession = array( 10 => 'Noobie' 15 => 'Novace' ); doesnt work for multiple numbers Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830890 Share on other sites More sharing options...
porko2004 Posted May 10, 2009 Author Share Posted May 10, 2009 This is anoying Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830894 Share on other sites More sharing options...
porko2004 Posted May 10, 2009 Author Share Posted May 10, 2009 can anyone help please Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-830909 Share on other sites More sharing options...
Ken2k7 Posted May 10, 2009 Share Posted May 10, 2009 Again, that was helpful. You need to learn how to ask a question. Next time, I won't even bother with this. Can you explain what you need help with? Link to comment https://forums.phpfreaks.com/topic/157548-anyone-know-how-to-fix-this/#findComment-831110 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.