Jump to content

cms issues =(


green917

Recommended Posts

I'm attempting to create a very basic cms, wherein an enduser can change multiple pieces of data within the database from a single page. I have 4 basic tables that need to be changed. 1 of them is a little more advanced than the others with the ability to delete items from the database rather than simply the ability to update the info. The first is a bio section and the second is a table of recipes with the delete function built into it. I finally got the delete function to work but am unclear as to how to integrate the update scripts for the other tables into the same php script (or if that's even the correct way to do it.) Any help would be greatly appreciated.

 

green

 

delete function

<?php


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

include 'config.php';
   
$id = $_POST['hidden_id'];

$del = 'DELETE FROM recipes WHERE id="$id"';
$result = mysql_query($del,$link);

echo 'Recipe has been deleted';
echo '<br /><br /><a href="/hlgcon.php">Back to database contents</a>';
}
else{

include 'config.php';

$sql = "SELECT id,title FROM recipes ORDER BY title";
$rresult = mysql_query($sql,$link);

?>

 

update function(once again, I'm unsure how to combine these 2 scripts into 1 that runs the whole page with less database calls, etc.)

<?php

if ($_POST['bio_update']) {

header('Location: http://.php'); //header location removed

}
else{

include 'config.php';

$bio = "SELECT id, bio_text FROM bio ORDER BY id";
$bresult = mysql_query($bio,$link);

mysql_close($link);
}
?>

 

html & php display loops

<body>

<form name="bioitem" action="<?php echo $PHP_SELF ?>" method="post">
<table width="650" border="1" cellpadding="2" cellspacing="1">
<tr><th width="100%" colspan="4" style="background-color:#cddf77;"><center>Bio</center></th></tr>
<tr><th>id</th><th>bio text</th><th>update?</th></tr>
<?php 
while ($row = mysql_fetch_array($bresult)) {
echo '<tr><td>'.$row['id'].'</td>';
echo '<td>'.$row['bio_text'].'</td>';
echo '<td><center><input type="submit" name="bio_update" value="update" /></center></td></tr>';
}
?>
</table>


<form name="recitem" action="<?php echo $PHP_SELF ?>" method="post">
<table width="650" border="1" cellpadding="2" cellspacing="1">
<tr><th width="100%" colspan="4" style="background-color:#cddf77;"><center>Recipes</center></th></tr>
<tr><th>id</th><th>title</th><th>delete?</th></tr>

<?php
while($row = mysql_fetch_array($rresult)) {
echo '<tr><td>'.$row['id'].'</td>';
echo '<td>'.$row['title'].'</td>';
echo '<td><center><input type="hidden" name="recipe_id" value="' . $row['id'] . '" /><input type="submit" name="rec_delete" value="delete" /></center></td>';
echo '</tr>';
}
echo '<TR><td width="100%" height="30" valign="center" colspan="4"><center><a href="/hlgup.php"><img src="recipebtn.gif" border="0"></a></center></td></TR>'; 

?>	
</table>
</form>

</body>

 

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.