Tema: mensaje sql
Ver Mensaje Individual
  #9 (permalink)  
Antiguo 20/10/2008, 09:05
Javi611
 
Fecha de Ingreso: octubre-2008
Mensajes: 34
Antigüedad: 15 años, 6 meses
Puntos: 0
Respuesta: consulta INSERT INTO en pantalla

<?
echo ".$hidden.</td></tr>";

echo "<tr><td colspan='2'><fieldset><legend>Condiciones para la regla </legend>
<blockquote>Ingrese nuevas condiciones a la regla activa</blockquote>";

echo "<table>";

//echo "<pre>"; print_r($conditions);

foreach ($conditions as $i => $condition)
{

if ($cambio_regla != true)
{
$f_condicion = $condition;
}
else
{
$sql = "
SELECT * FROM
".TABLE_PREFIX."rules_conditions AS C
WHERE
C.id_regla='".$config['rule_id']."' AND C.nro='".$i."'";

echo $sql;
$r_condiciones = mysql_query($sql);
echo mysql_error();

$f_condicion = mysql_fetch_array($r_condiciones);
print_r($f_condicion);
}

if ($i == 1) {
echo "<tr><td>Si la </td><td>";
}
else {
echo "<tr><td> y si la </td><td>";
}

$sql_que = "SELECT * FROM ".TABLE_PREFIX."rules_ques";
$r_que = mysql_query($sql_que);
echo mysql_error();

$id = $f_condicion['id'];
//print_r($f_condicion);

echo "<select name='conditions[$i][item_id]' onchange='this.form.submit();'>"; //nchange='this.form.submit()';>";
echo "<option value='0'>-</option>";

for ($j = 0; $j < mysql_num_rows($r_que); $j++)
{
$f_que = mysql_fetch_array($r_que);
echo "<option value='".$f_que['id']."'";
if ($f_que['id'] == $f_condicion['item_id'])
{
$accion = $f_que['que'];
echo " selected ";
}
echo ">".$f_que['que']."</option>";

}
echo "</select>";

echo "</td>
<td> es ";

if ($condition['item_id'] != 2){

//print_r($_POST);
unset($a);unset($b);unset($c);unset($t);

if ($f_condicion['logic'] == '<') $a = ' selected ';
if ($f_condicion['logic'] == '>') $b = ' selected ';
if ($f_condicion['logic'] == '=') $c = ' selected ';
echo "
<select name='conditions[$i][logic]'>"; //nchange='this.form.submit()';>";
echo "<option value='0'>-</option>";
echo "<option $a value='<'><</option>";
echo "<option $b value='>'>></option>";
echo "<option $c value='='>=</option>";
echo "</select>";
echo "</td><td>a ";

}

/*switch ($condition['item_id'])
{
/*case 0:
print "i equals 0";
break;*/
/* case 1:
echo "<input name='conditions[$i][logic_value]' size='2' value='".$f_condicion['logic_value'] ."'>";
break;
case 2:
unset($a);unset($b);unset($c);unset($t);

if ($f_condicion['logic_value'] == '1') $a = ' selected ';
else if ($f_condicion['logic_value'] == '2') $b = ' selected ';
else if ($f_condicion['logic_value'] == '3') $c = ' selected ';
else $t = " selected ";

echo "<select name='conditions[$i][logic_value]'>"; //nchange='this.form.submit()';>";
echo "<option $t value='0'>-</option>";
echo "<option $a value='1'>Baja</option>";
echo "<option $b value='2'>Media</option>";
echo "<option $c value='3'>Alta</option>";
echo "</select>";
break;

case 3:
echo "<input name='conditions[$i][logic_value]' size='2' value='".$f_condicion['logic_value'] ."'>";
break;
}*/

if ($condition['item_id'] == 2)
{
unset($a);unset($b);unset($c);unset($t);

if ($f_condicion['logic_value'] == '1') $a = ' selected ';
else if ($f_condicion['logic_value'] == '2') $b = ' selected ';
else if ($f_condicion['logic_value'] == '3') $c = ' selected ';
else $t = " selected ";

echo "<select name='conditions[$i][logic_value]'>"; //nchange='this.form.submit()';>";
echo "<option $t value='0'>-</option>";
echo "<option $a value='1'>Baja</option>";
echo "<option $b value='2'>Media</option>";
echo "<option $c value='3'>Alta</option>";
echo "</select>";
}
else if ($condition['item_id'] == 3)
{
echo "<input name='conditions[$i][logic_value]' size='2' value='".$f_condicion['logic_value'] ."'>";
echo " Veces";
/*echo "<select name='conditions[$i][logic_value]'>"; //nchange='this.form.submit()';>";
echo "<option $t value='0'>-</option>";
echo "<option $a value='1'>Veces</option>";
echo "<option $b value='2'>1 mes</option>";
echo "<option $c value='3'>Nunca</option>";
echo "</select>";*/
}
else
{
echo "<input name='conditions[$i][logic_value]' size='2' value='".$f_condicion['logic_value'] ."'>";
}

echo "</td>
<td> en la ";

$sql_contex = "SELECT * FROM ".TABLE_PREFIX."rules_contexts";
$r_contex = mysql_query($sql_contex);
echo mysql_error();

echo "
<select name='conditions[$i][context_id]'>";// onchange='this.form.submit()';>";
echo "<option value='0'>-</option>";

for ($j = 0; $j < mysql_num_rows($r_contex); $j++)
{
$f_contex = mysql_fetch_array($r_contex);
echo "<option value='".$f_contex['id']."'";
if ($f_contex['id'] == $f_condicion['context_id'])
{
$accion = $f_contex['que'];
echo " selected ";
}
echo ">".$f_contex['name']."</option>";

}

echo "</td><td>";

if ($f_condicion['context_id'] == 1)
{
echo "<select name='conditions[$i][context_value]'>";
echo select('clases', $f_condicion['context_value']);
echo "</select>";
}
else if ($f_condicion['item_id'] == 2)
{
echo "<select name='conditions[$i][context_value]'>";
echo select('preguntas', $f_condicion['context_value']);
echo "</select>";
}
else
{
echo "<input name='conditions[$i][context_value]' size='2' value='".$f_condicion['context_value']."'>";
}
echo "</td><td></td>";
echo "</tr>";
}

