I have a search query that looks like this which works fine (the end result outputs a CVS file):
$values = mysql_query("SELECT * FROM database_gcp_contact WHERE role = '13'");
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= $rowr[$j].", ";
}
$csv_output .= "\n";
}
However I need to make this sligntly more complex. Im trying to do something like the following (but this does not work).
$values = mysql_query("SELECT * FROM database_gcp_contact WHERE table_id > '0'
if ($role) {
AND table_role = '$role'
}
if ($position) {
AND table_position = '$position'
}
");
while ($rowr = mysql_fetch_row($values)) {
for ($j=0;$j<$i;$j++) {
$csv_output .= $rowr[$j].", ";
}
$csv_output .= "\n";
}