Jump to content

Editing through row id


max_power

Recommended Posts

Hi,

 

First things first, I am creating a current events page, where as an admin I can go in there and add more events, edit them and delete them. Now my problem is in the editting part of it. What I want to do is first view all the events and edit them. What I have got is, as each event is displayed in a row I have attached an edit button to each row, so what I want to do is, when I click a particular edit button on a particular row, it only edits that row's events, I am having trouble with my SQL query, as right now when I click the edit button I can edit all the events.

 

My sql query along with the form code is:

 

$sql = "SELECT id,author,last_updated,category,event,summary FROM events WHERE `id` = '".$row['id']."'";
$rs = @mysql_query($sql,$conn);
if (!$rs)
 {exit("Error in SQL");}

while ($row = mysql_fetch_array($rs))
{
{
  
  ?>
  <tr>
	<td valign="top">
	<table>
				<table border="0" rules="none" cellpadding="1" cellspacing="2" bgcolor="lightgrey" align="center" width="760" height="100">
				<tr>
					<td colspan="30" bgcolor="#696969" valign="middle"  height="35" align="center">
						<font size="4"><b>Current Events</b></font>
					</td>
				</tr>
  <td><form name="EditDetails" method="post" form action="manage-viewevents.php">
<input type="submit" value="Edit">
<input type="hidden" name="SaveChanges" value="1">
<input type="hidden" name="EditDetails" value="0">
<tr height="50">
					<td>
						Event ID:
					</td>

					<td><input type="number" name="id" value="<? echo $row['id']; ?>"size="10"></td>

				</tr>
				<tr height="50">
					<td>
						Author:
					</td>

					<td><input type="text" name="author" value="<? echo $row['author']; ?>"size="20"></td>

				</tr>
				<tr height="50">
					<td>
						Last updated:
					</td>

					<td><input type="text" name="last_updated" value="<? echo $row['last_updated']; ?>"size="20"></td>

				</tr>
				<tr>
					<td width="130">
						Category:
					</td>

					<td>
						<select name="category" value="<? echo $row['category']; ?>">
						<option value="category1">category1</option>
						<option value="category2">category2</option>
						<option value="category3">category3</option>
						<option value="category4">category4</option>
						</select>

					</td>
				</tr>
				<tr height="50">
					<td>
						Event:
					</td>

					<td>
						<textarea name="event" value="<? echo $row['event']; ?>" rows="12" cols="25"></textarea>
					</td>

				</tr>	
				</tr>
				<tr height="50">
					<td>
						Summary:
					</td>

					<td>
						<textarea name="summary" value="<? echo $row['summary']; ?>" rows="5" cols="25"></textarea>
					</td><br><br>
					</tr>
					<tr> 
      	   <td width="150"></td>
      	   <td width="200">
	   <img src="images/bold.gif" alt="Bold" border="0" onClick="addsmiley(\'<b>Your Text Here</b>\')" style="cursor: pointer;">
	   <img src="images/italic.gif" alt="Italic" border="0" onClick="addsmiley(\'<i>Your Text Here</i>\')" style="cursor: pointer;">
	   <img src="images/underline.gif" alt="Underline" border="0" onClick="addsmiley(\'<u>Your Text Here</u>\')" style="cursor: pointer;">
	   <img src="images/link.gif" alt="Insert Link" border="0" onClick="addsmiley(\'<a href="http://www.somesite.com" target="_blank">Your Link</a>\')" style="cursor: pointer;">
	   <img src="images/newline.gif" alt="New Line" border="0" onClick="addsmiley(\'<br>\')" style="cursor: pointer;">
	   </td>
    	   </tr>
		<tr> 
      	   <td> </td>
      	   <td><div align="right">
           <input type="submit" name="submit" value="SaveChanges">
           </div></td></tr></form></table></td></tr>
</form><td></tr><?
  }

}
@mysql_close($conn);
echo "</table></td></tr>";

 

But this comes up with nothing all. Just a note, I havent set up the update query yet as I have got it working, just waiting for this particular part to work and I am set.

 

Any ideas?

 

Thanks.

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.