echo "<tr><td colspan='5'>";
echo "<input type='submit' name='_agregar_condicion_' value='Agregar nueva condicion'>";
echo "</td></tr>";
echo "</table>";


echo "</fieldset>
</td></tr>";

echo "<tr><td colspan='2'><fieldset><legend>Acciones</legend><table width='100%'>";

echo "<tr><td colspan='3'><blockquote>Ingrese las sugerencias
correspondientes en<br>caso de que se cumplan las condiciones.
</blockquote></td></tr>";

foreach ($sug as $nh => $sugerencia)
{
echo "<tr><td >";

$sql_acc = "SELECT * FROM ".TABLE_PREFIX."rules_actions"; // WHERE id_regla='".$config['rule_id']."'";
$r_acc = mysql_query($sql_acc);
echo mysql_error();

echo "<select name='sug[".$nh."][id_accion]' onchange='this.form.submit();'>"; //nchange='this.form.submit()';>";
echo "<option value='0'>-</option>";

for ($j = 0; $j < mysql_num_rows($r_acc); $j++)
{
$f_acc = mysql_fetch_array($r_acc);
echo "<option value='".$f_acc['id']."'";
if ($f_acc['id'] == $sugerencia['id_accion']) echo " selected ";
echo ">".$f_acc['es']."</option>";

}

echo "</select>";

echo "</td><td>";

$sql_rec = "SELECT * FROM ".TABLE_PREFIX."rules_resources"; // WHERE id_regla='".$config['rule_id']."'";
$r_rec = mysql_query($sql_rec);
echo mysql_error();

echo "<select name='sug[".$nh."][id_recurso]' onchange='this.form.submit();'>";
echo "<option value='0'>-</option>";

for ($j = 0; $j < mysql_num_rows($r_rec); $j++)
{
$f_rec = mysql_fetch_array($r_rec);
echo "<option value='".$f_rec['id']."'";
if ($f_rec['id'] == $sugerencia['id_recurso']) echo " selected ";
echo ">".$f_rec['es']."</option>";

}
echo "</select>";

echo "</td><td>";

if ($sugerencia['id_recurso'] == 1)
{
echo "<select name='sug[".$nh."][valor]'>";
echo select('clases', $sugerencia['id_recurso']);
echo "</select>";
}
else
{
echo "<input type='text' size='10' name='sug[".$nh."][valor]' value='".$sugerencia['valor']."'>";
}

echo "</td></tr>";
}

?>
<tr><td colspan='3'><input type='submit' name='_agregar_sugerencia_' value='Agregar nueva sugerencias'></td></tr>
</table>
</fieldset>
</td></tr>
</table>
<input type='submit' name='actualizar' value='INSERTAR REGLA'>
<input type='hidden' name='edit_rule' value='1'>
</form>
</table>

<? //print_r($_SESSION); ?>
<?php require (AT_INCLUDE_PATH.'footer.inc.php'); ?>



Es algo incomprensible porque utiliza la plataforma atutor, para dar cursos por internet.

Muchas Gracias!