Jump to content

[SOLVED] Simple help please


marklarah

Recommended Posts

<?php
you know the drill here 
?>

<style type="text/css">
fieldset { border:1px solid green; padding: 1em;
  font:80%/1 sans-serif; }

legend {
  padding: 0.2em 0.5em;
  border:1px solid green;
  color:green;
  font-size:90%;
  text-align:left;
  }

label {
  float:left;
  width:25%;
  margin-right:0.5em;
  padding-top:0.2em;
  text-align:right;
  font-weight:bold;
  }
</style>

<script type="text/javascript">
function formgo(){

var cnum = document.lform.ops.length;

for (i = 0; i <cnum; i++) {
if (document.lform.ops[i].checked) {
var chkd = document.lform.ops[i].value;
}
}


switch (chkd)
{

<?php

$query = mysql_query("SELECT * FROM logins ORDER BY label DESC") or die(mysql_error());

while ($row = mysql_fetch_array($query)){

echo 'case "'.$row['name'].'":
  document.'.$row['name'].'.submit();
  break;

';
}
?>



default:
  alert("");
}

alert(chkd);

}
</script>

<form name="lform">
  <fieldset>
  <legend>Login Forms</legend>
<?php


$query2 = mysql_query("SELECT * FROM logins ORDER BY label DESC") or die(mysql_error());

// while ($row2 = mysql_fetch_assoc($query2)){
//print_r($row2);
//}

// echo mysql_num_rows($query);
while ($rows = mysql_fetch_assoc($query2)){

echo '  <label for="ops">'.$rows['label'].'</label> <input type="radio" name="ops" value="'.$rows['name'].'">     <br />';
}
?>
<button type="button" onClick="formgo()">Submit</button>
  </fieldset>
</form>


<?php
while ($row = mysql_fetch_assoc($query2)){
$info = explode("|", $row['info']);
$num = count($info);

if($num % 2 != 0){
echo 'Problem';
}else{

echo '<form name="'.$row['name'].'" action="'.$row['action'].'" method="post">';

//here?
$n = 0;
while ($n < ($num/2)){
$m = $n+1;
echo '<input type="hidden" name="'.$info[$n].'" value="'.$info[$m].'">';
$n++;
$n++;
}

echo '</form>';

}


}
?>

<?php

// connect stuff

// CSS Junk

// Random JS

// I presume the switch is working

$q = mysql_query("SELECT * FROM logins ORDER BY label DESC") or die(mysql_error());

while ($r = mysql_fetch_assoc($q)){
echo '  <label for="ops">'.$r['label'].'</label> <input type="radio" name="ops" value="'.$r['name'].'">     <br />';
}

while ($a = mysql_fetch_assoc($q)){
$info = explode("|", $ra['info']);
$num = count($info);

if($num % 2 != 0){
echo 'Problem';
}else{

echo '<form name="'.$row['name'].'" action="'.$row['action'].'" method="post">';

$n = 0;
while ($n < ($num/2)){ // Why are you doing this?
$m = $n+1;
echo '<input type="hidden" name="'.$info[$n].'" value="'.$info[$m].'">';
$n++;
$n++;
}

echo '</form>';

}


}
?>

 

----------------

Now playing: Flyleaf Vs. The Legion Of Doom - I'm So Sick (T-Virus Remix)

via FoxyTunes

yeah, the $info variable is an array, and it stores it in the first block will be a the name of a field, the second the value of it. Then the third block will be the name of another.....and so on. So within each row, there may be many different hidden fields, so that hopefully goes through them, but im running this now (still doesn't work)

$l = $num/2;
$n = 0;
while ($l != ($num/2)){
$m = $n+1;
echo '<input type="hidden" name="'.$info[$n].'" value="'.$info[$m].'">';
$n++;
$n++;
$l++;
}

 

 

When im trying print_r($row) within the last while loop, it doesn't work...

 

 

See if you can spot the problem :P

 

$l = $num/2; // <---!!!!!!!!!
$n = 0;
while ($l != ($num/2)){ // <-- What did you just define $l as 
$m = $n+1;
echo '<input type="hidden" name="'.$info[$n].'" value="'.$info[$m].'">';
$n++;
$n++;
$l++;
}

 

----------------

Now playing: Foo Fighters - Times Like These

via FoxyTunes

$l = 0;
$n = 0;
while ($l != ($num/2)){ // <-- What did you just define $l as 
echo '<input type="hidden" name="'.$info[$n].'" value="'.$info[$n+1].'">';
$n++;
$n++; // Why twice?
$l++;
}

 

----------------

Now playing: Foo Fighters - Disenchanted Lullaby

via FoxyTunes

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.