|
Posted by none on 10/06/87 11:29
As i said... I have several calls to the same "action" which i guess
could be resolved as a function: but i'm learning and i have no idea how
to do that.
I post the code, extremely boring i suppose. It's in italian, but it
shouldnt make such a difference, right?
The idea is that of making a form where the select options are taken
straight out of a mysql table, actually, a single column.
<?php
$database=****;
$link = mysql_connect('localhost', '***', '**********'); # connette a
mysql con user e pass
if (!$link) {
die('Could not connect: ' . mysql_error());
}
@mysql_select_db($database) or die( "Unable to select database"); #
connette al database indicato nella var database
# qui comincia il form coi vari select per i vantaggi etc...
<form action="pagina3.php" method="post">
<select name="vantaggi1">
<option value="NULL" selected="selected">niente<br>
<?php
$i=0;
$query="select van from vantaggi";
$res=mysql_query($query);
for ($i=0;$i<19;$i++){
$val=mysql_result($res,$i);
echo "<option value='$val'>$val";
}
?>
</select>
<select name="vantaggi2">
<option value="NULL" selected="selected">niente<br>
<?php
$i=0;
$query="select van from vantaggi";
$res=mysql_query($query);
for ($i=0;$i<19;$i++){
$val=mysql_result($res,$i);
echo "<option value='$val'>$val";
}
?>
</select>
<select name="vantaggi3">
<option value="NULL" selected="selected">niente<br>
<?php
$i=0;
$query="select van from vantaggi";
$res=mysql_query($query);
for ($i=0;$i<19;$i++){
$val=mysql_result($res,$i);
echo "<option value='$val'>$val";
}
?>
</select>
# qui iniziano gli svantaggi
<br>
<select name="svantaggi1">
<option value="NULL" selected="selected">niente<br>
<?php
$i=0;
$query="select svan from svantaggi";
$res=mysql_query($query);
for ($i=0;$i<24;$i++){
$val=mysql_result($res,$i);
echo "<option value='$val'>$val";
}
?>
</select>
<select name="svantaggi"2>
<option value="NULL" selected="selected">niente<br>
<?php
$i=0;
$query="select svan from svantaggi";
$res=mysql_query($query);
for ($i=0;$i<24;$i++){
$val=mysql_result($res,$i);
echo "<option value='$val'>$val";
}
?>
</select>
<select name="svantaggi"3>
<option value="NULL" selected="selected">niente<br>
<?php
$i=0;
$query="select svan from svantaggi";
$res=mysql_query($query);
for ($i=0;$i<24;$i++){
$val=mysql_result($res,$i);
echo "<option value='$val'>$val";
}
?>
</select>
# qui iniziano le abilità speciali
<br>
<select name="abspec1">
<option value="NULL" selected="selected" >niente<br>
<?php
$i=0;
$query="select abspec from abspec";
$res=mysql_query($query);
for ($i=0;$i<11;$i++){
$val=mysql_result($res,$i);
echo "<option value='$val'>$val";
}
?>
</select>
<select name="abspec2">
<option value="NULL" selected="selected" >niente<br>
<?php
$i=0;
$query="select abspec from abspec";
$res=mysql_query($query);
for ($i=0;$i<11;$i++){
$val=mysql_result($res,$i);
echo "<option value='$val'>$val";
}
?>
</select>
<select name="abspec3">
<option value="NULL" selected="selected" >niente<br>
<?php
$i=0;
$query="select abspec from abspec";
$res=mysql_query($query);
for ($i=0;$i<11;$i++){
$val=mysql_result($res,$i);
echo "<option value='$val'>$val";
}
mysql_close($link);
?>
</select>
<input type="submit" value="spara">
</form>
[Back to original message]
|