According to my knowledge a CMS exists for creating a tool which is used by people who write text and aren't interested in or hired to print code. A great advantage is that users can't mess up the structure of my design.
So I was trying to develop a table with input fields like code1.
But I really wanted to combine it with a code like code2. see underneath
code1
<?php
function valid_var1($str) {
return (ereg ('[0-9]{0,}$', $str));
}
function valid_var2($str) {
return (ereg ('[0-9]{0,}$', $str));
}
function valid_var3($str) {
return (ereg ('[0-9]{0,}$', $str));
}
function valid_var4($str) {
return (ereg ('[0-9]{0,}$', $str));
}
$var1= $_POST['var1'];
$var2= $_POST['var2'];
$var2= $_POST['var3'];
$var2= $_POST['var4'];
if ($verzendbutton != "verzenden" || !valid_var1($var1) || !valid_var2($var2)) {
echo "<form action=\"$PHP_SELF\" method=\"post\">";
?>
<table width="161" border="1">
<tr>
<td width="71"><input type="text" name="var1" value="<?php echo $var1?>" size="10" maxlength="10"></td>
<td width="74"><input type="text" name="var2" value="<?php echo $var2?>" size="10" maxlength="10"></td>
</tr>
<tr>
<td><input type="text" name="var3" value="<?php echo $var3?>" size="10" maxlength="10"></td>
<td><input type="text" name="var4" value="<?php echo $var4?>" size="10" maxlength="10"></td>
</tr>
<tr/><td colspan="2">
<input type="submit" value="verzenden" name="verzendbutton">
<input type="reset" value="wissen" name="wissen">
</td></tr></table>
</form>
<?php
}else{
echo "<table border=\"1\">";
echo "<tr><td>$var1</td><td>$var2</td></tr>";
echo "<tr><td>$var3</td><td>$var4</td></tr>";
echo "</table>";
}
?>
code2
<?php
$var1=$_POST['var1'];
$var2= $_POST['var2'];
function valid_var1($str) {
return (ereg ('[0-9]{0,}$', $str));
}
function valid_var2($str) {
return (ereg ('[0-9]{0,}$', $str));
}
if ($verzendbutton != "verzenden" || !valid_var1($var1) || !valid_var2($var2)) {
echo "<form action=\"$PHP_SELF\" method=\"post\">";
?>
<title>tabel creeren</title>
<table>
<tr><td>
Rijen</td><td><input type="text" name="var1" value="<?php echo $var1?>" size="10" maxlength="10">
</td><td width="103"> </td>
</tr>
<tr>
<td> </td>
<td colspan="2"><?php if ($verzendbutton && !valid_var1($var1)) {
echo "<span class=\"fout\">Vul hier het aantal rijen in</span>";
}
?></td>
</tr>
<tr><td>
Kolommen</td><td><input type="text" name="var2" value="<?php echo $var2 ?>" size="10" maxlength="10">
</td>
</tr>
<tr>
<td> </td>
<td colspan="2"><?php if ($verzendbutton && !valid_var2($var2)) {
echo "<span class=\"fout\">Vul hier het aantal rijen in</span>";
}
?></td>
</tr>
<tr><td>
<input type="submit" value="verzenden" name="verzendbutton">
<input type="reset" value="wissen" name="wissen">
</td></tr></table>
</form>
<?php
} else { // in alle andere gevallen (dus formulier verzonden)
echo "<form action=\"$PHP_SELF\" method=\"post\">";
$cols = "<td> How can I put input fields here which stores user-input variabels and print it to screen? after submitting?</td>";
$rows = "<tr>";
$rowsend = "</tr>";
echo '<table>';
for ( $rij =0; $rij < $var1; $rij++ ){
echo "$rows";
for ($col=0; $col < $var2; $col++ ){
echo "$cols";
}
echo "$rowsend";
}
echo '</table>';
}
echo "</form>";
?>
Yess, both my codes works seperately, but when I receive two integers 1 for rows, 1 for columns,
How can I put input fields which stores user-input variabels and print it to screen? after submitting?
at first I wanna create $input1, $input2, $input3 etc for storing in a Mysql database. and of course display it after submission for public.
I hope my examples are clear and my extra info too.
I am sorry for using some HTML in the examples. I didn't know how to describe it otherwise.
Thanks in advance