Animal777,
Your posts are greatly appreciated, thank you. I looked at your gallery and see how you're wrapping the images. I'll get to that when I can, but for now I am obsessed with this "marathon dev cycle" on what should be a simple, simple beginner lesson. I'm humble ...beyond humble, my name is mud.
Below is my code (one version anyway) but it does NOT produce... and I have tried EVERY <html><?php ?></html> combination, both logical and not logical. Orginally I had expected the heredoc syntax Mayank introduced in his tutorial to output the html with the //Final Output section as it does with the viewgallery.php for example. But that doesn't produce for me either.
Mayank,
I also appreciate your screen grabs, though they teach nor prove nothing. However, to show the WHOLE DOCUMENT with html and all, that DOES return the page you speak of, now THAT would be studying material.
PHP Code:
<html>
<head>
<title>Admin Page</title>
<link rel="stylesheet" href="css/ckstyle.css" />
</head>
<body>
<?php
include("config.inc.php");
dbConnect("assets");
include 'design.inc.php';
if( empty($_POST['action']) )
{
// Build the Category List
$result = mysql_query( "SELECT category_id,category_name FROM gallery_category" );
while( $row = mysql_fetch_array( $result ) )
{
$category_list .=<<<__HTML_END
<option value="$row[0]">$row[1]</option>\n
__HTML_END;
}
mysql_free_result( $result );
$category_list = '<select name="categoryid">'. $category_list .'</select>';
?>
<form name="add_category" action="admin.php" method="post">
<b>Add Category:</b><br />
Name: <input type="text" name="cname" />
<input type="submit" value="add" name="action" />
</form>
<br /><br />
<form name="edit_category" action="admin.php" method="post">
<b>Edit Category:</b><br />
New Name: <input type="text" name="cname" />
<?php echo($category_list); ?>
<input type="submit" value="edit" name="action" />
</form>
<br /><br />
<form name="delete_category" action="admin.php" method="post">
<b>Delete Category:</b><br />
<?php echo($category_list); ?>
<input type="submit" value="delete" name="action" />
</form>
<?php
}
else
{
if( strcasecmp($_POST['action'], "add" )==0 && !empty( $_POST['cname'] ) )
{
add_category($_POST['cname']);
}
else if( strcasecmp($_POST['action'], "edit" )==0 && !empty( $_POST['cname'] ) && !empty( $_POST['categoryid'] ) )
{
edit_category($_POST['categoryid'], $_POST['cname']);
}
else if( strcasecmp($_POST['action'], "delete" )==0 && !empty( $_POST['categoryid'] ) )
{
delete_category($_POST['categoryid']);
}
else
{
echo("Action not understood" ); exit;
}
echo("Process completed!" );
}
// the functions here
function edit_category($category_id, $new_name)
{
mysql_query("
UPDATE gallery_category SET
category_name = '" . addslashes($new_name) . "'
WHERE category_id = '" . addslashes($category_id) . "'" );
}
function add_category($category_name)
{
mysql_query("
INSERT INTO gallery_category (
category_name
) VALUES (
'" . addslashes($category_name) . "'
)" );
}
function delete_category($category_id)
{
global $images_dir;
$result = mysql_query("
SELECT photo_filename
FROM gallery_photos
WHERE photo_category='" . addslashes($category_id) . "'" );
while ($row = @mysql_fetch_array($result)) {
unlink($images_dir . '/' . $row[0]);
}
mysql_query("
DELETE FROM gallery_photos
WHERE photo_category='" . addslashes($category_id) . "'" );
mysql_query("
DELETE FROM gallery_category
WHERE category_id='" . addslashes($category_id) . "'" );
}
// if I were using the final output (heredoc syntax) it would go here
?>
</body>
</html>
Bookmarks