Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
|
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 20th, 2006, 03:44 AM
Friend of Wrox
 
Join Date: Mar 2005
Posts: 264
Thanks: 0
Thanked 0 Times in 0 Posts
Default problem reciving check box values using post metho

Hi all i got a form with many checkboxes and i want to pass checkbox varaibles to a new page using post method but the problem is that each time the first variable get pasted .Beleow u see part of php code that recives the passed variables. When i run this script by selecting 3 check boxes which has values :1 first check box, 2 second checkbox and 3 3th checbox. i get this

select filename,title from wimpy where id=1

instead of

select filename,title from wimpy where id=1 OR id=2 OR id=3

I be happy if an expert help me fix this problem and be able to pass all values of check box to second page and be able to buil query such :
select filename,title from wimpy where id=1 OR id=2 OR id=3
Thanks

part of check box form code:
Code:
<form method="POST" action="./playlist.php"  name="mp3Play">
...
...
...
playlist.php code
Code:
<?php

//echo $_POST['id']; 

$user = "root";
$pw = "";
$db = "mp3sversion5";
$mysql_access = mysql_connect("localhost", $user, $pw);
mysql_select_db($db, $mysql_access);


if (isset($_POST['Id'])) {
    $fragments = explode(',',$_POST['Id']);
    $loopCount = sizeof($fragments);
    for ($loop = 0; $loop < $loopCount; $loop++) {
        if ($where != '') $where .= ' OR';
        $where .= ' id='.$fragments[$loop].' ';
    }    }
$query = "select filename,title from wimpy where $where";

echo $query;

$result = mysql_query($query);
 
Old March 10th, 2006, 08:27 PM
Friend of Wrox
 
Join Date: Dec 2004
Posts: 154
Thanks: 0
Thanked 0 Times in 0 Posts
Default

>> playlist.php code
I use :
<Form action=Play_MP3.php' method='POST'>
<SELECT SIZE="22" NAME="MP3_Selection[]" MULTIPLE>
<?php
$NBFile=$NBFile-1;
for ($i=0; $i<=$NBFile; $i++) {
$file_Name1=$FileArray[$i];
?>
<OPTION><?php echo substr($file_Name1, 0, strlen($file_Name1)-4); ?></OPTION>
<?php } ?>
</SELECT>
<p style="margin-top: 10; margin-bottom: 0" align="center">
<input type="submit" value="Play Selection" name="Juky">
</p>
</form>

To play my mp3..
on the Play_MP3.php it looks like this:
$NBFile=0;
foreach($_POST['MP3_Selection'] as $name)
    {
        $FileArray[]=stripslashes(stripslashes($name)).".mp3";
    $NBFile=$NBFile+1;
    }
Somehow I couldn't associate the array directly to another.. but hey whatever works..

I hope that will help you :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
Problem reciving email Urgent marshad77 Apache Tomcat 1 July 24th, 2008 06:28 AM
check box problem Vince_421 Access VBA 3 March 1st, 2007 04:35 PM
Dynamic List Box Post Back Problem rstelma ASP.NET 1.0 and 1.1 Professional 12 March 2nd, 2006 05:55 PM
How to store check box values in php sessions? method PHP How-To 0 February 22nd, 2006 12:08 AM
help me to pass the check box values to new page ansar BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 0 November 16th, 2004 06:08 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.