PHP文章录入数据库后如何正确显示出来 本人的代码如下
<?php require_once('../Connections/myconn.php'); ?>
<?php
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = (!get_magic_quotes_gpc()) ? addslashes($theValue) : $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;
}
$editFormAction = $_SERVER['PHP_SELF'];
if (isset($_SERVER['QUERY_STRING'])) {
$editFormAction .= "?" . htmlentities($_SERVER['QUERY_STRING']);
}
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
$insertSQL = sprintf("INSERT INTO inform (title, subtitle, content, typist) VALUES (%s, %s, %s, %s)",
GetSQLValueString($_POST['title'], "text"),
GetSQLValueString($_POST['subtitle'], "text"),
GetSQLValueString($_POST['content'], "text"),
GetSQLValueString($_POST['typist'], "text"));
mysql_select_db($database_myconn, $myconn);
$Result1 = mysql_query($insertSQL, $myconn) or die(mysql_error());
$insertGoTo = "inform.php";
if (isset($_SERVER['QUERY_STRING'])) {
$insertGoTo .= (strpos($insertGoTo, '?')) ? "&" : "?";
$insertGoTo .= $_SERVER['QUERY_STRING'];
}
header(sprintf("Location: %s", $insertGoTo));
}
?>
$sql="SELECT * FROM ($datebase_myconn)";/**æ¥è¯¢ä½ çæ°æ®åºéé¢çå 容çè¯å¥**/
$query=mysql_query($sql);/**ææ¥è¯¢è¯å¥æ§è¡**/
while($show=mysql_fetch_array($query))/**éåæ°æ®åºéçæ¡æ°**/
{
echo $show['title'];/*è¿éä½ å¯ä»¥æå ¥å°htmlçéé¢ï¼echoçå 容æ¯ä½ çæ°æ®åºéé¢çå 容ï¼titleå¯ä»¥æ¢æsubtitle, contentä»ä¹çï¼å°±çä½ çæ°æ®æ¯ä»ä¹äº*/
}
mysql_close($myconn);//ææå¼å°±æå ³é^_^
æ¾ç¤ºæç« çæ°æ®åºå 容ï¼ç®åçå°±æ¯æä½ çåå ¥æ°æ®çå 容æ¹ææ¥æ¾ï¼ç¶å读åºæ¥èå·²
mysql_fetch_array
用法查阅手册