Jump to content

Try to _GET more input lines with same name, and i get output only the last !!!


z0l3e

Recommended Posts

function showCart() {

global $db;

 

$cart = $_SESSION['cart'];

$output[] = '<div align="center"><table cellpadding="1" cellspacing="1" bgcolor="#666666" width="400">';

$output[] = '<tr bgcolor="#FFFFFF" valign="middle">';

$output[] = '<td width="70" align="center">Titlu</td>';

$output[] = '<td width="90" align="center">Imagine </td>';

$output[] = '<td width="60" align="center">Pret</td>';

$output[] = '<td align="center">Sterge Produs</td>';

 

$total += $price * $qty;

$output[] = '</tr>';

$output[] = '</table>';

if ($cart) {

$items = explode(',',$cart);

$contents = array();

foreach ($items as $item) {

$contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1;

}

$output[] = '<form  action="http://www.sprayart.info/new/sprayart.php"><div align="center" name="trimite" id="trimite"><table width="400">';

foreach ($contents as $id=>$qty) {

 

 

$sql = 'SELECT * FROM com_images WHERE id = '.$id;

$result = $db->query($sql);

$row = $result->fetch();

extract($row);

 

$output[] = '<tr bgcolor="#FFFFFF">';

$output[] = '<td width="70">

<input type="hidden" name="title[ ]"

value="'.$title.'" size="5" maxlength="5" />

<input type="text"  value="'.$title.'" size="5" maxlength="5" disabled="disabled" /></td>';

$output[] = '<td width="90" align="center" valign="middle"><img src=../../'.$thumbnail.'> </td>';

$output[] = '<td width="60" align="center">'.$price.'</td>';

$output[] = '<td ></td>';

$total += $price * $qty;

$output[] = '<td width="50"><a href="cart.php?action=delete&id='.$id.'" class="r"><img src="../../media/sterge.jpg"></a></td>';

$output[] = '</tr>';

}

 

$output[] = '</table>';

$output[] = '<hr>';

$output[] = '<p align="right">Total De plata: <strong>'.$total.' RON</strong></p></div>';

 

$output[] = '<table border="0" width="444" id="table29" cellspacing="0" cellpadding="0" background="#BASE_URL#media/comand_form.gif" height="322">

  <form action="#BASE_URL#sprayart.php" method="post" name="trimite" id="trimite">

    <tr>

      <td width="25"></td>

      <td width="71" class="text_negru_left_25"><span class="style4">*</span> Nume:</td>

      <td width="146"><input name="nume" type="text" class="text_negru_fild_19" /></td>

      <td width="170"></td>

      <td width="32"></td>

    </tr>

    <tr>

      <td width="25"></td>

      <td  class="text_negru_left_25"><span class="style4">*</span> Adresa:</td>

      <td ><input name="adresa" type="text" class="text_negru_fild_19"></td>

      <td width="170"></td>

      <td width="32"></td>

    </tr>

    <tr>

      <td width="25"></td>

      <td  class="text_negru_left_25"><span class="style4">*</span> E-mail:</td>

      <td ><input name="email" type="text" class="text_negru_fild_19" /></td>

      <td width="170"></td>

      <td width="32"></td>

    </tr>

    <tr>

      <td width="25"></td>

      <td class="text_negru_left_25"><span class="style4">*</span> Telefon:</td>

      <td ><input name="telefon" type="text" class="text_negru_fild_19" /></td>

      <td width="170"></td>

      <td width="32"></td>

    </tr>

    <tr>

      <td width="25" height="139"></td>

      <td colspan="3" class="text_negru_left_25"><span class="style4">*</span>        <textarea name="mesaj" cols="44" rows="7" ></textarea></td>

      <td width="32"></td>

    </tr>

    <tr>

      <td width="25" height="39"></td>

      <td colspan="2" valign="top" class="text_negru_left_25"></td>

      <td valign="top" class="text_negru_left_25"><input style="BORDER-RIGHT: #3a3a3a 1px solid; BORDER-TOP: #3a3a3a 1px solid; FONT-SIZE: 8pt; FLOAT: right; BORDER-LEFT: #3a3a3a 1px solid; COLOR: #b1b1a7; BORDER-BOTTOM: #3a3a3a 1px solid; FONT-FAMILY: Verdana; BACKGROUND-COLOR: #3a3a3a" type="submit" class="buton" name="trimite" value="Trimite" /></td>

      <td width="32"></td>

    </tr></table></form>';

 

 

  how can i get the "title" for all products ! if i buy one its ok it will send me in email, but if is more products i get only the last added product!!

 

Please help thank you !

Link to comment
Share on other sites

function writeShoppingCartup() {

$cart = $_SESSION['cart'];

if (!$cart) {

return '<img src="../../media/cart.jpg"> <br /> Cosul meu (Gol)';

} else {

// Parse the cart session asizeiable

$items = explode(',',$cart);

$s = (count($items) > 1) ? 'e':'';

return '<img src="../../media/cart.jpg">

<br /><a href="#BASE_URL#ViewCard/">Cosul meu (' .count($items).')</a>';

}

}

 

function showCart() {

global $db;

 

$cart = $_SESSION['cart'];

$output[] = '<div align="center"><table cellpadding="1" cellspacing="1" bgcolor="#666666" width="400">';

$output[] = '<tr bgcolor="#FFFFFF" valign="middle">';

$output[] = '<td width="70" align="center">Titlu</td>';

$output[] = '<td width="90" align="center">Imagine </td>';

$output[] = '<td width="60" align="center">Pret</td>';

$output[] = '<td align="center">Sterge Produs</td>';

 

$total += $price * $qty;

$output[] = '</tr>';

$output[] = '</table>';

if ($cart) {

$items = explode(',',$cart);

$contents = array();

foreach ($items as $item) {

$contents[$item] = (isset($contents[$item])) ? $contents[$item] + 1 : 1;

}

$output[] = '<form  action="http://www.sprayart.info/new/sprayart.php"><div align="center" name="trimite" id="trimite"><table width="400">';

foreach ($contents as $id=>$qty) {

 

 

$sql = 'SELECT * FROM com_images WHERE id = '.$id;

$result = $db->query($sql);

$row = $result->fetch();

extract($row);

 

$output[] = '<tr bgcolor="#FFFFFF">';

$output[] = '<td width="70">

[THIS IS PROBLEM PHP] <input type="hidden" name="title[]" value="'.$title.'" size="5" maxlength="5" />

<input type="text"  value="'.$title.'" size="5" maxlength="5" disabled="disabled" /></td>';

$output[] = '<td width="90" align="center" valign="middle"><img src=../../'.$thumbnail.'> </td>';

$output[] = '<td width="60" align="center">'.$price.'</td>';

$output[] = '<td ></td>';

$total += $price * $qty;

$output[] = '<td width="50"><a href="cart.php?action=delete&id='.$id.'" class="r"><img src="../../media/sterge.jpg"></a></td>';

$output[] = '</tr>';

}

 

$output[] = '</table>';

$output[] = '<hr>';

$output[] = '<p align="right">Total De plata: <strong>'.$total.' RON</strong></p></div>';

 

 

 

Ok i will expend the issue !!!

 

            This is a function that add items in my shopping cart the problem is that this generate a multiple row table and whe i try to $_GET; $_POST['title']  the value of $_GET,POST['title'] should be an array but is NULL, and i can figure out why ... i try

 

 

"foreach($_POST['test'] as $val) {

  echo $val .'<br >';

}"

 

but i get this

Warning: Invalid argument supplied for foreach() in C:\xampp\htdocs\SprayART\includes\functions.inc.php on line 113

 

so when i use this

 

if(is_null($_POST['title']))

{

echo "true";

}else{ echo "false";}

 

I get the  " true" value ... so this is my problem    $_POST['title'] IS NOT AN ARRAY   

 

  my question is WHY ???

Link to comment
Share on other sites

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.