Jump to content

[SOLVED] creating survey from database bug


Q695

Recommended Posts

This code is copying the data from the previous query for some reason, and changing the type of field produced:

 

<?php

$type=$_GET[type];

?>

<form action="?page=construction_type&type=<?php echo $type;?>" method="post">

<strong>Zip/Postal Code:</strong> <br>

<input type="text" name="zip">

<?php

$sql="SELECT * FROM criteria WHERE type='$type' AND rank<'10';";

$result=@mysql_query($sql,$con) or die(death($sql));

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

 

/////////////////////////////////////////////////////////////////////////////

echo "<p><strong>".$row[value].":</strong><br>";

////////////////////////////////////////////////////////////////////////////

 

$sql2="SELECT * FROM criteria WHERE question='$row[question]' AND rank='10';";

$result2=@mysql_query($sql2,$con) or die(death($sql2));

while ($row2=mysql_fetch_array($result2)){

 

$style=$row['style'];

switch ($style) {

    case 1:

        $field=" $row2[value]:<br><input type='radio' name='$row[value]' value='$row2[value]'>";

        break;

    case 2:

        $field="<input type='text' name='$row[value]' > $row2[value]";

        break;

    case 3:

        $field="<input type='checkbox' name='$row[value]' value='$row2[value]'> $row2[value]";

        break;

    case 4:

        $field="<textarea name='$row[value]'></textarea>";

        break;

}

echo $field;

}

echo "</p>";

} ?>

<p><strong>Expect:</strong><br>

<textarea name="expect" cols="50" rows="10"></textarea></p>

<input type="submit" value="Submit">

</form>

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.