Besoin d'aide pour checkbox

patator_35 Messages postés 2 Date d'inscription jeudi 24 février 2005 Statut Membre Dernière intervention 25 février 2005 - 24 févr. 2005 à 14:22
patator_35 Messages postés 2 Date d'inscription jeudi 24 février 2005 Statut Membre Dernière intervention 25 février 2005 - 25 févr. 2005 à 22:26
Bonjour,

je suis en train de finaliser la mise en place d'un site web basé sur oscommerce. Je suis encore débutant en php.
J'ai rectifié une contribution pour ajouter des cases à cocher.


<HR>

Dans un fichier, new_attribute_include.php, j'ai ajouté les lignes suivantes :
if ($attribute_RH == "-1") {
echo "<TD class="main" align="left"> </TD>";
}else {
echo "<TD class="main" align="left"> </TD>";
}

if ($attribute_LH == "-1") {
echo "<TD class="main" align="left"> </TD>";
}else {
echo "<TD class="main" align="left"> </TD>";
}

Le fichier modifié commence par (pour info) :
<FORM ACTION="<?=$PHP_SELF?>" METHOD="POST" NAME="SUBMIT_ATTRIBUTES">
">

<?


if ( $cPath ) echo "";


require( 'new_attributes_functions.php');


// Temp id for text input contribution.. I'll put them in a seperate array.
$tempTextID= "1999043";


// Lets get all of the possible options


$query "SELECT * FROM products_options where products_options_id LIKE '%' AND language_id '$languageFilter'";


<HR>

Lorsque j'appuie sur save dans mon formulaire, la page new_attribute_change.php est appelée mais elle ne semble pas bien récupérer les valeurs des checkbox :

for ($i = 0; $i < sizeof($optionValues); $i++) {
........
........
(j'ai rajouté ces 2 lignes et modifié la MYSQL_QUERY)

$value_RH = $HTTP_POST_VARS[$optionValues[$i] . '_optionValues_RH'];
$value_LH = $HTTP_POST_VARS[$optionValues[$i] . '_optionValues_LH'];
.....
MYSQL_QUERY( "INSERT INTO products_attributes ( products_id, options_id, options_values_id, options_values_price, price_prefix, products_options_sort_order,RH,LH)
VALUES( '$current_product_id', '$optionsID', '$optionValues[$i]', '$value_price', '$value_prefix', '$value_sort','$value_RH','$value_LH')" ) or die(mysql_error());

Je suis persuadé que les variables ne sont pas correctement récupérées dans $value_RH et $value_LH

J'espère réellement que quelqu'un de calé pourra m'aider car je suis vraiement scotché :)
Merci
Patrice

Patrice

1 réponse

patator_35 Messages postés 2 Date d'inscription jeudi 24 février 2005 Statut Membre Dernière intervention 25 février 2005
25 févr. 2005 à 22:26
J'ai finallement trouvé la réponse

Here is the final answer :
in new_attributes_function.php
<!--c1-->

CODE


<!--ec1-->
function getHandValues( $current_value_id, $current_product_id )
{
global $attribute_RH, $attribute_LH,$isSelected;

if ( $isSelected ) {
$query "SELECT * FROM products_attributes where options_values_id '$current_value_id' AND products_id = '$current_product_id'";

$result = mysql_query($query) or die(mysql_error());

while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) {

$attribute_RH = $line['RH'];
$attribute_LH = $line['LH'];

}

} else {

$attribute_RH = '';
$attribute_LH = '';
}

}
<!--c2-->
<!--ec2-->

In new_attributes_include
<!--c1-->

CODE


<!--ec1-->
getHandValues( $current_value_id, $current_product_id );

if ($attribute_RH == "1") {
echo "<TD class="main" align="left">&nbsp;&nbsp;</TD>";
}else {
echo "<TD class="main" align="left">&nbsp;&nbsp;</TD>";
}

if ($attribute_LH == "1") {
echo "<TD class="main" align="left">&nbsp;&nbsp;</TD>";
}else {
echo "<TD class="main" align="left">&nbsp;&nbsp;</TD>";
}
<!--c2-->
<!--ec2-->

In new_attributes_change
<!--c1-->

CODE


<!--ec1-->
$value_RH = $HTTP_POST_VARS[$optionValues[$i] . '_RH'][0];
$value_LH = $HTTP_POST_VARS[$optionValues[$i] . '_LH'][0];
<!--c2-->
<!--ec2-->

Patrice
0
Rejoignez-nous