Hi All.
Sorry if I have broken the rules but I first posted this in the CODE section and afte rthink for for a time I think it should be in the DATABASE section.
I am trying to run a query that looks at the content of a SESSION variable (colname) and runs the query to extract data from 2 tables.
This is the complete code.
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
$maxRows_members = 10;
$pageNum_members = 0;
if (isset($GET['pageNum_members'])) {
$pageNum_members = $GET['pageNum_members'];
}
$startRow_members = $pageNum_members * $maxRows_members;
$colname_members = "-1";
if (isset($SESSION['member_id'])) {
$colname_members = (get_magic_quotes_gpc()) ? $SESSION['member_id'] : addslashes($_SESSION['member_id']);
}
mysql_select_db($database_table2, $table2);
$query_members = sprintf("SELECT * FROM table2 WHERE member_id = %s", GetSQLValueString($colname_members, "text"));
$query_limit_members = sprintf("%s LIMIT %d, %d", $query_members, $startRow_members, $maxRows_members);
$members = mysql_query($query_limit_members, $table2) or die(mysql_error());
$row_members = mysql_fetch_assoc($members);
if (isset($GET['totalRows_members'])) {
$totalRows_members = $GET['totalRows_members'];
} else {
$all_members = mysql_query($query_members);
$totalRows_members = mysql_num_rows($all_members);
}
$totalPages_members = ceil($totalRows_members/$maxRows_members)-1;
?>
[/code]
WHERE condition 'colname'? . colname holds the data from the SESSION variable.
Can anyone help please