Jump to content


Photo

PHP and MySQL problem


  • Please log in to reply
1 reply to this topic

#1 TJMAudio

TJMAudio
  • Members
  • PipPipPip
  • Advanced Member
  • 54 posts

Posted 01 October 2006 - 12:17 AM

Alright, here is a copy of the code that is having the problems:

			<dl>
				<dt>
					<a onclick="switchmenu('first');" class="proftop" style="cursor:pointer;">
						<img src="images/firstmenu.gif" /> 
						<?php $cat1maxlvl = $maxlvl / 4;
							 ?>
						<span class="proftop"> <?php echo $faction; ?> <?php echo "$minlvl - $cat1maxlvl"; ?> Profiles</span>
					</a>
				</dt>
				<dd id="first">
				<?php
					$get1 = "SELECT * FROM `profile` WHERE `minlvl`>='$minlvl' AND `maxlvl`<='$cat1maxlvl' AND `faction`='$faction' ORDER BY profileid AND minlvl DESC";
					$q1 = mysql_query($get1) or die(mysql_error());
					while($r1 = mysql_fetch_array($q1)){
						$p1id = $r1['profileid'];
						$p1name = $r1['profilename'];
						$p1link = $r1['profilelink'];
						?>
					<a href="<?php echo $p1link; ?>" class="f1"> <img src="images/profilemenu.gif" border="0" /></a>
					<a href="<?php echo $p1link; ?>" class="f1"><?php echo $p1name; ?></a>
					<br />
					<?php } ?>
				</dd>
			</dl>

This part of the code is giving me a headache.  Here are the variables used in this:

$minlvl = 1
$maxlvl = 20
$cat1maxlvl = 5
$faction = alliance
and then so on and so forth.

I have 4 of these being called as it runs down the script, going from levels 1-5, 5-10, 10-15, and 15-20.  The thing is, this one is getting something that has a maxlvl of 10.  Is my SQL wrong?  If you need to see the full script just let me know.

Thanks. 
:: My Site ::
Feel free to critique...

#2 thedarkwinter

thedarkwinter
  • Members
  • PipPipPip
  • Advanced Member
  • 191 posts
  • LocationLondon

Posted 02 October 2006 - 01:57 PM

Hi

Since the mins + maxes are integeres, you can try posting them in directs without quotes:

Also, i thing the ORDER clause shouldn't contain an AND (?)

$get1 = "SELECT * FROM `profile` WHERE (minlvl >=$minlvl) AND (maxlvl<=$cat1maxlvl) AND (faction='$faction') ORDER BY profileid, minlvl DESC;";

its also helpful to echo $get1 so you can check that the variables are going in correctly.

Cheers
Michael


Remember - if you don't figure it out yourself, you'll probably forget it tomorrow :)




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users