Scripts
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb Site ManagementScripts

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
1200+ fellow developers rate and compare features of the top IDEs, like Visual Studio, Eclipse, RAD, Delphi and others, across 13 categories. Enjoy this FREE Download of the IDE User Satisfaction Study by Evans Data Corporation. Download Now!
  #1  
Old October 1st, 2005, 03:07 PM
chi-town chi-town is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2005
Posts: 1 chi-town User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 m 22 sec
Reputation Power: 0
My E-commerce script

Ok, I need some help with an e-commerce script that I am writing. Here's what it does.

It detects computer systems from the database and then displays them in a dropdown list. Then when you select one system it will then give you a list of products that are compatible with the system. I got the databasing part down alright but I need help witht he php part.

Here's the code:

Code:
<html>
<head>
<title>Configurator</title>
</head>
<body>
<?PHP
//This part of the file contains the info to make a connection to the
database

//Database access information
define ('DB_USER', 'root');
define ('DB_PASSWORD', '');
define ('DB_HOST', 'localhost');
define ('DB_NAME', 'project');

//Make connection and then select database
$dbc = @mysql_connect (DB_HOST, DB_USER, DB_PASSWORD) OR die ('Could not
connect to MySQL: ' . mysql_error() );
mysql_select_db (DB_NAME) OR die ('Could not select database: ' .
mysql_error() );

//form to allow user to select a product to view
echo '<div align="center">
<form method="get" action="index.php">
<select name="system">
<option value="NULL">Choose a System:</option>
';

//retrieve and display available systems
$query = 'SELECT * FROM products ORDER BY system ASC';
$result = mysql_query ($query);
while ($row = mysql_fetch_array ($result, MYSQL_NUM)) {
        echo '<option value="', $row[0], '">', stripslashes($row[1]), '</option>
        ';
        }

//complete form
echo '</select>
<input type="submit" name="submit" value="GO!">
</form>
</div>
';

//retrieve system info from particular selection if selected
if (isset($_GET['system'])) {

        $s = intval($_GET['system']);

        //Get system name
        $query = "SELECT system FROM products WHERE id=$s";
        $result = mysql_query ($query);
        list ($system) = mysql_fetch_array ($result, MYSQL_NUM);

        echo "<hr /><div align=\"center\"><b>$system Info</b><br />
        <small>(All products will open in their own window. Recently added
products will show first.)</small></div>\n";

        //initialize variable
        $first = TRUE;

//Query the database
$query = "SELECT price, item, description, sku FROM hardware WHERE
system=$s OR system1=$s";
$result = mysql_query ($query);

//display all systems
while ($row = mysql_fetch_array ($result, MYSQL_ASSOC))  {

//If this is the first record, create table header
if ($first) {
        echo '<table border="1" width="100%" cellspacing="3" cellspacing="3"
align="center">
<tr><td align="left" width="5%"><b>Select</b></td>
        <td align="center" width="37.5%"><font size="+1">Item</font></td>
        <td align="center" width="37.5%"><font size="+1">Description</font></td>
        <td align="right" width="10%"><b>Sku Number</b></td>
        <td align="center" width="10%"><b>Price</b></td>
</tr>';
        }                //end of $first IF



echo "  <tr>
        <td align=\"left\"><input name=\"select\" type=\"radio\"
value=\"submit\"></td>
        <td align=\"center\"><a href=\"http://{$row['item']}\" target=\"_new\">" .
        stripslashes($row['item']) . "</a></td>
        <td align=\"center\">{$row['description']}</td>
        <td align=\"right\">{$row['sku']}</td>
        <td align=\"center\">$ {$row['price']}</td>
</tr>\n";

$tax = ($row['price']) * (.08);
$total = ($tax) + ($row['price']);

        //one record is returned
        $first = FALSE;

}

//If no records where displayed
if ($first) {
                echo '<div align="center">There are currently no systems in the
database.</div>';
} else {

                echo ' <tr>
                        <td colspan="4" align="right">
                                <b>Tax: <b></td>
                        <td align="right">$' . number_format ($tax, 2) . '</td>
                        <br>
                         <tr>
                                <td colspan="4" align="right">
                                        <b>Total: <b></td>
                                <td align="right">$' . number_format ($total, 2) . '</td></table>';
        //closes table
}

}

mysql_close();                //close database connection

?>
</body>
</html>


now I integrated code to have a radio selection button next to each item that is detected in the system but I really need help integrating a submit button that will select that item that is selected by the radio button and update the price according to the one I selected, can someone please help me?

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb Site ManagementScripts > My E-commerce script


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway