Jump to content

Selecting Via Combo Box

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
Bioshox

Bioshox

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
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!

<?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

<?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
Bioshox

Bioshox

    Programming Professional

  • Members
  • PipPipPipPipPip
  • 207 posts
Anybody any idea's about this?!