Jump to content
php.lv forumi

teksta saglabashana ar formas palidzibu db


marlboro

Recommended Posts

labdien esu izveidojis "textarea" kura ierakstitais texts pec pogas nospieshanas - "Saglabāt" tiek saglabats DB konkreta tabulaa

PIEMERS :

<form name="form1" method="post" action="update.php">
Ievadi lapas saturu :<br><textarea rows="10" cols="60" name="Saturs1"><?php echo "$Saturs1" ?></textarea>
<input type="submit" name="Submit" value="Saglabāt">
</form>
</body>
</html>

 

velos bet isti nesaprotu ka lai izveido kipa "list menu" kura ir piem Saturs1 Saturs2 , izveloties Saturs1 es varu ieraxtiit tekstu tabulaa 1 ,izveloties Saturs2 varu ierakstit tabula2 ? ka isti tas butu jataisa ?

Link to comment
Share on other sites

Kur klūda ? PRicnipa saturu vinsh man izdruka bet kad parsledzu uz saturs2 nekas nemainas... ko daru nepareiiz ?

 

<form name="form1" method="post" action="updatePage.php">

Izvēlies lapu :

<select name="select">

<option value="<?php $x = 1; ?>">saturs1</option>

<option value="<?php $x2 = 2; ?>">saturs2</option>

</select>

<br><textarea rows="10" cols="60" name="contents">

 

 

<?php

$saturs_x = $x;

 

if($saturs_x == 1){

echo "$contents";

 

}else{

echo "nau!!";

}

?>

</textarea>

<input type="submit" name="Submit" value="Saglabāt">

</form>

Link to comment
Share on other sites

Uzraksti sekojoši:

 

<form name="select_content" method="get" id="select_content">
Izvēlies lapu :
<select name="lapa" onchange="document.forms['select_content'].submit();">
<option value="1">saturs1</option>
<option value="2">saturs2</option>
</select>
</form>

<form name="form1" method="post" action="updatePage.php">

<br><textarea rows="10" cols="60" name="contents">

<?php
$saturs_x = (int)$_GET['lapa'];

if($saturs_x == 1){
echo "$contents";

}else{
echo "nau!!";
}
?>
</textarea>
<input type="submit" name="Submit" value="Saglabāt">
</form>

Link to comment
Share on other sites

Pamaini koda augšdaļu uz:

<?php
$select_opts = array(1,2);

if ($_GET['lapa']) {
$lapa = (int)$_GET['lapa'];
} else {
$lapa = 0;
}
if (!ins_array($lapa, $select_opts))
$lapa = 0;
?>
<form name="select_content" method="get" id="select_content">
Izvēlies lapu :
<select name="lapa" onchange="document.forms['select_content'].submit();">
<option value="0" <?php if ($lapa==0) echo 'selected';?>></option>
<option value="1" <?php if ($lapa==1) echo 'selected';?>>saturs1</option>
<option value="2" <?php if ($lapa==2) echo 'selected';?>>saturs2</option>
</select>
</form>

Link to comment
Share on other sites

hmm . nu kad salieku tavu doto piemeru kopa ar ieprieksh mineeto nekas nedarbojas :(

 

<?php
$select_opts = array(1,2);

if ($_GET['lapa']) {
$lapa = (int)$_GET['lapa'];
} else {
$lapa = 0;
}
if (!ins_array($lapa, $select_opts))
$lapa = 0;
?>
<form name="select_content" method="get" id="select_content">
Izvēlies lapu :
<select name="lapa" onchange="document.forms['select_content'].submit();">
<option value="0" <?php if ($lapa==0) echo 'selected';?>></option>
<option value="1" <?php if ($lapa==1) echo 'selected';?>>saturs1</option>
<option value="2" <?php if ($lapa==2) echo 'selected';?>>saturs2</option>
</select>
</form>

<form name="form1" method="post" action="updatePage.php">

<br><textarea rows="10" cols="60" name="contents">

<?php
$saturs_x = (int)$_GET['lapa'];

if($saturs_x == 1){
echo "$contents";

}else{
echo "nau!!";
}
?>
</textarea>
<input type="submit" name="Submit" value="Saglabāt">
</form>

Link to comment
Share on other sites

×
×
  • Create New...