z0l3e Posted March 19, 2012 Share Posted March 19, 2012 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 ! Quote Link to comment https://forums.phpfreaks.com/topic/259283-try-to-_get-more-input-lines-with-same-name-and-i-get-output-only-the-last/ Share on other sites More sharing options...
cpd Posted March 19, 2012 Share Posted March 19, 2012 Could you try splitting your code up and putting it in or [code=php:0] tags instead of dumping the file. We'll be able to help a lot easier then Quote Link to comment https://forums.phpfreaks.com/topic/259283-try-to-_get-more-input-lines-with-same-name-and-i-get-output-only-the-last/#findComment-1329242 Share on other sites More sharing options...
Andy-H Posted March 20, 2012 Share Posted March 20, 2012 <input name="test[]" > <input name="test[]" > <input name="test[]" > foreach($_POST['test'] as $val) { echo $val .'<br >'; } works with $_GET too Quote Link to comment https://forums.phpfreaks.com/topic/259283-try-to-_get-more-input-lines-with-same-name-and-i-get-output-only-the-last/#findComment-1329258 Share on other sites More sharing options...
z0l3e Posted March 20, 2012 Author Share Posted March 20, 2012 i have tried but my problem is that $_POST['test'] is not an array is NULL this is my problem and i don`t know why !!! Quote Link to comment https://forums.phpfreaks.com/topic/259283-try-to-_get-more-input-lines-with-same-name-and-i-get-output-only-the-last/#findComment-1329349 Share on other sites More sharing options...
z0l3e Posted March 20, 2012 Author Share Posted March 20, 2012 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 ??? Quote Link to comment https://forums.phpfreaks.com/topic/259283-try-to-_get-more-input-lines-with-same-name-and-i-get-output-only-the-last/#findComment-1329384 Share on other sites More sharing options...
Gem Posted March 20, 2012 Share Posted March 20, 2012 var_dump($_POST['title']); you might want to add method="post" to your form tag though ... Quote Link to comment https://forums.phpfreaks.com/topic/259283-try-to-_get-more-input-lines-with-same-name-and-i-get-output-only-the-last/#findComment-1329391 Share on other sites More sharing options...
z0l3e Posted March 20, 2012 Author Share Posted March 20, 2012 the same, var_dump($_POST['title']); = NULL i put the method="post" in the form var_dump($_POST['title']); you might want to add method="post" to your form tag though ... Quote Link to comment https://forums.phpfreaks.com/topic/259283-try-to-_get-more-input-lines-with-same-name-and-i-get-output-only-the-last/#findComment-1329408 Share on other sites More sharing options...
Gem Posted March 20, 2012 Share Posted March 20, 2012 where have you defined $title? Quote Link to comment https://forums.phpfreaks.com/topic/259283-try-to-_get-more-input-lines-with-same-name-and-i-get-output-only-the-last/#findComment-1329434 Share on other sites More sharing options...
Gem Posted March 20, 2012 Share Posted March 20, 2012 nm, i see it Quote Link to comment https://forums.phpfreaks.com/topic/259283-try-to-_get-more-input-lines-with-same-name-and-i-get-output-only-the-last/#findComment-1329437 Share on other sites More sharing options...
z0l3e Posted March 20, 2012 Author Share Posted March 20, 2012 yes is it defined $title ... i solved what i need to to ... thank YOU, and all who try to help me. CASE SOLVED ! nm, i see it Quote Link to comment https://forums.phpfreaks.com/topic/259283-try-to-_get-more-input-lines-with-same-name-and-i-get-output-only-the-last/#findComment-1329494 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.