12-26-2008, 12:05 PM
|
#1 (permalink)
|
|
The Visitor
Join Date: Dec 2008
Posts: 1
Thanks: 0
|
problem in php
PHP Code:
<?php session_start(); if($_SESSION['login']=="true") { echo "<b style=color:red>logged In As ".$_SESSION[username]; ?> <head> <script language="javascript"> function f1() { var a=document.getElementById('b').value; var b=document.getElementById('c').value; var c=a*b; document.getElementById('d').value=c; }</script></head> <body background="back1.jpg"> <table align="right"><tr align="right"><th><a href="logout.php" title="click here for logout">LogOut</a></th></tr></table> <?php $con= mysql_connect('localhost', 'root'); if (!$con) { die('Could not connect to database server: ' . mysql_error()); } $dbname = 'my_db'; $db_selected = mysql_select_db($dbname, $con); if (!$db_selected) { die("Could not connect $dbname " . mysql_error()); } $res=mysql_query("select p_name,p_price from temp where s_name='$_SESSION[username]'"); echo "<b><center>"; echo "<p style=color:#FF66CC>"; echo "Hi $_SESSION[username] "."Information On Shopping"; echo"<br>"; echo"<br>"; //$num_fields = mysql_num_fields($res); ?> <form action="" method="post" enctype="multipart/form-data" name="frm1"> <table cellspacing="7" cellpadding="8" > <tr> <th>product Name</th> <th>product price</th> <th>Quantity</th> <th>Total Price</th> </tr> <?php while($res2=mysql_fetch_object($res)) //for($x=0;$x<$num_row;$x++) { ?> <tr> <td><input type="text" id="a" name="a" value="<?php echo $res2->p_name; ?>" readonly=""></td> <td><input type="text" id="b" name="b" value="<?php echo $res2->p_price; ?>" readonly=""></td> <td><input type="text" id="c" name="c" onBlur="javascript:f1()"></td> <td><input type="text" id="d" name="d" value=""></td> </tr> <?php } ?> </table> </form> <a href="home1.php">Buy More Product</a> <?php } else { echo "Unauthorized Visit ! You Cannot access this Page"; echo"<br>"; echo"<br>"; echo "<a href='index.php' title='go back to login page'>click here to login</a>"; } ?>
I am wirting a programme on shopping cart there i am facing a problem while i am calculating the price of individual product using Javascript Blur Function..It is calculating only one value at a time..
it couldnot calculate the next values of the product which the user buying....pls can anyone help me out....pls send it in my email..its sauravlnp@gmail.com
Last edited by Salathe : 12-26-2008 at 05:35 PM.
Reason: Wrapping code in PHP tags
|
|
|
|