Closed Thread
Results 1 to 2 of 2

Thread: Selecting Via Combo Box

  1. #1
    Bioshox is offline Programmer
    Join Date
    Oct 2009
    Location
    Manchester, UK
    Posts
    196
    Rep Power
    10

    Selecting Via Combo Box

    Hey

    I need to update a post in a blogging system via a combo box, i have it at the moment so the combo box lists all the posts in the blog

    But i need it when submit is pressed for the ID of the post to go to a variable

    At the moment i have it so the user has to type in the ID ina text box here is the code for the update and getpost pages

    its just not working!

    Code:
    <?php 
    include "../config.php";
    ?>
    
    <html>
    <head>
    <title> Fusion Strike; Live! - Edit Post</title>
    <link rel="stylesheet" href="../style.css" type="text/css" >
    <body>
    <img src="../images/logo.png">
    <br>
    <div id="page-wrap">
    
    	<h4>
    		<?php include "../bloginfo.php"; ?>
    	
    	</h4>
    
    <h6>
    	
    	<?php include "navadmin.php"; ?>
    	
    </div>
    </h6>
    <div id="page-wrap">
    <h6><a href="admin.php">Back to Admin Center</a></h6>
    
    <?
    
    
    // If submitted, check the value of "select". If its not blank value, get the value and put it into $select.
    if(isset($select)&&$select!=""){
    $select=$_GET['select'];
    }
    ?>
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
    </head>
    <body>
    <form id="form1" name="form1" method="get" action="update.php">
    Car company :
    <select name="select">
    <option value="">--- Select ---</option>
    <?
    // Get records from database (table "name_list").
    $list=mysql_query("select * from cms order by id asc");
    
    // Show records by while loop.
    while($row_list=mysql_fetch_assoc($list)){
    ?>
    <option value="<? echo $row_list['id']; ?>" <? if($row_list['id']==$select){ echo "selected"; } ?>><? echo $row_list['title']; ?></option>
    <?
    // End while loop.
    }
    ?>
    </select> 
    <input type="submit" name="Submit" value="Select" />
    </form>
    
    </body>
    </html>
    
    
    	
    
    
    
    		<?php include "../footer.php"; ?>
    and

    Code:
    <?php 
    include "../config.php";
    ?>
    
    <?php
    
    if(isset($_POST['submit'])){
    $title = $_POST['title'];
    $content = $_POST['content'];
    $name = $_SESSION['nameadmin'];
    $id = mysql_real_escape_string($id);
    $postid = $row_list['id']; 
    
    	$post_new_content = $_POST['content']; //get the user-admin filled in new content for the post 
        $update_post = mysql_query("UPDATE cms SET body = '".addslashes(mysql_real_escape_string($_POST['content']))."' WHERE id = '$postid' ")or die(mysql_error()); 
    	
    	$post_new_title = $_POST['title']; //get the user-admin filled in new content for the post 
        $update_title = mysql_query("UPDATE cms SET title = '".addslashes(mysql_real_escape_string($_POST['title']))."' WHERE id = '$postid' ")or die(mysql_error()); 
    echo "Content Updated<br><a href='../index.php' >Home</a>";
    }else {
    ?>
    <p>
    <form action='update.php' method='post'>
    Post ID to Edit: <br>
    <input type='text' name='id' size='63.5' /><br>
    Title: <br>
    <input type='text' name='title' size='63.5' /><br>
    Body: <br>
    <textarea name='content' rows='15' cols='50'></textarea>
    <br>
    <input type='submit' name='submit' value='Edit Post' />
    </p>
    <?php
    }
    ?>
    </div>
    
    </form>

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
  3. #2
    Bioshox is offline Programmer
    Join Date
    Oct 2009
    Location
    Manchester, UK
    Posts
    196
    Rep Power
    10

    Re: Selecting Via Combo Box

    Anybody any idea's about this?!

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Problem while selecting tag
    By thatsme in forum HTML Programming
    Replies: 1
    Last Post: 02-14-2011, 08:58 AM
  2. Selecting Row from Listview
    By Darkco in forum C# Programming
    Replies: 1
    Last Post: 01-12-2010, 12:57 PM
  3. Selecting Orders Before Some Date
    By chili5 in forum Database & Database Programming
    Replies: 3
    Last Post: 08-21-2009, 04:33 PM
  4. Selecting something that is not there
    By Lokantis in forum Database & Database Programming
    Replies: 2
    Last Post: 01-31-2009, 04:54 AM
  5. Trouble selecting value from DBLookupComboBox
    By georgiegal in forum Pascal and Delphi
    Replies: 2
    Last Post: 07-28-2008, 04:36 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts