Jump to content

Recommended Posts

<?php include('dblogin.php'); ?>

 

<?php

$mysql="SELECT * FROM products";

 

$result=mysql_query($mysql);

if ($_GET["add"]!="")

{

$_SESSION["cost"]=($_SESSION["cost"]+$price["price"] );

$_SESSION["products"]=$_SESSION["products"]+1;

}

 

 

$result=mysql_query($sql);

 

?>

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

 

<!-- Link to stylesheet stylesheet.css within the same folder as the HTML page -->

<link rel="StyleSheet" href="inc/css/stylesheet.css" type="text/css">

 

 

 

 

<html>

<head>

</head>

<body>

 

<div id="container"> <!-- Start of the Container DIV -->

<div class="animatedtabs">

<ul>

<li class="selected" ><a href="Shop.php" title="Shop"><span>Shop</span></a></li>

<li><a href="index.php" title="Home"><span>Home</span></a></li>

<li><a href="new.php" title="New"><span>New</span></a></li>

<li><a href="Categories.php" title="Categories"><span>Catogires</span></a></li>

<li><a href="safty.php" title="Tools"><span>Safty Center </span></a></li>

</ul>

</div>

 

 

 

 

<div id="HEADER">

<h1>swapit.com</h1>

<div class="Visual">

</div>

<div id="CONTENT">

 

<?php

$connect = mysql_connect('mysql5.000webhost.com', 'a2534943_swapit', '11gordon') or die(mysql_error())

while ($row = mysql_fetch_array(db.mySQL,$result, MYSQL_BOTH))

{

echo '<div id="products">';

echo '<form name="cart" method="post" action="Shop.php?add=true">';

echo '<table><tr>';

    echo '<td><h2>'.$row["title"].'</h2><p>'.$row["description"].'</p></td><td>£'.$row["price"].'</td><td><input type="submit" name="submit" value=" Add to Cart"></td>';

echo '</table></tr>';

echo '</form>';

echo '</div>';

}

?>

 

<?php

echo '<div id="cart">';

echo '<form name="cart" method="post" action="shop-cart.php" >';

echo '<p class="center">SHOPPING CART</p>';

echo '<p>No of Items: <strong>'.$_SESSION["products"].'</strong><br/>Total Price: <strong>£'. $_SESSION["cost"].'</strong></p>';

echo '<p class="button"><input type="submit" name="Submit" value=" Check Out >> "shop-cart.php""></p>';

echo '</form>';

echo '</div>';

 

?>

 

 

 

 

 

</div>

 

</div>

 

 

 

<?php include('dblogin.php');

if ($_SESSION["userid"]=="")

{

header ('Location: login.php');

}

 

if ($_SESSION["userid"]!="")

{

echo '<p><a href="logout.php">Logout</a></p>';

}

 

 

 

?>

 

 

 

<!-- Do not edit above this line -->

 

<h2>Products...</h2>

<div id="TEXT">

 

<div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr><td><h2>Hot Fuzz - Limited Edition</h2>

<p>1 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>

</td></table></tr><input type="hidden" name="id" value="1"><input type=$price name="price" value="19.99"><td><input type="submit" name="submit" value=" Add to Cart"></form></div>

<div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr><td><h2>10000 BC</h2>

<p>2 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>

</td></table></tr><input type="hidden" name="id" value="2">

<input type="hidden" name="price" value="24.99"></form></div><div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>

<td><h2>The Matrix</h2><p>3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>

</td></table></tr><input type="hidden" name="id" value="3"><input type=$price name="price" value="9.99"><input type="submit" name="submit" value=" Add to Cart"></form></div>

<div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>

<td><h2>Empire Records</h2><p>4 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>

<td></td></table></tr><input type="hidden" name="id" value="4"> <input type=$price name="price" value="14.99"><<input type="submit" name="submit" value=" Add to Cart"></form></div>

<div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>

<td><h2>The Transporter</h2><p>5 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p><

</td></table></tr><input type="hidden" name="id" value="5"><input type=$price name="price" value="12.49"><input type="submit" name="submit" value=" Add to Cart"></form></div>

echo '<input type="hidden" name="id" value="'.$row["product_id"].'">';

 

 

</div>

 

<!-- Do not edit below this line -->

 

</div>

 

<div id="FOOTER">

<p>swapit.com </p>

<p>This website is a university assignment demonstration not a real shop!</p>

</div>

 

</body>

</html>

 

<!-- CO1505 Assignment 1 Project Example -->

<!-- www.000webhost.com Analytics Code -->

<script type="text/javascript">

var websiteID='http://swapit.comoj.com';

</script>

<script type="text/javascript" src="http://analytics.hosting24.com/do.php"></script>

<noscript>

<a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/do.php?websiteID=chici.org" alt="web hosting" /></a>

</noscript>

<!-- End Of Code -->

 

 

<div class="shop">

<li>

 

<!-- the shop-->

 

</div> <!-- End of the Container DIV -->

 

</body>

 

</html>

 

 

Warning: Wrong parameter count for mysql_fetch_array() in /home/a2534943/public_html/Shop.php on line 53#

is the errort i am geting

 

 

 

 

page liknk is http://swapit.comoj.com

Link to comment
https://forums.phpfreaks.com/topic/143250-i-dont-understan-what-i-am-dowing-wrong/
Share on other sites

Please use the code tags next time ;)

 

Why do you have

$connect = mysql_connect('host', '*****', '*****') or die(mysql_error())
// ERROR BELOW, because of look at line above...
          while ($row = mysql_fetch_array(db.mySQL,$result, MYSQL_BOTH))

Then, at the top:

<?php include('dblogin.php'); ?>

<?php
   $mysql="SELECT * FROM products";

   $result=mysql_query($mysql);

 

 

Connecting AFTER you try to run the query?

 

 

Also, for future debugging its easier to have an 'or die(mysql_error())' statement on the end.

$result=mysql_query($mysql) or die(mysql_error());

 

(removed your user/pass in connect statement)

<?php

$connect = mysql_connect('mysql5.000webhost.com', 'a2534943_swapit', '11gordon') or die(mysql_error());

while ($row = mysql_fetch_array (db.mySQL,$result, MYSQL_BOTH))

{

echo '<div id="products">';

echo '<form name="cart" method="post" action="Shop.php?add=true">';

echo '<table><tr>';

    echo '<td><h2>'.$row["title"].'</h2><p>'.$row["description"].'</p></td><td>£'.$row["price"].'</td><td><input type="submit" name="submit" value=" Add to Cart"></td>';

echo '</table></tr>';

echo '</form>';

echo '</div>';

}

?>

 

 

THERE SOMTHING WORNG HERE AND SOME WERE ALSE

still a promblem

 

Warning: Wrong parameter count for mysql_fetch_array() in /home/a2534943/public_html/Shop.php on line 54

    	<?php

 		while ($row = mysql_fetch_array (db.mySQL,$result, MYSQL_BOTH))
		{
			echo '<div id="products">';
			echo '<form name="cart" method="post" action="Shop.php?add=true">';
			echo '<table><tr>';
	    	echo '<td><h2>'.$row["title"].'</h2><p>'.$row["description"].'</p></td><td>£'.$row["price"].'</td><td><input type="submit" name="submit" value=" Add to Cart"></td>';
			echo '</table></tr>';
			echo '</form>';
			echo '</div>';
		}

See my above post.

 

I just noticed you're missing a semicolon on the $connect line.

 

Anyways, you need to move the connect statement above the query statement, and add in the or die() part. It'll tell you all the errors when try to run the query.

--

Your new post, change:

mysql_fetch_array (db.mySQL,$result, MYSQL_BOTH)

to

mysql_fetch_array($result)

 

Look at parameters you should pass to the function, you won't need "db.mySQL"

There were bugs all above the loop so I have rewritten it and is as follows:

<?php include('dblogin.php'); 
$host='';
$user='';
$pass='';
$database='';

   $connect = mysql_connect($host, $user, $pass) or die(mysql_error())
   mysql_select_db($database) or die(mysql_error()."Could not select database");

   $mysql="SELECT * FROM `products`";

   $result=mysql_query($mysql);
   if ($_GET["add"]!="")
   {
         $_SESSION["cost"]=($_SESSION["cost"]+$price["price"] );
         $_SESSION["products"]=$_SESSION["products"]+1;
   }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!-- Link to stylesheet stylesheet.css within the same folder as the HTML page -->
<link rel="StyleSheet" href="inc/css/stylesheet.css" type="text/css">
<html>
<head>
</head>
<body>
<div id="container"> <!-- Start of the Container DIV -->
<div class="animatedtabs">
<ul>
<li class="selected" ><a href="Shop.php" title="Shop"><span>Shop</span></a></li>
<li><a href="index.php" title="Home"><span>Home</span></a></li>
<li><a href="new.php" title="New"><span>New</span></a></li>
<li><a href="Categories.php" title="Categories"><span>Catogires</span></a></li>
<li><a href="safty.php" title="Tools"><span>Safty Center </span></a></li>
</ul>
</div>
<div id="HEADER">
   <h1>swapit.com</h1>
   <div class="Visual">
   </div>
<div id="CONTENT">
    <?php
          while ($row = mysql_fetch_array($result))
         {
            echo '<div id="products">';
            echo '<form name="cart" method="post" action="Shop.php?add=true">';
            echo '<table><tr>';
             echo '<td><h2>'.$row["title"].'</h2><p>'.$row["description"].'</p></td><td>£'.$row["price"].'</td><td><input type="submit" name="submit" value=" Add to Cart"></td>';
            echo '</table></tr>';
            echo '</form>';
            echo '</div>';
         }
       echo '<div id="cart">';
       echo '<form name="cart" method="post" action="shop-cart.php" >';
       echo '<p class="center">SHOPPING CART</p>';
       echo '<p>No of Items: <strong>'.$_SESSION["products"].'</strong><br/>Total Price: <strong>£'. $_SESSION["cost"].'</strong></p>';
       echo '<p class="button"><input type="submit" name="Submit" value=" Check Out >> "shop-cart.php""></p>';
       echo '</form>';
       echo '</div>';
    ?>
   </div>
</div>
<?php include('dblogin.php');
   if ($_SESSION["userid"]=="")
   {
      header ('Location: login.php');
   }

      if ($_SESSION["userid"]!="")
      {
         echo '<p><a href="logout.php">Logout</a></p>';
      }
   ?>

<!-- Do not edit above this line -->

<h2>Products...</h2>
   <div id="TEXT">

   <div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr><td><h2>Hot Fuzz - Limited Edition</h2>
   <p>1 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
   </td></table></tr><input type="hidden" name="id" value="1"><input type=$price name="price" value="19.99"><td><input type="submit" name="submit" value=" Add to Cart"></form></div>
   <div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr><td><h2>10000 BC</h2>
   <p>2 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
   </td></table></tr><input type="hidden" name="id" value="2">
   <input type="hidden" name="price" value="24.99"></form></div><div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>
   <td><h2>The Matrix</h2><p>3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
   </td></table></tr><input type="hidden" name="id" value="3"><input type=$price name="price" value="9.99"><input type="submit" name="submit" value=" Add to Cart"></form></div>
   <div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>
   <td><h2>Empire Records</h2><p>4 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
   <td></td></table></tr><input type="hidden" name="id" value="4"> <input type=$price name="price" value="14.99"><<input type="submit" name="submit" value=" Add to Cart"></form></div>
   <div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>
   <td><h2>The Transporter</h2><p>5 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p><
   </td></table></tr><input type="hidden" name="id" value="5"><input type=$price name="price" value="12.49"><input type="submit" name="submit" value=" Add to Cart"></form></div>
   echo '<input type="hidden" name="id" value="'.$row["product_id"].'">';


   </div>

<!-- Do not edit below this line -->

</div>

<div id="FOOTER">
<p>swapit.com </p>
<p>This website is a university assignment demonstration not a real shop!</p>
</div>

</body>
</html>

<!-- CO1505 Assignment 1 Project Example -->
<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript">
var websiteID='http://swapit.comoj.com';
</script>
<script type="text/javascript" src="http://analytics.hosting24.com/do.php"></script>
<noscript>
<a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/do.php?websiteID=chici.org" alt="web hosting" /></a>
</noscript>
<!-- End Of Code -->


<div class="shop">
<li>

<!-- the shop-->

</div> <!-- End of the Container DIV -->
</body>
</html>

Website Under Review I HAVE TO WAIT FOR 4 HOURS FOR THE UNI SERVER TO CHECK MY PAGE FFS

<?php include('dblogin.php'); ?>

<?php
$mysql="SELECT * FROM products";

$result=mysql_query($mysql);
if ($_GET["add"]!="")
{
		$_SESSION["cost"]=($_SESSION["cost"]+$price["price"] );
		$_SESSION["products"]=$_SESSION["products"]+1;
}


$result=mysql_query($mysql);
$result=mysql_query($mysql) or die(mysql_error()));

?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!-- Link to stylesheet stylesheet.css within the same folder as the HTML page -->
<link rel="StyleSheet" href="inc/css/stylesheet.css" type="text/css">




<html>
<head>
</head>
<body>

<div id="container"> <!-- Start of the Container DIV -->
<div class="animatedtabs">
<ul>
<li class="selected" ><a href="Shop.php" title="Shop"><span>Shop</span></a></li>
<li><a href="index.php" title="Home"><span>Home</span></a></li>
<li><a href="new.php" title="New"><span>New</span></a></li>
<li><a href="Categories.php" title="Categories"><span>Catogires</span></a></li>
<li><a href="safty.php" title="Tools"><span>Safty Center </span></a></li>
</ul>
</div>




<div id="HEADER">
<h1>swapit.com</h1>
<div class="Visual">
</div>
<div id="CONTENT">

	<?php

 		while ($row =mysql_fetch_array($result))
		{
			echo '<div id="products">';
			echo '<form name="cart" method="post" action="Shop.php?add=true">';
			echo '<table><tr>';
	    	echo '<td><h2>'.$row["title"].'</h2><p>'.$row["description"].'</p></td><td>£'.$row["price"].'</td><td><input type="submit" name="submit" value=" Add to Cart"></td>';
			echo '</table></tr>';
			echo '</form>';
			echo '</div>';
		}
 ?>

<?php
		echo '<div id="cart">';
		echo '<form name="cart" method="post" action="shop-cart.php" >';
		echo '<p class="center">SHOPPING CART</p>';
		echo '<p>No of Items: <strong>'.$_SESSION["products"].'</strong><br/>Total Price: <strong>£'. $_SESSION["cost"].'</strong></p>';
		echo '<p class="button"><input type="submit" name="Submit" value=" Check Out >> "shop-cart.php""></p>';
		echo '</form>';
		echo '</div>';

	?>





</div>

</div>



<?php include('dblogin.php');
if ($_SESSION["userid"]=="")
{
	header ('Location: login.php');
}

	if ($_SESSION["userid"]!="")
	{
		echo '<p><a href="logout.php">Logout</a></p>';
	}



?>



<!-- Do not edit above this line -->

<h2>Products...</h2>
<div id="TEXT">

<div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr><td><h2>Hot Fuzz - Limited Edition</h2>
<p>1 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
</td></table></tr><input type="hidden" name="id" value="1"><input type=$price name="price" value="19.99"><td><input type="submit" name="submit" value=" Add to Cart"></form></div>
<div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr><td><h2>10000 BC</h2>
<p>2 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
</td></table></tr><input type="hidden" name="id" value="2">
<input type="hidden" name="price" value="24.99"></form></div><div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>
<td><h2>The Matrix</h2><p>3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
</td></table></tr><input type="hidden" name="id" value="3"><input type=$price name="price" value="9.99"><input type="submit" name="submit" value=" Add to Cart"></form></div>
<div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>
<td><h2>Empire Records</h2><p>4 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
<td></td></table></tr><input type="hidden" name="id" value="4"> <input type=$price name="price" value="14.99"><<input type="submit" name="submit" value=" Add to Cart"></form></div>
<div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>
<td><h2>The Transporter</h2><p>5 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p><
</td></table></tr><input type="hidden" name="id" value="5"><input type=$price name="price" value="12.49"><input type="submit" name="submit" value=" Add to Cart"></form></div>
echo '<input type="hidden" name="id" value="'.$row["product_id"].'">';


</div>

<!-- Do not edit below this line -->

</div>

<div id="FOOTER">
<p>swapit.com </p>
<p>This website is a university assignment demonstration not a real shop!</p>
</div>

</body>
</html>

<!-- CO1505 Assignment 1 Project Example -->
<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript">
var websiteID='http://swapit.comoj.com';
</script>
<script type="text/javascript" src="http://analytics.hosting24.com/do.php"></script>
<noscript>
<a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/do.php?websiteID=chici.org" alt="web hosting" /></a>
</noscript>
<!-- End Of Code -->


<div class="shop">
<li>

<!-- the shop-->

</div> <!-- End of the Container DIV -->

</body>

</html>

 

THATS MY CURRNT CODE IT DOST WORK FULLY YET AND IDK WHY

 

Parse error: syntax error, unexpected T_STRING in /home/a2534943/public_html/Shop.php on line 8

 

 

<?php include('dblogin.php');
$host = "mysql5.000webhost.com";
$db_name= "a2534943_swapit";
$username = "a2534943_swapit";
$password = "11gordon";

   $connect = mysql_connect($host, $username, $password) or die(mysql_error())
   mysql_select_db($db_name) or die(mysql_error()."Could not select database");

   $mysql="SELECT * FROM `products`";

   $result=mysql_query($mysql);
   if ($_GET["add"]!="")
   {
         $_SESSION["cost"]=($_SESSION["cost"]+$price["price"] );
         $_SESSION["products"]=$_SESSION["products"]+1;
   }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!-- Link to stylesheet stylesheet.css within the same folder as the HTML page -->
<link rel="StyleSheet" href="inc/css/stylesheet.css" type="text/css">
<html>
<head>
</head>
<body>
<div id="container"> <!-- Start of the Container DIV -->
<div class="animatedtabs">
<ul>
<li class="selected" ><a href="Shop.php" title="Shop"><span>Shop</span></a></li>
<li><a href="index.php" title="Home"><span>Home</span></a></li>
<li><a href="new.php" title="New"><span>New</span></a></li>
<li><a href="Categories.php" title="Categories"><span>Catogires</span></a></li>
<li><a href="safty.php" title="Tools"><span>Safty Center </span></a></li>
</ul>
</div>
<div id="HEADER">
   <h1>swapit.com</h1>
   <div class="Visual">
   </div>
<div id="CONTENT">
    <?php
          while ($row = mysql_fetch_array($result))
         {
            echo '<div id="products">';
            echo '<form name="cart" method="post" action="Shop.php?add=true">';
            echo '<table><tr>';
             echo '<td><h2>'.$row["title"].'</h2><p>'.$row["description"].'</p></td><td>£'.$row["price"].'</td><td><input type="submit" name="submit" value=" Add to Cart"></td>';
            echo '</table></tr>';
            echo '</form>';
            echo '</div>';
         }
       echo '<div id="cart">';
       echo '<form name="cart" method="post" action="shop-cart.php" >';
       echo '<p class="center">SHOPPING CART</p>';
       echo '<p>No of Items: <strong>'.$_SESSION["products"].'</strong><br/>Total Price: <strong>£'. $_SESSION["cost"].'</strong></p>';
       echo '<p class="button"><input type="submit" name="Submit" value=" Check Out >> "shop-cart.php""></p>';
       echo '</form>';
       echo '</div>';
    ?>
   </div>
</div>
<?php include('dblogin.php');
   if ($_SESSION["userid"]=="")
   {
      header ('Location: login.php');
   }

      if ($_SESSION["userid"]!="")
      {
         echo '<p><a href="logout.php">Logout</a></p>';
      }
   ?>

<!-- Do not edit above this line -->

<h2>Products...</h2>
   <div id="TEXT">

   <div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr><td><h2>Hot Fuzz - Limited Edition</h2>
   <p>1 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
   </td></table></tr><input type="hidden" name="id" value="1"><input type=$price name="price" value="19.99"><td><input type="submit" name="submit" value=" Add to Cart"></form></div>
   <div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr><td><h2>10000 BC</h2>
   <p>2 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
   </td></table></tr><input type="hidden" name="id" value="2">
   <input type="hidden" name="price" value="24.99"></form></div><div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>
   <td><h2>The Matrix</h2><p>3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
   </td></table></tr><input type="hidden" name="id" value="3"><input type=$price name="price" value="9.99"><input type="submit" name="submit" value=" Add to Cart"></form></div>
   <div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>
   <td><h2>Empire Records</h2><p>4 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
   <td></td></table></tr><input type="hidden" name="id" value="4"> <input type=$price name="price" value="14.99"><<input type="submit" name="submit" value=" Add to Cart"></form></div>
   <div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>
   <td><h2>The Transporter</h2><p>5 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p><
   </td></table></tr><input type="hidden" name="id" value="5"><input type=$price name="price" value="12.49"><input type="submit" name="submit" value=" Add to Cart"></form></div>
   echo '<input type="hidden" name="id" value="'.$row["product_id"].'">';


   </div>

<!-- Do not edit below this line -->

</div>

<div id="FOOTER">
<p>swapit.com </p>
<p>This website is a university assignment demonstration not a real shop!</p>
</div>

</body>
</html>

<!-- CO1505 Assignment 1 Project Example -->
<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript">
var websiteID='http://swapit.comoj.com';
</script>
<script type="text/javascript" src="http://analytics.hosting24.com/do.php"></script>
<noscript>
<a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/do.php?websiteID=chici.org" alt="web hosting" /></a>
</noscript>
<!-- End Of Code -->


<div class="shop">
<li>

<!-- the shop-->

</div> <!-- End of the Container DIV -->
</body>
</html>

 

k all erro are gon  but the tataliser on my page is not adding up

<?php include('dblogin.php');

$host = "mysql5.000webhost.com";
$db_name= "a2534943_swapit";
$username = "a2534943_swapit";
$password = "11gordon";

   $connect = mysql_connect($host, $username, $password,$db_name) or die(mysql_error());
   mysql_select_db($db_name) or die(mysql_error()."Could not select database");

   $mysql="SELECT * FROM `products`";

   $result=mysql_query($mysql);
   if ($_GET["add"]!="")
   {
         $_SESSION["cost"]=($_SESSION["cost"]+$price["price"] );
         $_SESSION["products"]=$_SESSION["products"]+1;
   }
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">

<!-- Link to stylesheet stylesheet.css within the same folder as the HTML page -->
<link rel="StyleSheet" href="inc/css/stylesheet.css" type="text/css">
<html>
<head>
</head>
<body>
<div id="container"> <!-- Start of the Container DIV -->
<div class="animatedtabs">
<ul>
<li class="selected" ><a href="Shop.php" title="Shop"><span>Shop</span></a></li>
<li><a href="index.php" title="Home"><span>Home</span></a></li>
<li><a href="new.php" title="New"><span>New</span></a></li>
<li><a href="Categories.php" title="Categories"><span>Catogires</span></a></li>
<li><a href="safty.php" title="Tools"><span>Safty Center </span></a></li>
</ul>
</div>
<div id="HEADER">
   <h1>swapit.com</h1>
   <div class="Visual">
   </div>
<div id="CONTENT">
    <?php
          while ($row = mysql_fetch_array($result))
         {
            echo '<div id="products">';
            echo '<form name="cart" method="post" action="Shop.php?add=true">';
            echo '<table><tr>';
             echo '<td><h2>'.$row["title"].'</h2><p>'.$row["description"].'</p></td><td>£'.$row["price"].'</td><td><input type="submit" name="submit" value=" Add to Cart"></td>';
            echo '</table></tr>';
            echo '</form>';
            echo '</div>';
         }
       echo '<div id="cart">';
       echo '<form name="cart" method="post" action="shop-cart.php" >';
       echo '<p class="center">SHOPPING CART</p>';
       echo '<p>No of Items: <strong>'.$_SESSION["products"].'</strong><br/>Total Price: <strong>£'. $_SESSION["cost"].'</strong></p>';
       echo '<p class="button"><input type="submit" name="Submit" value=" Check Out >> "shop-cart.php""></p>';
       echo '</form>';
       echo '</div>';
    ?>
    
   </div>
</div>
<?php include('dblogin.php');
   if ($_SESSION["userid"]=="")
   {
      header ('Location: login.php');
   }

      if ($_SESSION["userid"]!="")
      {
         echo '<p><a href="logout.php">Logout</a></p>';
      }
   ?>

<!-- Do not edit above this line -->

<h2>Products...</h2>
   <div id="TEXT">

   <div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr><td><h2>Hot Fuzz - Limited Edition</h2>
   <p>1 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
   </td></table></tr><input type="hidden" name="id" value="1"><input type=$price name="price" value="19.99"><td><input type="submit" name="submit" value=" Add to Cart"></form></div>
   <div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr><td><h2>10000 BC</h2>
   <p>2 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
   </td></table></tr><input type="hidden" name="id" value="2">
   <input type="hidden" name="price" value="24.99"></form></div><div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>
   <td><h2>The Matrix</h2><p>3 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
   </td></table></tr><input type="hidden" name="id" value="3"><input type=$price name="price" value="9.99"><input type="submit" name="submit" value=" Add to Cart"></form></div>
   <div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>
   <td><h2>Empire Records</h2><p>4 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p></td>
   <td></td></table></tr><input type="hidden" name="id" value="4"> <input type=$price name="price" value="14.99"><<input type="submit" name="submit" value=" Add to Cart"></form></div>
   <div id="products"><form name="cart" method="post" action="Shop.php?add=true"><table><tr>
   <td><h2>The Transporter</h2><p>5 Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.</p><
   </td></table></tr><input type="hidden" name="id" value="5"><input type=$price name="price" value="12.49"><input type="submit" name="submit" value=" Add to Cart"></form></div>
   echo '<input type="hidden" name="id" value="'.$row["product_id"].'">';


   </div>

<!-- Do not edit below this line -->

</div>

<div id="FOOTER">
<p>swapit.com </p>
<p>This website is a university assignment demonstration not a real shop!</p>
</div>

</body>
</html>

<!-- CO1505 Assignment 1 Project Example -->
<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript">
var websiteID='http://swapit.comoj.com';
</script>
<script type="text/javascript" src="http://analytics.hosting24.com/do.php"></script>
<noscript>
<a href="http://www.hosting24.com/"><img src="http://analytics.hosting24.com/do.php?websiteID=chici.org" alt="web hosting" /></a>
</noscript>
<!-- End Of Code -->


<div class="shop">
<li>

<!-- the shop-->

</div> <!-- End of the Container DIV -->
</body>
</html>

new start now i have to get the number apper in a new screen  and idk how

 

 


<!-- Link to stylesheet stylesheet.css within the same folder as the HTML page -->
<link rel="StyleSheet" href="inc/css/stylesheet.css" type="text/css">
</head>

<div id="HEADER">
<p class="right"><a href="logout.php">Logout</a></p>
<h1>swapit</h1>

<ul>
	<li><a href="contact.php">Contact Us</a></li>
	<li><a href="shop.php">Products</a></li>
	<li><a href="blank.php">About Us</a></li>
	<li><a href="index.php">Home</a></li>
</ul>
<div class="Visual">


<div id="CONTENT">
<!-- Do not edit above this line -->

<h2>Shopping Cart</h2>
<div id="TEXT">
<p>You currently have the following items in your shopping cart</p>

<div id="products"><form name="checkout" method="post" action="checkout.php"><table class="full"></table></div><br/><p>Total <strong>£'. $_SESSION["cost"].'</strong></p>';</p><input type="submit" name="Submit" value=" Pay for items"></form>
</div>

<!-- Do not edit below this line -->

</div>

<div id="FOOTER">
<p>swapit.com © 2008 </p>
<p>This website is a university assignment demonstration not a real shop!</p>
</div>

</body>
</html>

<!-- CO1505 Assignment 1 Project Example -->
<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript">
</script>
<script type="text/javascript" src="http://analytics.hosting24.com/do.php"></script>
<!-- End Of Code -->

<?php

$host = "mysql5.000webhost.com";
$db_name= "a2534943_swapit";
$username = "a2534943_swapit";
$password = "11gordon";
$_SESSION['userid']=$row['userid'];
header ('Location: Shop.php');
	$_SESSION["cost"]=0;
	$_SESSION["products"]=0;
	$_SESSION["order"]="";
	$items = explode(",",$_SESSION["order"]);
$sql="SELECT * FROM products";
$result=mysql_query($sql);
$_SESSION["cost"]=total_price;
$_SESSION['userid']  = customer_id;
$items = explode(",",$_SESSION["order"]);

$items[0]=1
$items[1]=2
$items[2]=3
$items[3]=4
$items[4]=5








// Connect to server and select databse.
mysql_connect("$host", "$username", "$password")or die("cannot connect");
mysql_select_db("$db_name")or die("cannot select DB");
$sql='INSERT INTO orders VALUES ("",'.$_SESSION["userid"].',"'.$order.'",'.$_SESSION["cost"].')';
mysql_query($sql);


echo '<h1>Order Table</h1>';

echo '<p>This page displays the orders that are held within the orders table in your databse.</p>';

$sql="SELECT * FROM orders";
$result=mysql_query($sql);

while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
    echo ''.$row["order_id"].' - '.$row["customer_id"].' - '.$row["order_details"].' - '.$row["total_price"].'';
echo '<br />';
}

while ($row = mysql_fetch_array($result, MYSQL_ASSOC))
	{

		$row['product-id'];
		$row['title'];
		$row['description'];
		$row['cost'];


		for( $i = 0; $i < count($items); ++$i )
		{
			if ($items[$i]==$row['product-id'])
			{
				echo $row['title']. ' - £'.$row['price'];
				$order = $order.$row['title'].",";

			}
		}



	}



?>

<!-- Link to stylesheet stylesheet.css within the same folder as the HTML page -->
<link rel="StyleSheet" href="inc/css/stylesheet.css" type="text/css">
</head>

<div id="HEADER">
<p class="right"><a href="logout.php">Logout</a></p>
<h1>swapit</h1>

<ul>
	<li><a href="contact.php">Contact Us</a></li>
	<li><a href="shop.php">Products</a></li>
	<li><a href="blank.php">About Us</a></li>
	<li><a href="index.php">Home</a></li>
</ul>
<div class="Visual">


<div id="CONTENT">
<!-- Do not edit above this line -->

<h2>Shopping Cart</h2>
<div id="TEXT">
    <?php
          while ($row = mysql_fetch_array($result))
         {
            echo '<div id="products">';
            echo '<form name="cart" method="post" action="Shop.php?add=true">';
            echo '<table><tr>';
            echo '<td><h2>'.$row["title"].'</h2><p>'.$row["description"].'</p></td><td>£'.$row["price"].'</td><td><input type="submit" name="submit" value=" Add to Cart"></td>';
            echo '</table></tr>';
            echo '</form>';
            echo '</div>';
         }
       echo '<div id="cart">';
       echo '<form name="cart" method="post" action="shop-cart.php" >';
       echo '<p class="center">SHOPPING CART</p>';
       echo '</strong><br/>Total Price: <strong>£'. $_SESSION["cost"].'</strong></p>';
       echo '<p class="button"><input type="submit" name="Submit" value=" Check Out >> "checkout.php"></p>';
       echo '</form>';
       echo '</div>';
        ?>


<!-- Do not edit below this line -->

</div>

<div id="FOOTER">
<p>swapit.com © 2008 </p>
<p>This website is a university assignment demonstration not a real shop!</p>
</div>

</body>
</html>

<!-- CO1505 Assignment 1 Project Example -->
<!-- www.000webhost.com Analytics Code -->
<script type="text/javascript">
</script>
<script type="text/javascript" src="http://analytics.hosting24.com/do.php"></script>
<!-- End Of Code -->

new code

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.