示例#1
0
                break;
        }
        print "</strong></p>";
    }
    return $thumbnail;
}
require "admin_login.php";
include "dbinfo.php";
if (isset($_POST['submit'])) {
    $id = $_POST['id'];
    $name = $_POST['name'];
    $code = $_POST['code'];
    $price = $_POST['price'];
    $description = $_POST['description'];
    $picture = checkPicture();
    $thumbnail = checkThumbnail();
    $sql = "UPDATE product SET\nPicture='{$picture}',\nThumbnail='{$thumbnail}',\nName='{$name}',\nCode='{$code}',\nPrice='{$price}',\nDescription='{$description}'\nwhere id='{$id}'";
    $result = mysqli_query($conn, $sql) or die(mysqli_error($conn));
    print "<br/><br/><br/><br/><br/><br/>";
    print "<html><head><title>Update Results</title></head><body>";
    include "header.php";
    print <<<HERE
<h1>The new record looks like this: </h1>
Picture: <img src='images/slide/{$picture}' /><br/>
Slide: <img src='images/thumbnail/{$thumbnail}' />
<p><strong>Name:</strong>{$name}</p>
<p><strong>Code:</strong>{$code}</p>
<p><strong>Price:</strong>{$price}</p>
<p><strong>Description:</strong>{$description}</p>
HERE;
}
示例#2
0
function addData($name, $code, $price, $description)
{
    //print "Ready to add data";
    include "dbinfo.php";
    $picture = checkPicture();
    $thumbnail = checkThumbnail();
    $sql = "INSERT INTO product VALUES (null,'{$picture}','{$thumbnail}','{$name}','{$code}','{$price}','{$description}')";
    $result = mysqli_query($conn, $sql) or die(mysqli_error($conn));
    if (true === $result) {
        printf("no error: %s\n", mysqli_error($conn));
    } else {
        echo 'done.';
    }
    include "header.php";
    print <<<HERE
\t<h1>The following has been added:</h1>
\t<ul>
\t<li>Picture: <img src='images/slide/{$picture}' /></li>
\t<li>Slide: <img src='images/thumbnail/{$thumbnail}' /></li>
\t<li>Name: {$name}</li>
\t<li>Code: {$code}</li>
\t<li>Price: {$price}</li>
\t<li>Description: {$description}</li>
\t</ul>
HERE;
}