Yeh I can but there is 30 files or so of php but i can put up the revlevant code i guess. Here it is:
code for show_cart.php
<?
include ("func.php");
// The shopping cart needs sessions, so start one
session_start();
if($new)
{
//new artist selected
if(!session_is_registered("cart"))
{
$cart = array();
session_register("cart");
$items = 0;
session_register("items");
$total_price = "0.00";
session_register("total_price");
}
if($cart[$new])
$cart[$new]++;
else
$cart[$new] = 1;
$total_price = calculate_price($cart);
$items = calculate_items($cart);
}
if($save)
{
foreach ($cart as $memberid => $qty)
{
if($$memberid=="0")
unset($cart[$memberid]);
else
$cart[$memberid] = $$memberid;
}
$total_price = calculate_price($cart);
$items = calculate_items($cart);
}
do_html_header("Your shopping cart");
if($cart&&array_count_values($cart))
display_cart($cart);
else
{
echo "<p>There are no artists that you have booked.";
echo "<hr>";
}
$target = "index.php";
// if we have just added an item to the cart, continue shopping in that category
if($new)
{
$details = get_artist_details($new);
if($details["procatid"])
$target = "show_cat.php?procatid=".$details["procatid"];
}
display_button($target, "continue-shopping", "Continue Shopping");
$path = $PHP_SELF;
$path = str_replace("show_cart.php", "", $path);
display_button("https://".$SERVER_NAME.$path."checkout.php", "go-to-checkout", "Go To Checkout");
do_html_footer();
?>
code for artist_func.php
<?
function get_categories()
{
// query database for a list of categories/professions
$conn = db_connect();
$query = "select procatid, profession
from profession_cat";
$result = @($query);
if (!$result)
return false;
$num_cats = @mysql_num_rows($result);
if ($num_cats ==0)
return false;
$result = db_result_to_array($result);
return $result;
}
function get_category_name($procatid)
{
// query database for the name for a category id
$conn = db_connect();
$query = "select profession
from profession_cat
where procatid = '$procatid'";
$result = @($query);
if (!$result)
return false;
$num_cats = @mysql_num_rows($result);
if ($num_cats ==0)
return false;
$result = mysql_result($result, 0, "profession");
return $result;
}
function get_artists($procatid)
{
// query database for the artists in a category
if (!$procatid || $procatid=="")
return false;
$conn = db_connect();
$query = "select *
from artists
where procatid='$procatid'";
$result = @($query);
if (!$result)
return false;
$num_artists = @mysql_num_rows($result);
if ($num_artists ==0)
return false;
$result = db_result_to_array($result);
return $result;
}
function get_artist_details($memberid)
{
// query database for all details of a particular artist
if (!$memberid || $memberid=="")
return false;
$conn = db_connect();
$query = "select *
from artists
where memberid='$memberid'";
$result = @($query);
if (!$result)
return false;
$result = @mysql_fetch_array($result);
return $result;
}
function calculate_price($cart)
{
// sum total price for all items in shopping cart
$price = 0.0;
if(is_array($cart))
{
$conn = db_connect();
foreach($cart as $memberid => $qty)
{
$query = "select price
from artists
where memberid='$memberid'";
$result = mysql_query($query);
if ($result)
{
$artist_price = mysql_result($result, 0, "price");
$price +=$artist_price*$qty;
}
}
}
return $price;
}
function calculate_items($cart)
{
// sum total artists for booking
$items = 0;
if(is_array($cart))
{
foreach($cart as $memberid => $qty)
{
$items += $qty;
}
}
return $items;
}
?>
code for admin.php which comes after the login page is called.
<?
// include function files for this application
require_once("func.php");
session_start();
if ($username && $passwd)
// they have just tried logging in
{
if (login($username, $passwd))
{
// if they are in the database register the user id
$admin_user = $username;
session_register($username);
}
else
{
// unsuccessful login
do_html_header("Problem:");
echo "You could not be logged in.
You must be an administrator for Tastywet in order to view this page.<br>";
do_html_url("login.php", "Login");
do_html_footer();
exit;
}
}
do_html_header("Administration");
if (check_admin_user())
display_admin_menu();
else
echo "You are not authorized to enter the administration area.";
do_html_footer();
?>
does this help? I need to know where to declare my variables and indexes? are indexexs directly related to the database design?
thanks!