PHP - Multiselect And Add
Hi guys,
Im using a poker league script to keep track of the home games me and my 5 friends play every month. This script works fine, but its kinda tendeous because when I make a round I have to manually add every player individualy. I edited the html so that I get a multiselect box where all the names are listed and can be multiselected, but the code only saves the first name and thus it does not work as intended. anyone got any idea how to change this so I can select multiple names and they are added all at once? here is how the page looks: this is the add-players-to-tournament.php: Code: [Select] <?php include "../includes/config.php"; if (isset($_COOKIE["ValidUserAdmin"])) { require ( "../includes/CGI.php" ); require ( "../includes/SQL.php" ); $cgi = new CGI (); $sql = new SQL ( $DBusername, $DBpassword, $server, $database ); if ( ! $sql->isConnected () ) { die ( $DatabaseError ); } ?> <html> <head> <title>PokerMax Poker League :: The Poker Tournament League Solution</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <link href="../includes/style.css" rel="stylesheet" type="text/css" /> </head> <body bgcolor="#F4F4F4"> <?PHP include ("header.php"); ?> <table width="100%" cellpadding="5" cellspacing="0" border="0"> <tr> <td valign="top" bgcolor="ghostwhite" class="menu"><?PHP include ("leftmenu.php"); ?></td> <td bgcolor="#FFFFFF"> </td> <td valign="top" align="left" width="100%" bgcolor="#000000"><h1><br /> <img src="images/home.gif" width="25" height="25" /> PokerMax Poker League :: <font color="#CC0000">Assign Players to Tournaments</font></h1> <br /> <p>If you are running multiple tournaments on your website, this feature will allow you to assign any of your players to tournaments which you are running.</p> <?php if ( $cgi->getValue ( "op" ) == "AssignPlayer" ) { $result = mysql_query("SELECT playerid FROM ".$score_table." WHERE playerid = " . $sql->quote ( $cgi->getValue ( "playerid" ) ) . " AND tournamentid = " . $sql->quote ( $cgi->getValue ( "tournamentid" ) ) . "") or die ("$DatabaseError"); $chkd_email = mysql_numrows($result); if ($chkd_email != "") { print "<p class=\"red\"><strong>The Player has already been assigned to this tournament</strong></p>"; } else { mysql_query("INSERT INTO ".$score_table." VALUES ( '', " . $sql->quote ( $cgi->getValue ( "playerid" ) ) . ", " . $sql->quote ( $cgi->getValue ( "tournamentid" ) ) . ", '0', '$dateadded' )") or die ("$DatabaseError"); ?> <br> <p align="center" class="red">The player <strong><?php echo $_POST['playerid']; ?></strong> has been assigned to the poker tournament.</p> <?php } } ?> <form method="post"> <input name="op" type="hidden" value="AssignPlayer"> <select name="playerid" multiple size="8"> <?PHP $rows = $sql->execute ( "SELECT * FROM " . $player_table . " ORDER BY playerid ASC", SQL_RETURN_ASSOC ); for ( $i = 0; $i < sizeof ( $rows ); ++$i ) { $row = $rows [ $i ]; ?> <option value="<?php echo $cgi->htmlEncode ( $row [ "playerid" ] ); ?>"> <?php echo $cgi->htmlEncode ( $row [ "playerid" ] ); ?> - <?php echo $cgi->htmlEncode ( $row [ "name" ] ); ?> </option> <?php } ?> </select> <em>and assign to the tournament =></em> <select name="tournamentid" size="1"> <option value="">Select Tournament ....</option> <?PHP $rows = $sql->execute ( "SELECT * FROM " . $tournament_table . " ORDER BY id DESC", SQL_RETURN_ASSOC ); for ( $i = 0; $i < sizeof ( $rows ); ++$i ) { $row = $rows [ $i ]; ?> <option value="<?php echo $cgi->htmlEncode ( $row [ "tournamentid" ] ); ?>"> <?php echo $cgi->htmlEncode ( $row [ "tournament_name" ] ); ?> </option> <?php } ?> </select> <input type="submit" value="Assign Player" ONCLICK="return confirm('Are you sure you want to add this player to the tournament?');" /> </form> <br /></td> </tr> </table> <?PHP include ("footer.php"); ?> </body> </html> <?php } else { header("Location: index.php"); exit; } ?> Similar TutorialsHi guys, I have a form with a multiselect option as below Code: [Select] <select multiple="multiple" id="smoker" name="smoker[]"> <option value="" selected="selected">Please select</option> <option value="No" >No</option> <option value="Occasionally" >Occasionally</option> <option value="Often" >Often</option> <option value="Open to All" >Open to All</option> </select> and need to pass this info into mysql insert, but before that I need them to be seperated by coma, i have the code below but keep getting errors Code: [Select] if ($_SERVER['REQUEST_METHOD'] == 'POST') { $smoker=stripslashes($_POST['smoker']); $smoker_db=implode(", ",$smoker); } this is the error i get Quote Notice: Array to string conversion in ...... Could you please help me with this? Many thanks in advance I have this 3 tables
users (id_user)
music_styles (id_style, style) ex. (1) - (Blues)
user_styles (id_user, id_style)
I'm trying to create a form in which the user ($user = $_SESSION['id_user']) chooses through a multiple select the styles of preference to store them in the database using mysqli statements.
If the styles prefered are selected they should be displayed in the select input later, how can i accomplish this?
Thanks.
I know it's maybe EASY but how can I insert datas into database from multi-select html form? Here is the code: Code: [Select] <body><form action="<?=$_SERVER['PHP_SELF']?>" method="post"> <select name="test[]" multiple="multiple"> <option value="one">one</option> <option value="two">two</option> <option value="three">three</option> <option value="four">four</option> <option value="five">five</option> </select> <input type="submit" value="Send" /> </form> <?php $test=$_POST['test']; if ($test){ foreach ($test as $t){echo 'You selected ',$t,'<br />';} } ?></body>Any ideas how to modify the above code so I can INSERT INTO values from multi-select box? Hi forum, I would like to create a webpage (no DB) where I internally can reboot my phones (with https+login ofcause...). This is my reboot.php from http://code.google.com/p/php-sip/: --- <?php require_once('PhpSIP.class.php'); try { $api = new PhpSIP('172.30.30.1'); // IP we will bind to $api->setUsername('10000'); // authentication username $api->setPassword('secret'); // authentication password // $api->setProxy('some_ip_here'); $api->addHeader('Event: resync'); $api->setMethod('NOTIFY'); $api->setFrom('sip:10000@sip.domain.com'); $api->setUri('sip:10000@sip.domain.com'); $res = $api->send(); echo "res1: $res\n"; } catch (Exception $e) { echo $e->getMessage()."\n"; } ?> --- What I would like to achieve is to have a index.php with a "SITE" dropdown and a multiselect "PHONE" dropdown - where only marked phone(s) for a selected site can be chosen (most likely some java stuff...?): I need to be able to run this (reboot.php) from linux shell (like: php reboot.php <IP>) so I can schedule remote phonereboots when software has been updated on my provisioning server. It would be awesome if I was also able to choose "SITE"+"ALL" and reboot all phones in a site from both webpage and shell... Thanks in advance :-) ! ~Maymann |