Friday, 15 June 2012

php - Codeigniter, how do i get 2 params in the controller using javascript? -



php - Codeigniter, how do i get 2 params in the controller using javascript? -

hey guys got shopping cart loads using jquery, im using codeigniter, , dont know how 2 of params utilize get. this's javascritp method calls script.

function anade() { var idnumero = $(this).val(); var quant = $("#num" + idnumero).val(); $("#carrito").load("http://example.com/cart/addtocart?p=" + $(this).val() + "&cant=" + quant); }

this old script, im implementing mvc codeigniter, wont re write this:

session_start(); $suma=0; if (isset($_get['p'])) { $_session['product'][$_session['count']] = $_get['p']; $_session['quantity'][$_session['count']] = $_get['quant']; $_session['count']++; } $conexion = mysqli_connect($bd_servidor, $bd_usuario, $bd_contrasenia, $bd_basededatos); mysqli_set_charset($conexion, "utf-8"); echo"<table>"; ($i = 0; $i < $_session['count']; $i++) { //echo "product: " . $_session['product'][$i] . "<br />"; $query = "select * producto idproducto=" . $_session['producto'][$i] . ""; $resultado = mysqli_query($conexion, $query); while ($fila = mysqli_fetch_array($resultado)) { echo "<tr><td>unid : ".$_session['quantity'][$i]."</td><td>" . $fila['name'] . "</td><td> " . number_format(($_session['quantity'][$i]*$fila['price']),2) . "</td></tr>"; $suma+= $_session['quantity'][$i]*$fila['price'] ; } } //echo"<hr>"; echo "<tr><td>subtotal</td><td></td><td>". number_format($suma,2)."</td></tr>"; echo "</table>";

i know how should controller. ok? function getcart($p, $cant){ method...}

thxs!

here code should utilize 2 parameters in codeigniter.

java script

function anade() { var idnumero = $(this).val(); var quant = $("#num" + idnumero).val(); $("#carrito").load("http://example.com/cart/addtocart/" + $(this).val() + "/" + quant); }

in codeigniter

function getcart($p, $cant) { }

javascript php jquery ajax codeigniter

No comments:

Post a Comment