PHP - Rank Is Incorrect
Ever since I switched over to pagination, the ranks for the sites have been off. I use to have an $i++ increment that kept the ranks, but now with pagination, it just ranks those on the current page. Is there a way to bypass this?
public function grabSites() { //amount of sites $amount = mysql_num_rows(mysql_query("SELECT * FROM sites")); if($amount > 0) { //amount per page $p_page = 13; //track page $start = $_GET['page']; //max_pages $max_pages = $amount / $p_page; //set default if(!$start) $start = 0; //new query $query = mysql_query("SELECT id,title,description,votes,date,outl,site_url FROM sites ORDER BY votes DESC LIMIT $start, $p_page"); while($fetch = mysql_fetch_assoc($query)) { ++$i; $i = $i + $p_page; echo " <div id='post-1' class='post'> <h2 class='title'><font color='white'>#". $i." ".$fetch['title'] ."</font></h2> <div class='entry'> <b>". $fetch['title'] ." currently has ". $fetch['votes'] ." votes. <a href='vote.php?id=". $fetch['id'] ."'>Vote now</a>.</b> <br/><br/> <p>". nl2br(stripslashes($fetch['description'])) ."</p> </div> <p class='meta'><a href='". $fetch['site_url'] ."'>Visit</a></p> </div> "; } //set back and forth variables $previous = $start - $p_page; $next = $start + $p_page; ?> <hr> <center> <?php if(!($start<=0)) echo "<a href='index.php?page=". $previous ."'><<</a>"; $i = 1; for($x = 0; $x < $amount; $x = $x + $p_page) { echo "<a href='index.php?page=". $x ."'> ". $i ." </a>"; $i++; } if(!($start>=$amount-$p_page)) echo "<a href='index.php?page=". $next ."'>>></a></center>"; ?> </center> <?php } else { echo " <div id='post-1' class='post'> <h2 class='title'><a href='#'>Oh NOEZ!</a></h2> <h3 class='date'>". date("M-d-Y") ."</h3> <div class='entry'> <p>There are currently no sites to display!</p> </div> <p class='meta'>View</p> </div> "; } } Similar TutorialsI am having trouble on user post = rank This is the rank table: ----------------- post | rank ----------------- 0 | Noob 10 | Member 50 | Metal 100 | Silver 200 | Gold $user_post="120"; $query_rank=mysql_query("SELECT * FROM rank WHERE post<='$user_post' OR post>='$user_post'") or die ("Error"); while ($row=mysql_fetch_assoc($query_rank)){ $rank=$row['rank']; } echo "User Rank: $rank"; The above code output: User Rank: Gold The right output should be: User Rank: Silver Please help It will be better if someone willing to share a better ranking code. Consider the following code; Code: [Select] <div class="blockrow"> <table cellpadding="10" align="center" border="0"> <tr> <td> <center> <font size=6>Donation Hall of Fame</font><br><br> <font size=2><b>Anonymous Donations are not Counted</b></font><br><br> <font size=3><a href="/donate">Get on This List</a></font> <br> <br> <?php //database connection $connectdb = mysql_connect ("localhost", "user", "pass") or die ('I cannot connect to the database because: ' . mysql_error()); mysql_select_db ("thatsact_donations"); //query setup $sql = "SELECT * FROM totals ORDER BY donation_total DESC LIMIT 100"; $result = mysql_query($sql) or die(mysql_error()); //initialize container $container = array(); //get entries from db while ($get = mysql_fetch_assoc($result)){ if(!$get[userid]=="0") { $username = "<b><a style=\"color:#00CC00\" href=/member.php/$get[userid]>$get[username]</a></b> donated <b>$$get[donation_total]</b> total so far!"; } $container[] = "<font size=3>$username</font>"; } //combine collected entries $output = implode("<br /><hr>",$container); echo $output; mysql_close($connectdb); ?> </center> </td> </tr> </table> </div> I would like to add a rank number to the container starting with one and going 23456 as each piece is echoed. How might I do this because I am very new to php. Example: 1. Username donated $5...... 2. Username donated $4........ 3. Username donated $3....... Thanks in advance. Hi all, the other I coded a simular script to this which didnt work, so I re coded it but im having a problem with this one aswell, what its meant to do is just change the users rank to what is posted, but every time I hit submit on the form it locates me to a different place. <?php session_start(); include ("../includes/db_connect.php"); include ("../includes/functions.php"); logincheck(); $username = $_SESSION['username']; $rankget = mysql_query ("SELECT * FROM users WHERE username='$username'"); $newrank = mysql_fetch_object($rankget); if ($_POST['change']){ if ($newrank->userlevel >= "2"){ $time = now(); $updateuser = $_POST['usernameone']; // User Posted $updaterank = $_POST['rankone']; // Rank posted if ($updateuser == NULL && $updaterank == NULL){ $message = "You must enter a user and rank"; }elseif ($updateuser == NULL){ $message = "You must enter a username"; }elseif ($updaterank == NULL){ $message = "You must enter a rank"; } mysql_query ("UPDATE users SET rank = '$updaterank' WHERE username='$updateuser'") or die (mysql_error()); mysql_query ("INSERT INTO logs (`id` , `who`, `action`, `time`) VALUES ('', '$username' , '$username Updated rank; $updateuser to $updaterank' , '$time')") or die (mysql_error()); mysql_query ("INSERT INTO inbox (`id` , `to` , `from` , `message` , `date` , `read` , `saved` , `event_id`) VALUES ('', '$updateuser', 'System', 'Your rank has been updated to $updaterank!', '$date', '0', '0', '')") or die (mysql_error()); echo ("Rank Changed!"); }} ?> <html> <head> <title>Change Rank</title> <link rel="stylesheet" href="../include/in.css" type="text/css"> <style type="text/css"> .infobg { font-family: Arial; font-weight:normal; font-size:12px; border-top: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; background: URL(textbg1.png); font-weight:300; } .button { font-size: 12px; background:url(button.png); vertical-align: middle; border-top: 1px solid #000000; border-right: 1px solid #000000; border-bottom: 1px solid #000000; border-left: 1px solid #000000; color: #FFFFCC; height:23px; font-weight:300; border-radius: 10px; padding-bottom:2px; } </style> </head> <body> <form action='' name='form1' id='form1' method='POST'> <table width='50%' cellpadding='0' align='center' cellspacing='0' border='1' bordercolor='#000000' bgcolor='#808080' style='border-collapse: collapse'> <tr> <td><?php echo ("$message"); ?></td> </tr> <tr> <td background='../header.jpg' colspan='2' align='center'>Change Rank</td> <tr> <td>Username:</td><td><input type='text' name='usernameone'></td> </tr> <tr> <td>Rank:</td><td><input type='text' name='rankone'></td> </tr> <tr> <td> </td><td><input type='submit' name='change' value='Change Rank!'></td> </tr> </table> </form> </body> </html> Anyone see why it locates me else? Thanks Hello everyone,
I'm create an application where I have member, admin, and superadmin
What I'm try to do is superadmin update member to admin, so they can have more privilege. The name of the table is member where I have member, admin account, and i have row call 'rank'. Rank 1 is for member they have access basic stuff and rank 2 they have more privilege. Want the superadmin to type the name of the member and change to rank 2.
This is what happening, if I dont put nothing on the text boxes, it said "Please check if you have put the right information." , if i put member and the rank i want to change is says ""User has upgrade to admin", but than when i check my database the member is still a member when i wanted to change to admin.
Can anyone see where I'm going home, or what should I change.
<form> </form> <form action='<?php htmlentities($_SERVER['PHP_SELF']); ?>' method='POST' enctype='multipart/form-data '> Username: <input class="fontsize" name='user' type='text'/> Rank: <input class="fontsize" name='rank' type='text' /> <br><br> <input class="button" type='submit' name='get' value='Upgrade' /> </form> </h2> <?php if(isset($_POST['get'])) { $username1 = $_POST['user']; $sql_user = mysqli_real_escape_string ($connection, $username1); $rank = $_POST['rank']; $rank = mysqli_real_escape_string ($connection, $rank); $query1 = mysqli_query($connection, "SELECT rank FROM member WHERE username='$sql_user'"); if ($row = mysqli_fetch_array($query1)) { if ($rank == '1') { $data1 = mysqli_query($connection, "UPDATE member SET rank= '1' WHERE username='sql_user'") or die (mysql_error($connection)); echo "User has downgrade to member"; } elseif ($rank == '2') { $data2 = mysqli_query($connection, "UPDATE member SET rank= '2' WHERE username ='sql_user'") or die (mysql_error($connection)); echo "User has upgrade to admin"; } else { echo "Please check if you have put the right information."; } } } ?> This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=312470.0 Hello everyone... My following code is supposed to order rank by from Greatest covertaction but for some reason it is ranking the greatest last eg. 900,000 Rank 1 900,001 Rank 2 900,002 Rank 3 Here is the code: Code: [Select] <?php $q = "SELECT * FROM `accountinfo_db` ORDER BY `covertaction`, `anticovertaction` ASC"; $res = mysql_query($q) or die(mysql_error()); $i = 1; while($player=mysql_fetch_array($res)){ $id = securevar($player['id']); $time = time(); $user = securevar($player['username']); $q = "UPDATE `accountinfo_db` SET `covertrank` = '$i', `lastTurnTime` = '$time' WHERE `id` = '$id'"; if(mysql_query($q)){ echo "Covert & Anti Covert Rank set to $user as ".number_format($i)."!<br />"; } else { // query failed with an error // put your error reporting/logging code here... } $i++; } ?> Any help will be appreciated! Brian hi i have a table like this rank xp 1 0 2 50 3 100 4 200 say my username has 75xp how would a select which rank i am not sure how i can do this? :S cheers matt I have a small bit of jquery code that is not working:
$(function() { $(‘’[name=\'pet_type\']”).change(function() { $(‘’[name=\'breed\']”).removeAttr(‘disabled’); $(‘’[name=\'breed\']”).children(‘data-pet-type[name!=\'’ + $(this).val() + ‘\']’).hide(); $(‘’[name=\'breed\']”).children(‘data-pet-type[name=\'’ + $(this).val() + ‘\']’).show(); }); });My javascript is not good at all, so cannot spot errors? Any help would be much appreciated! Thanks Hi all My site is build using php includes. the index.php file contains code like <?php if(@$_GET['page'] == "web-design"){ include("includes/web-design.php"); } else if(@$_GET['page'] == "hosting"){ include("includes/hosting.php"); } else { include("includes/home.php"); } ?> I have created a sub domain blog.maplewebdesign.co.uk and a sub dircetory named blog. The link to this part of my site doesn't use includes, I want it to link directly to that sub directories index.php page. This works fine, but then when I click on a different link anywhere on the site my url is as follows www.maplewebdesign.co.uk/blog/index.php?page=home For some reason it is keeping the blog/ in the URL If you want to see go to http://www.maplewebdesign.co.uk/blog/ then click on a differnt link and check out the URL What am I doing wrong? Thanks Adi The password ARE correct. My code keeps saying that the password is INCORRECT. The password is MD5'ed once a user registers, and when they type in a password at the login (as shown), the password is also MD5'ed. Why is it that it's output is incorrect password? <?php session_start(); include("includes/mysql.php"); include("includes/config.php"); ?> <title><?php echo $title; ?></title> <?php if(!$_SESSION['user']) { $username = $_POST['username']; $password = $_POST['password']; $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); if(!$password || !$username) { echo ' <h1>Login</h1> <center><p><form action="login.php" method="POST"> <table border="0"> <tr><th>Username:</th> <td><input type="text" name="username" maxlength="20"><br/></td></tr> <tr><th>Password:</th> <td><input type="password" name="password" maxlength="30"><br/></td></tr> <tr><th></th><td><input type="submit" value="Login"></td></tr> </table></form></p></center> </div> '; } else { $query = mysql_query("SELECT COUNT(username),password,username FROM users WHERE username='$username'"); $check = mysql_fetch_assoc($query); $db_username = $check['username']; $password = md5($password); if($check['COUNT(username)'] < 1) { echo ' <p>No account exists with this username. Please go back.</p> '; } elseif($check['password']==$password && $db_username==$username) { echo ' <h1>Login Successful</h1> <p>You have successfully logged in! Return home.</p> '; $_SESSION['user']=$username; } else { echo ' <p>The password you have enetered in is incorrect. Please go back.</p> '; } } } else { echo ' <p>Your already logged in!</p> '; } ?> It's been a while since I've used my queries, can anyone tell me what's wrong with this mysql query? Code: [Select] $query = mysql_query("SELECT * FROM `chicken_names` WHERE `gender` = 'Hen' AND `name` LIKE '%$s_terms%' ORDER BY `likes` DESC") or die(mysql_error()); So I am trying to make an incorrect password message but the message never appears.
My code:
<? require "./includes/config.php"; $LS->init(); if(isset($_POST['act_login'])){ $user=$_POST['login']; $pass=$_POST['pass']; if($user=="" || $pass==""){ $msg=array("Error", "Username / Password Wrong !"); } else { if(!$LS->login($user, $pass)){ $msg=array("Error", "Username / Password Wrong !"); } } } ?> I have a register page that MD5 Hash's the users password and a login which also does this. However, no matter what I try it always says incorrect password. Even when I remove the MD5. Register Code: Code: [Select] <?php error_reporting (E_ALL ^ E_NOTICE); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Member System - Register</title> </head> <body> <?php if ( $_POST['registerbtn'] ){ $getuser = $_POST['user']; $getemail = $_POST['email']; $getpass = $_POST['pass']; $getretypepass = $_POST['retypepass']; if ($getuser){ if ($getemail){ if ($getpass){ if ($getretypepass){ if ( $getpass === $getretypepass ){ if ( (strlen($getemail) >= 7) && (strstr($getemail, "@")) && (strstr($getemail, ".")) ){ require("./connect.php"); $query = mysql_query("SELECT * FROM users WHERE username='$getuser'"); $numrows = mysql_num_rows($query); if ($numrows == 0){ $query = mysql_query("SELECT * FROM users WHERE email='$getemail'"); $numrows = mysql_num_rows($query); if ($numrows == 0){ $password = md5(md5("kjfiufj".$password."Fj56fj")); $date = date("F d, Y"); $code = md5(rand()); mysql_query("INSERT INTO users VALUES ( '', '$getuser', '$password', '$getemail', '0', '$code', '$date' )"); $query = mysql_query("SELECT * FROM users WHERE username='$getuser'"); $numrows = mysql_num_rows($query); if ($numrows == 1){ $site = "http://c3221281.web44.net/"; $webmaster = "Simon <admin@simon.com>"; $headers = "From: $webmaster"; $subject = "Activate Your Account"; $message = "Thanks for registering. Click the link below to activate your account.\n"; $message .= "$site/activate.php?user=$getuser&code=$code\n"; $message .= "You must activate your account to login."; if ( mail($getemail, $subject, $message, $headers) ){ $errormsg = "You have been registered. You must activate your account from the activation link sent to <b>$getemail</b>."; $getuser = ""; $getemail = ""; } else $errormsg = "An error has occueed. Your activation email was not sent."; } else $errormsg = "An error has occured. Your account was not created."; } else $errormsg = "There is already a user with that email."; } else $errormsg = "There is already a user with that username."; mysql_close(); } else $errormsg = "You must enter a valid email address to register."; } else $errormsg = "Your passwords did not match."; } else $errormsg = "You must retype your password to register."; } else $errormsg = "You must enter your password to register."; } else $errrosmg = "You must enter your email to register."; } else $errormsg = "You must enter your username to register."; } $form = "<form action='./register.php' method='post'> <table> <tr> <td></td> <td><font color='red'>$errormsg</font></td> </tr> <tr> <td>Username:</td> <td><input type='text' name='user' value='$getuser' /></td> </tr> <tr> <td>Email:</td> <td><input type='text' name='email' value='$getemail' /></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='pass' value='' /></td> </tr> <tr> <td>Retype:</td> <td><input type='password' name='retypepass' value='' /></td> </tr> <tr> <td></td> <td><input type='submit' name='registerbtn' value='Register' /></td> </tr> </table> </form>"; echo $form; ?> </body> </html> Login Code: Code: [Select] <?php error_reporting (E_ALL ^ E_NOTICE); session_start(); $userid = $_SESSION['userid']; $username = $_SESSION['username']; ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Member System - Login</title> </head> <body> <?php if ($username && $userid){ echo "You are already logged in as <b>$username</b>. <a href='./member.php'>Click here</a> to go to the member page."; } else{ $form = "<form action='./login.php' method='post'> <table> <tr> <td>Username:</td> <td><input type='text' name='user' /></td> </tr> <tr> <td>Password:</td> <td><input type='password' name='password' /></td> </tr> <tr> <td></td> <td><input type='submit' name='loginbtn' value='Login' /></td> </tr> <tr> <td><a href='./register.php'>Register</a></td> <td><a href='./forgotpass.php'>Forgot your password?</a></td> </tr> </table> </form>"; if ($_POST['loginbtn']){ $user = $_POST['user']; $password = $_POST['password']; if ($user){ if ($password){ require("connect.php"); $password = md5(md5("kjfiufj".$password."Fj56fj")); // make sure login info correct $query = mysql_query("SELECT * FROM users WHERE username='$user'"); $numrows = mysql_num_rows($query); if ($numrows == 1){ $row = mysql_fetch_assoc($query); $dbid = $row['id']; $dbuser = $row['username']; $dbpass = $row['password']; $dbactive = $row['active']; if ($password == $dbpass){ if ($dbactive == 1){ // set session info $_SESSION['userid'] = $dbid; $_SESSION['username'] = $dbuser; echo "You have been logged in as <b>$dbuser</b>. <a href='./member.php'>Click here</a> to go to the member page."; } else echo "You must activate your account to login. $form"; } else echo "You did not enter the correct password. $form"; } else echo "The username you entered was not found. $form"; mysql_close(); } else echo "You must enter your password. $form"; } else echo "You must enter your username. $form"; } else echo $form; } ?> </body> </html> Many thanks for your time and help, hello in the attached code, how do i add another field to the query? ie, i have all the code to create the result and would like to add further values such as $dept? what is the correct way to code query? i must stress that i am using php 4.4.7 so json_encode is out. the code is working but just need to find a way to add the $dept to the qeury? many thanks $dept = array(); $box = array(); while ($row = mysql_fetch_array($result)) { $dept[] = $row['department']; $box[] = $row['custref']; } /*$items = rtrim($_POST['items'],","); $sql = "UPDATE `boxes` SET status = 'Out' WHERE Id IN ($items)"; $result = runSQL($sql);*/ $total = count(explode(",",$items)); $result = runSQL($sql); $total = mysql_affected_rows(); /// Line 18/19 commented for demo purposes. The MySQL query is not executed in this case. When line 18 and 19 are uncommented, the MySQL query will be executed. header("Expires: Mon, 26 Jul 1997 05:00:00 GMT" ); header("Last-Modified: " . gmdate( "D, d M Y H:i:s" ) . "GMT" ); header("Cache-Control: no-cache, must-revalidate" ); header("Pragma: no-cache" ); header("Content-type: text/x-json"); $json = ""; $json .= "{\n"; $json .= "box: [\"". implode('","', $box) ."\"]\n"; $json .= "}\n"; echo $json; $sql = "INSERT INTO `act` (`item`) VALUES ('". implode("'),('", $box) . "')"; $result = runSQL($sql); Currently I have 5 entries in my table. Entring this query displays all five in the correct order. Code: [Select] SELECT * FROM products ORDER BY count DESC LIMIT 16 However, using this code, the first result is omitted and the last four are displayed. $query="SELECT * FROM products ORDER BY count DESC LIMIT 16"; $result = mysql_query($query); $row = mysql_fetch_array($result); echo '<div>'; while ($row = mysql_fetch_array($result)) { echo '<div>'.$row[product].'</div> <div>'.$row[count].'</div>'; } echo '</div>'; Can someone help me find my error? Thanks i am writing this script for use as an include in joomla and the directphp plugin so in my joomla article i have: Code: [Select] <?php include 'test/conducttest.php'; conducttest(); ?> Ok now my issue! the form in this function is passing only the values for the last item in the loop rather than for the selected radio item when submitted. so when say for example the radio selected is: ID TEST TYPE UNIQUE TEST ID AVAILABLE 5 Adolescent Clinical 50021629 1 and the last item in the list is: ID TEST TYPE UNIQUE TEST ID AVAILABLE 4 Adult Clinical 12341629 1 When the form is submitted even if the 1st item is selected, it returns the value for the second one. I am sorta new to php so any suggestions will be appreciated. Here is my full code: Code: [Select] <?php function conducttest() { //GET JOOMLA USER ID & USERNAME FOR LOGGED USER $user =& JFactory::getUser(); $userID = $user->id; //GET JOOMLA DATABASE OBJECTS $db =& JFactory::getDBO(); //NEW TESTS QUERY (what purchased test are available for use with 'item_available' == '1' {unused test} and matching current 'user_id') $new_query = " SELECT * FROM crt_transactionHistory WHERE user_id = ".$userID." AND item_available = '1' ORDER BY item_name, id "; $db->setQuery($new_query); $new = $db->loadAssocList(); //OPEN TESTS QUERY (what purchased test are available for use with 'item_available' == '2' {resume test} and matching current 'user_id') $resume_query = " SELECT * FROM crt_transactionHistory WHERE user_id = ".$userID." AND item_available = '2' ORDER BY item_name, id "; $db->setQuery($resume_query); $resume = $db->loadAssocList(); //DISPLAY use_test FORM if(!isset($_POST['test'])) { //SELECT FORM: WHICH TEST WOULD YOU LIKE TO USE? echo ' <fieldset> <table> <form method="post" action="'.$PHP_SELF.'">'; if (empty($new)) { echo ' <th colspan="3"align="left">NO NEW TESTS AVAILABLE</th>'; } else { echo ' <th colspan="3"align="left">NEW TESTS AVAILABLE</th> <tr> <td width="75px">SELECT</td> <td width="50px">ID</td> <td width="150px">TEST TYPE</td> <td width="150px">UNIQUE TEST ID</td> <tr>'; foreach ($new as $result1) { echo ' <tr> <td><input type="radio" value="' .$result1['id']. '" name="test_id"></td> <td>'.$result1['id'].'</td> <td><input type="hidden" value="'.$result1['item_name'].'" name="item_name">'.$result1['item_name'].'</td> <td><input type="hidden" value="'.$result1['item_number'].'" name="item_number">'.$result1['item_number'].'</td> <input type="hidden" value="'.$result1['item_available'].'" name="item_available"> <input type="hidden" value="'.$userID.'" name="userID"> <tr>'; } } echo ' </table> <hr /> <table>'; if (empty($resume)) { echo ' <th colspan="3"align="left">NO TESTS TO RESUME</th>'; } else { echo ' <th colspan="3"align="left">RESUME TEST</th> <tr> <td width="75px">SELECT</td> <td width="50px">ID</td> <td width="150px">TEST TYPE</td> <td width="150px">UNIQUE TEST ID</td> <tr>'; foreach ($resume as $result2) { echo ' <tr> <td><input type="radio" value="' .$result2['id']. '" name="test_id"></td> <td>'.$result2['id'].'</td> <td><input type="hidden" value="'.$result2['item_name'].'" name="item_name">'.$result2['item_name'].'</td> <td><input type="hidden" value="'.$result2['item_number'].'" name="item_number">'.$result2['item_number'].'</td> <input type="hidden" value="'.$result2['item_available'].'" name="item_available"> <input type="hidden" value="'.$userID.'" name="userID"> <tr>'; } } echo ' </table> </fieldset> <input type="submit" name="test" value="Conduct Test" /> </form> '; } //NOW A TEST HAS BEEN SELECTED FOR USE if(isset($_POST['test'])) { $test_id = $_POST['test_id']; $item_name = $_POST['item_name']; $item_number = $_POST['item_number']; $item_available = $_POST['item_available']; $userID = $_POST['userID']; echo $test_id.'<br />'; echo $item_name.'<br />'; echo $item_number.'<br />'; echo $item_available.'<br />'; echo $userID.'<br />'; //IF THIS IS A NEW TEST... if ($item_available == "1") { echo 'new test'; } //IF WE ARE RESUMING A TEST... elseif ($item_available == "2") { echo 'resume test'; } } } ?> I have the following query: $getVideos = mysql_query("SELECT catergory, COUNT(catergory) as 'catCount' FROM videos GROUP BY catergory"); Using this in PHPMyAdmin returns the correct results of: catergory | catCount 0 | 7 1 | 1 10 | 2 How would get those results into a PHP array or what not...I have done this before but along time ago and cannot for the life of me remember how to do it. Hopefully someone can point me in the right direction? Regards, PaulRyan. this is the query: $query = "INSERT INTO kamerleden VALUES ('', '$twitter_id', '$name', '$nickname', '$fraction', '$residence', '$age', '$gender', '', '', '', '')"; it used to work but i switched to a different hosting. The first '' is the id which gives this error: query failed: Incorrect integer value: '' for column 'id' at row 1 in the database id is a int, with a length of 2 and with auto increment. How can i fix it? Hello folks, I've got a problem with a search script. It's searching a db containing various properties (as in buildings) and it's not quite returning the correct results. The search form asks that you select a house type (4 options, all of which are tick boxes) and then the last part of the form is select how many bedrooms you'd like (which is a drop-down list featuring numbers 2-5) What should happen is someone selects one or more of the tick boxes and then the number of bedrooms and it returns all the house types that were ticked but only those with the number of bedrooms that were specified in the original search. Currently the results are correct in that they're showing the correct house types, but the number of bedrooms isn't right. e.g. if you chose 2 bedrooms in the search it shows those, as well as 3, 4 and 5 bedrooms in the results. Can't figure it out but it will be something to do with && and OR in my search script. Can anyone suggest a tweak to this that might work? (I'm using the $_GET function because the search form is in a Flash movie) $Result = mysql_query("select * from property_names where TownHouse = '$_GET[TownHouse]' OR Apartment = '$_GET[Apartment]' OR Detached = '$_GET[Detached]' OR SemiDetached = '$_GET[SemiDetached]' && visible= 'Yes' && bedrooms = '$_GET[Bedrooms]' && bedrooms = '$_GET[Bedrooms]'") Incorrect login attempt 1 \/ Incorrect login attempt 2 \/ Incorrect login attempt 3 -->> ?forgot your login details? What's the most effecient way of achieving this? Is it to: 1. create a session for the user who hasn't logged in 2. the user login fails once, session['fail']=1 3. the user login fails twice, session['fail']=2 4. the user login fails for a third time pushing the session['fail'] count to three: this triggers an 'if' on the index.php prompting the user to retrieve their details through the "forgot login details system" However if the session['fail'] count never reaches 3 then this temp session is destroyed and the proper one created allowing the user into the site?? As usual any pointers into the correct direction here would be very much appreciated (and i try to repay by answering other peoples questions [where i can ]) |