ziedinjsh Posted October 27, 2009 Report Share Posted October 27, 2009 (edited) 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 October 27, 2009 by ziedinjsh Quote Link to comment Share on other sites More sharing options...
Indian Posted October 27, 2009 Report Share Posted October 27, 2009 (edited) kas tieši nestrādā ? Edited October 27, 2009 by Indian Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 27, 2009 Author Report Share Posted October 27, 2009 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 Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted October 27, 2009 Report Share Posted October 27, 2009 while($data = mysql_fetch_assoc($news)) echo "<option value='".$data['news_title']."'>".$data['news_title']."</option>"; ja es pareizi sapratu ko vēlies. Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 27, 2009 Author Report Share Posted October 27, 2009 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 Quote Link to comment Share on other sites More sharing options...
rATRIJS Posted October 27, 2009 Report Share Posted October 27, 2009 Nu bet tu jau pats selekto visas ziņas - kas tu domā viņš automātiski nolasīs tevis izvēlēto ziņu? Quote Link to comment Share on other sites More sharing options...
ziedinjsh Posted October 27, 2009 Author Report Share Posted October 27, 2009 nē, tapēc es arī jautāju.. jo es nesaprotu kā to izdarīt. Zinu ka šis while($data = mysql_fetch_array($news)) {} parāda visus ierakstus, bet nu es nevaru nekoizdomāt un tālāk netieku! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.