Hi again ! i am having an issue with updating database. When i update any price of a title it remove the title from database please can somebody help me what i am missing in my code. here it is:
Code: [Select]<?php ob_start() ; ?>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=iso-8859-1" />
<meta name="description" content="Your description goes here..." />
<meta name="keywords" content="your,keywords,goes,here" />
<meta name="author" content="Raza / Webbuilderstudio.com" />
<link rel="stylesheet" type="text/css" href="../style.css" title="1024px style" media="screen,projection" />
<title>CSCS Products</title>
</head>
<body>
<?php include_once("include_header.php");
include('db_fns.php');
?>
<h3>Your Administration Center</h3>
<?php
// Connects to your Database
db_connect();
//checks cookies to make sure they are logged in
if(isset($_COOKIE['ID_my_site']))
{
$username = $_COOKIE['ID_my_site'];
$pass = $_COOKIE['Key_my_site'];
$check = mysql_query("SELECT * FROM users WHERE username = '$username'")or die(mysql_error());
while($info = mysql_fetch_array( $check ))
{
//if the cookie has the wrong password, they are taken to the login page
if ($pass != $info['password'])
{ header("Location: login.php");
}
//otherwise they are shown the admin area
else
{ ?>
<?php
//If cmd has not been initialized
if(!isset($cmd))
{
//displaying all products on the page with title and price
$result = mysql_query("select * from booklist order by id");
echo'<center><h3>Product List</h3></center>';
//run the while loop that grabs all the news scripts
while($r=mysql_fetch_array($result))
{
$title=$r["title"];// title
$id=$r["id"];// id
echo "$id : $title - <a href='manager.php?cmd=edit&id=$id'>Edit</a>";
echo "
";
}
}
?>
<?php
if($_GET["cmd"]=="edit" || $_POST["cmd"]=="edit")
{
if (!isset($_POST["submit"]))
{
$id = $_GET["id"];
$sql = "SELECT * FROM booklist WHERE id=$id";
$result = mysql_query($sql);
$myrow = mysql_fetch_array($result);
?>
<form action="manager.php" method="post">
<input type="hidden" name="id" value="<?php echo $myrow["id"] ?>">
<h3>Please Enter New Price For the Unit:</h3>
<b>Title:</b><?php echo $myrow["title"] ?><br />
<b>Message:</b><? echo $myrow["body"] ?><br />
<b>Enter New Price:<b/><INPUT TYPE="TEXT" NAME="price" VALUE="<?php echo $myrow["price"] ?>" SIZE=4>
<input type="hidden" name="cmd" value="edit">
<div style="margin:10px 0 0 120px;"><input type="submit" name="submit" value="submit"></div>
</form>
<? } ?>
<?php
if ($_POST["submit"])
{
$title = $_POST["title"];
$body = $_POST["body"];
$price = $_POST["price"];
// Here i am having issue when i update it remove the title but update the price
$sql = "UPDATE booklist SET title='$title',body='$body',price='$price' WHERE id=$id";
$result = mysql_query($sql);
echo "<br /><center><font color="red">The Product Price Has been Updated. </font></center>";
}
}
echo'<center><h3>Orders List</h3></center>';
?>
<div style="border: 2px solid #FFFFFF; width: 700px; height: 260px; overflow: auto;">
<?php $orders = find_orders();
foreach($orders as $order): ?>
<div class="order">
<h3>Order ID: ( <?php echo $order['id']; ?> ) Dated: <?php echo $order['created_at']; ?></h3>
<b>Buyer: <?php echo $order['firstname']; ?> <?php echo $order['lastname']; ?></b> <br />
Amount Received: £<?php echo number_format($order['amount'], 2); ?> <br />
Email Address: <?php echo $order['email']; ?><br />
Payment Status: <?php echo $order['status']; ?><br />
Paypal Trans ID: <?php echo $order['paypal_trans_id']; ?><br />
Address: <?php echo $order['address']; ?> <?php echo $order['city']; ?> <?php echo $order['state']; ?> <?php echo $order['zip_code']; ?> <?php echo $order['country']; ?>
</div>
<?php $items = find_items($order['id']); ?>
<?php foreach($items as $item): ?>
[Product X Quantity]: <?php echo $item['title']; ?> X <?php echo $item['qty']; ?>
<?php endforeach; ?>
<hr/>
<?php endforeach; ?>
</div>
<?php
}
}
}
else
//if the cookie does not exist, they are taken to the login screen
{
header("Location: login.php");
}
?>
<?php include_once("sidebar.php");?>
<?php include_once("include_footer.php");?>
</div>
</body>
</html>
<?php ob_flush() ; ?>
Thanks for the help Team
simple php table loop
Hi all,I've the following code <?php // Create category options $query = "SELECT * FROM categories ORDER BY category ASC"; $result = mysql_query
help me, how to find text on an external html site using PHP
Would anyone know how to search an external html file for a work or phrase ?I was thinking something like this --I use script cURL...Code: <?phpif (isset($_POST['submitted'])) { $xurl_1 =
Adding Different Numbers From MySQL
Basically I have a mysql database with a couple prices as the following:9.999.999.9949.9924.5024.50How can I add these numbers and display the total from a mysql database?
How To Make More Than One Redirection with PHP on the same page?
Hey im trying to do a direction page where it open differently link direction pages every time somebody enter it.. like this for example any good hint on how to do this?<?phpheader(
multipart emiail forms
Hi All, I am new to the boards and I've been working on a form (which is rather massive, imo) and i've been looking online at other peoples php examples for multipart emails. The code i am using /
mysql_query returning boolean instead of mysql ressource
Hi,I seem to have a weird issue with the php command mysql_query. I pass 2 arguments the query in a string format (SQL is working properly) and a database ressource which is also good. The problem is
Allowing ' and "
Hello everyone,I am creating a form where users submit information to go into a database. I want the users to be allowed to use both ' and " in their messages, but the problem is when I try to
How to return to a previous page after running a PHP script
I'm having a bit of a melt down here because I think this should be really easy but can't work it out...!My page lists the records in my database and next to each record is a 'Delete' button. What I
mysql query with single quotes in a variable
$sitedetails = "INSERT INTO vars (address, sitename, description, ownername, theme) VALUES ('$url', '$sitename', '$description', '$ownername', '$theme') ";mysql_query($sitedetails) or
path to include folder
Hi everyone,When I'm testing locally, I have to add the name of the site folder as part of the path name when I'm including files, eg.include $_SERVER['DOCUMENT_ROOT'] .