SQL data not returning result on page post.

Permalink
I am having some troubles, and I think it's because I have been deep in .NET/SQL for awhile and jumped on a PHP/MySQL project.

I have a drop down list that I'm using as a filter option, and when a choice is selected, I have the selection appending in a sql statement to filter data again.

It's not triggering the sql query and I'm banging my head trying to get it working.

<?php
$con = mysql_connect("server","user","pass");
if (!$con)
{
  die('Could not connect: ' . mysql_error());
}
mysql_select_db("database", $con);
//IF THE FLAG HASN'T BEEN SET YET, SET THE DEFAULT
if(!isset($_GET['orderBy'])) {
     $_GET['orderBy'] = 'FRSTNAME';
}
//FIGURE OUT HOW TO SORT THE TABLE
switch($_GET['orderBy']) {
     case 'FRSTNAME':
     case 'LASTNAME':


Thank you a ton! Oh and the data column names are set by the client, as well as it's pulling from their server MySql database, which does work on the initial page load.

Deladroid
 
kieranrushby replied on at Permalink Best Answer Reply
kieranrushby
Hi,

Is departmentName as string? if so I think you need to enclose it in quotes.

$sql_filterBy = '= \'' . $_POST['department'].'\'';


or

$sql_filterBy = "= '" . $_POST['department']."'";


Cheers

Kieran
Deladroid replied on at Permalink Reply
Deladroid
Aww good catch. That may be it. I'll try it soon.

Thanks for the reply!
Deladroid replied on at Permalink Reply
Deladroid
To close the loop and mark answer-- that was the problem.

Thank you!
kieranrushby replied on at Permalink Reply
kieranrushby
Glad to help..