hi there,
i am trying to insert multiple values in table row from values of checkboxes.
allow me to paste my code than my question !
// get current block configuration
$sql = "SELECT * FROM ".PREFIX."mc_blocks WHERE sc_template='".$storeConfig['template']."'";
$result =& dbQuery($sql);
extract(dbFetchAssoc($result));
// Charge Left-Right Blocks
$spL=preg_split('/:/',$LBData); $spR=preg_split('/:/',$RBData);
$handle=opendir(SRV_ROOT.'blocks');
$blocklist1=""; while (false !== ($file = readdir($handle))) { if ( (!ereg("[ ]",$file)) && $file!=="." && $file!==".." && $file!=="" && $file!=="images" && $file!=="index.php") {$blocklist1.= "$file";}}
closedir($handle); $blocklist1 = explode(".php",$blocklist1); sort($blocklist1);
$i=0; $k=count($blocklist1); for ($ii=0; $ii < $k; ++$ii) { if(!empty($blocklist1[$ii])) { $blocklist[$i]=$blocklist1[$ii]; $i=$i+1; } }
$EmptyBlock='EmptyBlock';
if($tlogoyn==1) { $tlogoyn1='image'; $tlogoyn2='text'; } else { $tlogoyn1='text'; $tlogoyn2='image'; }
if($tbyn==1) { $tbyn1='Yes'; $tbyn2='No'; } else { $tbyn1='No'; $tbyn2='Yes'; }
if($bbyn==1) { $bbyn1='Yes'; $bbyn2='No'; } else { $bbyn1='No'; $bbyn2='Yes'; }
$ADMINOUT='
<form action="processConfig.php?action=modify" method="post" enctype="multipart/form-data" name="frmConfig" class="frmConfig">
<p align="center" class="formTitle">Template Config</p>'.displayError().'
<table width="100%" border="0" cellspacing="1" cellpadding="2" class="entryTable">
<tr class="entryTableHeader">
<td colspan="4"> Left - Right blocks check list</td>
</tr>
<tr>
<td align="center" class="content"><br><p><b>LEFT BLOCKS<br>(select) </b></p></td>
<td align="center" class="content"><br><p><b>RIGHT BLOCKS<br>(select)</b></p></td>
</tr>';
$cTable=count($blocklist); $ResultHtmlL='<br>'; $ResultHtmlR='<br>'; $NumL=-1; $NumR=-1;
for ($i=0; $i < $cTable; ++$i) {
$checkL='';
if (in_array($blocklist[$i],$spL)) {
$NumL=$NumL+1;
$ResultHtmlL.="$NumL <select name=\"xdpLBData[$NumL]\" class=\"box\">";
for ($jl=0; $jl < $cTable; ++$jl) {
$ResultHtmlL.="<option value='".$blocklist[$jl]."'";
if($blocklist[$jl]==$spL[$NumL]) {$ResultHtmlL.="selected"; $checkL=$blocklist[$jl]; }
$ResultHtmlL.=">".$blocklist[$jl];
}
$ResultHtmlL.="</select><input type='checkbox' name=\"xxL[$NumL]\" value='".$checkL."' ><br>";
}
$checkR='';
if (in_array($blocklist[$i],$spR)) {
$NumR=$NumR+1;
$ResultHtmlR.=" $NumR <select name=\"xdpRBData[$NumR]\" class=\"box\">";
for ($jr=0; $jr < $cTable; ++$jr) {
$ResultHtmlR.="<option value='".$blocklist[$jr]."'";
if($blocklist[$jr]==$spR[$NumR]) {$ResultHtmlR.="selected"; $checkR=$blocklist[$jr];}
$ResultHtmlR.=">".$blocklist[$jr];
}
$ResultHtmlR.="</select>";
if($checkR!==$EmptyBlock) {$ResultHtmlR.= "<input type='checkbox' name=\"xxR[$NumR]\" value='".$checkR."' >";}
$ResultHtmlR.="<br>";
}
}
$NumL=$NumL+1;
$ResultHtmlL.='<p><b>Add new left block</b><br>';
$ResultHtmlL.='<select name=\'xdpLBData['.$NumL.']\' class="box">';
for ($j=0; $j < $cTable; ++$j) { $ResultHtmlL.='<option value="'.$blocklist[$j].'">'.$blocklist[$j]; }
$ResultHtmlL.='<option value="'.$checkL.'" selected>'.$EmptyBlock.'</select>
</p><p> </p>';
$NumR=$NumR+1;
$ResultHtmlR.='<p><b>Add new right block</b><br>';
$ResultHtmlR.='<select name=\'xdpRBData['.$NumR.']\' class="box">';
for ($j=0; $j < $cTable; ++$j) { $ResultHtmlR.='<option value="'.$blocklist[$j].'">'.$blocklist[$j]; }
$ResultHtmlR.='<option value="'.$checkR.'" selected>'.$EmptyBlock.'</select>
</p><p> </p>';
$ADMINOUT.='
<tr>
A small explanation of the code :
This scans directory blocks, for php files.
I have manualy entered data in mysql row. It looks like this :
INSERT INTO `mc_blocks` VALUES (19, 'NewProducts:Search:Information:', 'BestSellers:DoYouKnow:Visa', '', 'Your Online Store', 'your slogan goes here', '', 2, '', '', '', '', '2', '8c48d8492bd97062f2e62473bcd6a988.gif', '', '<script type="text/javascript"><!--\r\ngoogle_ad_client = "pub-4843959578128079";\r\ngoogle_ad_width = 728;\r\ngoogle_ad_height = 90;\r\ngoogle_ad_format = "728x90_as";\r\ngoogle_ad_channel ="";\r\ngoogle_color_border = ["12127D"];\r\ngoogle_color_bg = ["FFFFFF"];\r\ngoogle_color_link = ["0000FF"];\r\ngoogle_color_url = ["008000"];\r\ngoogle_color_text = ["000000"];\r\n//--></script>\r\n<script type="text/javascript"\r\n src="http://pagead2.googlesyndication.com/pagead/show_ads.js">\r\n</script>', 1, 'multipack');
If you look at this you will see how values are stored :
"'NewProducts:Search:Information:"
I am trying to build function which will proceed the request.
I have a file called "processConfig.php". Within this function :
function modifyShopConfig()
{
$xdpLBData= $_POST['xdpLBData'];
$xdpRBData= $_POST['xdpRBData'];
$sql = "UPDATE mc_blocks SET LBData = '$xdpLBData', RBData = '$xdpRBData'";
$result = dbQuery($sql);
header("Location: index.php");
}
When i execute this function it removes all values from mysql row.
Could you please try to help me ?
I dont need entire code solution, just small tip how to solve this.
A query perhaps ?
Thank you,