0
$SQL="SELECT * FROM stats ORDER BY $teamval";

$result=mysql_query($SQL);

$num_results=mysql_num_rows($result);

$teamval is a value defined by a user, which is defined by selecting it in a dropdown list (The selections are all from a database)

What I'm getting is "Warning: mysql_num_rows() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\wamp\www\processlvl1.php on line 44"

Any solutions?

Edit: the variable for $teamval is not a column, it's a variable in a column.

The database tables look something like this:

First Name Last Name Team John Smith ROH Jake Harvey ROH Jerome Micheals ANE

Basically trying to get it to output only the names paired with a certain team that is selected by the user

John AJ
  • 21
  • 1
  • 7

1 Answers1

0

mysql_query return false if the request fail, not a resource. So meaby the error is your query.

try :

mysql_query($SQL) or die(mysql_error());

Thay will explain to you what is wrong

Yoann Augen
  • 1,966
  • 3
  • 21
  • 39
  • Unknown column 'ANA' in 'order clause' – John AJ Nov 27 '13 at 20:20
  • Not sure where it's getting 'order clause' from, but ANA is not a column, it's a variable in a column, so I guess I'm sorting it wrong? – John AJ Nov 27 '13 at 20:21
  • so you are trying to order you result by a field that doen't exist (it is case sensitive) – Yoann Augen Nov 27 '13 at 20:22
  • Yes, the order must be focus on name of a column. – Yoann Augen Nov 27 '13 at 20:23
  • yeah, I guess. Basically 'ANA' is a team under the column of 'Team', but I just want it to display everyone on that team (Who is in another column called 'First_Name'). Is it just the way I wrote it wrong? – John AJ Nov 27 '13 at 20:23