Skip to main content
Inspiring
July 9, 2009
Question

Mysql Recordset help

  • July 9, 2009
  • 1 reply
  • 326 views

Can anyone help me sort this out.

This code should spit out only the records that match a URK parameter $courscode but whatever I do it returns every record. I just can't figure out why?

$query_rs_dates = sprintf("SELECT * FROM dates09 UNION SELECT * FROM dates10 WHERE coursecode = '$coursecode' ORDER BY id", GetSQLValueString($colname_rs_dates, "text"));
$rs_dates = mysql_query($query_rs_dates, $con_tyf) or die(mysql_error());
$row_rs_dates = mysql_fetch_assoc($rs_dates);
$totalRows_rs_dates = mysql_num_rows($rs_dates);

Can anyone tell me where I am going wrong.

Cheers

Dave

This topic has been closed for replies.

1 reply

Inspiring
July 9, 2009

Don't worry, I have fixed it.

Seems you have to have the WHERE bit first for each table. Like this:

SELECT * FROM dates09 WHERE coursecode = '$coursecode') UNION (SELECT * FROM dates10 WHERE coursecode = '$coursecode')


Sorry if I put anyone to any trouble. But maybe this will help someone with the same problem in the future

Cheers

Dave