Jump to content

lost trying to make update row form :(


beam1985

Recommended Posts

hey everybody,

 

I am in way out of my league working on a CRUD app for class, and i am STUCK on this update form. im getting an unexpected else error, any suggestions? THANK YOU!!!

 

<?php

$host="localhost"; // Host name
$username="name"; // Mysql username
$password="pass"; // Mysql password

mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("ragra");

$title = $_POST['title'];
  
$tagline = $_POST['tagline'];
    
$content = $_POST['content'];
   
$author = $_POST['author'];
   
$category = $_POST['category'];


if (!isset($_POST['update'])){

$sql="SELECT * FROM ragra";
$result=mysql_query($sql);
$count=mysql_num_rows($result);
  


?>

<table>
<tr>
	<td><img src="comcarblog.jpg"></td>
</tr>
</table>

<table>
<tr>
	<td><a href="main.php" alt="Home"><img src="home.jpg"></a></td>
	<td><a href="" alt=""><img src="blank.jpg"></a></td>
	<td><a href="add.php" alt="Admin"><img src="admin.jpg"></a></td>
</tr>
</table>

<form name="form1" method="post">

<table width="600" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
	<tr>
		<td colspan="4" bgcolor="#41a1f3">
			You're about to delete some posts!
		</td>
	</tr>
</table>

<table width="600" border="0" cellspacing="1" cellpadding="0">
	<tr>
		<td align="center" bgcolor="#f3d841">Number</td>
		<td align="center" bgcolor="#f3d841">Id</td>
		<td align="center" bgcolor="#f3d841">Title</td>
		<td align="center" bgcolor="#f3d841">Tagline</td>
		<td align="center" bgcolor="#f3d841">Author</td>
	</tr>
	<?php
	while($rows=mysql_fetch_array($result)) {
	?>
	<tr>
		<td align="center" bgcolor="#FFFFFF">
			<input type="checkbox" name="checkbox[]" value="<?php echo $rows['id']; ?>" />
			<input type="hidden" value="<?php echo $rows['id']; ?>" name="itemid[]" />
		</td>
		<td bgcolor="#FFFFFF">
			<?php
				echo $rows['id'];
			?>
		</td>
		<td bgcolor="#FFFFFF">
		<?php
			echo $rows['title'];
		?>
		</td>
		<td bgcolor="#FFFFFF">
		<?php
			echo $rows['tagline'];
		?>
		</td>
		<td bgcolor="#FFFFFF">
		<?php
			echo $rows['author'];
		?>
		</td>
	</tr>
	<?php

	}
	?>
	<tr>
		<td colspan="5" align="center" bgcolor="#FFFFFF">
			<input name="delete" type="submit" id="update" value="Update These">
		</td>
	</tr>
</table>

</form>

<?php

} else {

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

	while(list($key,$value) = each($_POST['checkbox'])) { 

			$updates = join(',', $_POST['checkbox'] );
			$query = mysql_query("SELECT FROM article WHERE id IN ($updates) ");
		}				


if (!isset($_POST['nupdate'])){


?>

<table>
<tr>
	<td><img src="comcarblog.jpg"></td>
</tr>
</table>

<table>
<tr>
	<td><a href="main.php" alt="Home"><img src="home.jpg"></a></td>
	<td><a href="" alt=""><img src="blank.jpg"></a></td>
	<td><a href="add.php" alt="Admin"><img src="admin.jpg"></a></td>
</tr>
</table>

<form name="form2" method="post">

<table width="600" border="0" cellpadding="3" cellspacing="1" bgcolor="#CCCCCC">
	<tr>
		<td colspan="4" bgcolor="#41a1f3">
			You're about to delete some posts!
		</td>
	</tr>
</table>

<table width="600" border="0" cellspacing="1" cellpadding="0">
	<tr>
		<td align="center" bgcolor="#f3d841">Number</td>
		<td align="center" bgcolor="#f3d841">Id</td>
		<td align="center" bgcolor="#f3d841">Title</td>
		<td align="center" bgcolor="#f3d841">Tagline</td>
		<td align="center" bgcolor="#f3d841">Author</td>
	</tr>
</table>
	<?php
	while($rows=mysql_fetch_array($result)) {
	?>
<table>
	<tr>
		<td><font face="arial,helvetica" size="4px" color="#41a1f3">Title:</font>
		</td>
		<td><input type="text" name="title" value="Whats the title" size=60>
		</td>
	</tr>
<br>
	<tr>
		<td><font face="arial,helvetica" size="4px" color="#617fa0">Tagline:</font>
		</td>
		<td><input type="text" name="tagline" value="write something witty" size=60>
		</td>
	</tr>
<br>
	<tr>
		<td valign="top"><font face="arial,helvetica" size="4px" color="#617fa0">Content:</font>
		</td>

		<td><textarea name="content" rows="15" cols="45">This better be good!</textarea>
		</td>
	</tr>
<br>
	<tr>
		<td><font face="arial,helvetica" size="4px" color="#617fa0">Author:</font>
		</td>

		<td><?php echo "<select name='author'>
"; ?><option value="Bob">Bob<option value="Walker">Walker<option value="Somebody Else">Somebody Else</select>
		</td>
	</tr>
<br>
	<tr>
		<td><font face="arial,helvetica" size="4px" color="#617fa0">Category:</font>
		</td>
		<td><input type="text" name="category" value="whats the category" size=60>
		</td>
	</tr>
<br>
	<tr>
		<td><input type="submit" name="nsubmit" value="submit">
		</td> 
	</tr>
</table>
</form>
	<?php


}else{
if(isset($_POST['nupdate'])){

	while(list($key,$value) = each($_POST['ncheckbox'])) { 

			$nupdates = join(',', $_POST['ncheckbox'] );
			$query = mysql_query("UPDATE INTO article WHERE id IN ($nupdates) ") 
             VALUES (NULL, '$title', '$tagline', '$content', now( ) , '$author', '$category')";
}else{
?>
<table>
	<tr>
		<td><img src="comcarblog.jpg">
		</td>
	</tr>
</table>
<table>
	<tr>
		<td><a href="main.php" alt="Home"><img src="home.jpg"></a>
		</td>
		<td><a href="" alt=""><img src="blank.jpg"></a>
		</td>
		<td><a href="add.php" alt="Admin"><img src="admin.jpg"></a>
		</td>
	</tr>
</table>
<table>
	<tr>
		<td><p><font face="arial,helvetica" size="6px" color="#41a1f3">You have Sucsesfully added a post!</font></p>
		<p><font face="arial,helvetica" size="6px" color="#617fa0"><a href="main.php" alt="">View your post on the mainpage here</a></font></p>
		</td>
	</tr>
</table>
<?php



}
}

mysql_close();
?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

  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.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.