【发布时间】:2011-07-24 19:08:55
【问题描述】:
我的mysql数据库
ID platos mhkos
1 22 33
2 15 12
按 ID 和结果搜索 = platos + mhkos 如何?
我的代码是
<?php require_once('Connections/hlios.php'); ?>
<?php echo $row_test['platos']; ?>+ <?php echo $row_test['mhkos']; ?>
= <?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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;
}
}
$colname_test = "-1";
if (isset($_GET['client_id'])) {
$colname_test = $_GET['client_id'];
}
mysql_select_db($database_hlios, $hlios);
$query_test = sprintf("SELECT * FROM carpets_1 WHERE id = %s", GetSQLValueString($colname_test, "int"));
$test = mysql_query($query_test, $hlios) or die(mysql_error());
$row_test = mysql_fetch_assoc($test);
$totalRows_test = mysql_num_rows($test);
mysql_free_result($test);
?>
【问题讨论】:
-
您的问题对我来说似乎不清楚。请您举例说明您要实现的目标吗?
-
你的意思是如何得到两列的总和?如果是,请编辑问题的标题。