0
我想使用在while循环外创建的变量。 这是因为我有不同的变量,我想放在海誓山盟之后(逗号分隔)并放入一个字符串变量。之后,我将删除最后一个逗号。在while循环中创建变量并在循环中使用
这是我的代码
$result = mysql_query("SELECT * FROM ".$_POST['moduleName']);
while($row = mysql_fetch_array($result))
{
//read fieldnames from database
$fieldName = $row['modFieldName'];
//creating a variable with the fieldname
$fieldName = 'field'.$fieldName;
//fill Variable with posted input
$fieldName = $_POST[$row['modFieldName']];
//Put fieldname in a string (outputs: a,b,c,d,e,)
$postString = $fieldName.",";
}
//Remove last comma
$postString = substr($postString,0,-1);
echo $postString;