Jump to content


Photo

HELP PLEASE! selecting rows using multiple sql statements


  • Please log in to reply
1 reply to this topic

#1 ICEcoffee

ICEcoffee
  • Members
  • PipPip
  • Member
  • 19 posts

Posted 12 November 2003 - 02:35 PM

Hi all

I am developing a mysql/php database using Dreamweaver MX.

I have a page which selects rows from a number of recordsets. One of these recordsets selects from a table named notetaker. the criteria for selecting appropriate records are: a) from URL \"CustomerID\" and B) if field catagory = \"maintenance\". in dreamweaver mx this works:

SELECT *
FROM notetaker
WHERE CustomerID = colname
ORDER BY CtelNoteID ASC (see also below for full code)

BUT THIS DOES NOT:

SELECT *
FROM notetaker
WHERE CustomerID = colname AND notetaker.Catagory=\"maintenance\"
ORDER BY CtelNoteID ASC

I need to sort this sharpish, so quick help really appreciated.

cheers

***************** code **************************************
$colname_RSnotes = \"1\";
if (isset($HTTP_GET_VARS[\'CustomerID\'])) {
$colname_RSnotes = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS[\'CustomerID\'] : addslashes($HTTP_GET_VARS[\'CustomerID\']);
}
mysql_select_db($database_connDiamond, $connDiamond);
$query_RSnotes = sprintf(\"SELECT * FROM notetaker WHERE CustomerID = %s ORDER BY CtelNoteID ASC\", $colname_RSnotes);
$RSnotes = mysql_query($query_RSnotes, $connDiamond) or die(mysql_error());
$row_RSnotes = mysql_fetch_assoc($RSnotes);
$totalRows_RSnotes = mysql_num_rows($RSnotes);

*********************************************************

#2 shivabharat

shivabharat
  • Members
  • PipPipPip
  • Advanced Member
  • 371 posts
  • LocationChennai, India

Posted 13 November 2003 - 06:11 AM

I guess the problem is in the query formation

$query_RSnotes = sprintf("SELECT * FROM notetaker WHERE CustomerID = %s ORDER BY CtelNoteID ASC", $colname_RSnotes); echo $query_RSnotes;

see what you get when you display the query?

You can also try this

$query_RSnotes = "SELECT * FROM notetaker WHERE CustomerID =\'$colname_RSnotes\' ORDER BY CtelNoteID ASC"; echo $query_RSnotes;

Knowledge --- Reading Enriches Mind But Sharing Enhances It.[br][br]Note: Before you request help enusre that you have had a look at the tutorials @phpfreaks




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users