You are here: I guess there is a way to make a function out of this but i don't know how :) « PHP Language « IT news, forums, messages
I guess there is a way to make a function out of this but i don't know how :)

Posted by none on 11/21/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>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация