Jump to content
php.lv forumi

select forma


ziedinjsh

Recommended Posts

Kādu brīdi jau domāju un netieku skaidrībā kā lai uztaisa select kurā rādītos news_title. Izvēloties kādu no news_title, uzpiežu uz pogu, atveras input formās title un news, un varu viņus izlabot. Apakša uzspiežot pugu saglabājas..

 

$news = mysql_query("SELECT * FROM news ORDER BY news_id DESC");






if (isset($_POST['edit_news'])) {

$news_title = strip_tags($_POST['news_title']);
$news_news = strip_tags($_POST['news_news']);
$news_date = date("y-m-d");
$news_id = $_POST['news_id'];



$news = mysql_query("UPDATE news SET news_title='$news_title',news_news='$news_news',news_date='$news_date' WHERE news_id='$news_id'  ");
  echo "Jaunumi ir izlaboti";

}	










echo "<form method='post' action='".$_SERVER['PHP_SELF']."'>";
echo "<select name='news_id'>";
echo "<option value='".$data['news_title']."'>".$data['news_title']."</option>";
echo "</select>";
echo "<input type='submit' name='edit' value='Atvērt'>";
echo "</form>";  

while($data = mysql_fetch_array($news))
{

echo "<form method='post' action='".$_SERVER['PHP_SELF']."'>";
echo "<table></tr>";
echo "<td>Title</td><td><input type='text' name='news_title' value='".$data['news_title']."'></td>";
echo "</tr><tr>";
echo "<td>News</td><td><textarea name='news_news'>".$data['news_news']."</textarea></td>";
echo "</tr><tr>";
echo "<td></td><input type='hidden' name='news_id' value='".$data['news_id']."'><td><input type='submit' name='edit_news' value='Labot jaunumus'></td>";
echo "</tr></table>";
echo "</form>";

 }


Edited by ziedinjsh
Link to comment
Share on other sites

tas kā tagad izskatās:

echo "<form method='post' action='".$_SERVER['PHP_SELF']."'>";
echo "<select name='news_id'>";
echo "<option value='".$data['news_title']."'>".$data['news_title']."</option>";
echo "</select>";
echo "<input type='submit' name='edit' value='Atvērt'>";
echo "</form>";  

 

šeit neparādās nekas.. tas tapēc ka viņš ir pirms while($data = mysql_fetch_array($news)) { }

 

bet kad ielieku zem tad atkal viņš pie katra news rāda to select un tikai ar vienu title..

 

kā panākt lai rādās tikai divas formas.. nu input forma un textarea un augšā ar select izvēlos pēc title uzpiežo pugu un tajās formās atveras izvēlētais news_title un news_news

Link to comment
Share on other sites

while($data = mysql_fetch_assoc($news))
echo "<option value='".$data['news_title']."'>".$data['news_title']."</option>";

 

ja es pareizi sapratu ko vēlies.

 

Tā nē.. Doma ir tāda.. ieiet edit_news.php

 

tur ir selekts kurā tu izvēlies jaunumus kurus tu gribi labot. Izvēlies vienu uzpiež uz pogu un lejā <input formā> un <textarea> parādās news_title un news_news

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...