You are here: Re: Using check box in table to select records « All PHP « IT news, forums, messages
Re: Using check box in table to select records

Posted by Steve on 10/08/05 23:56

> In QUESTION.PHP I have records displayed from a MySQL database table in an
> HTML table and a check box for each record as follows

> <input type="checkbox" name="checkbox[]" value="<? echo
> $QuestionNo?>"

> I also have a form and a button as follows, which is suposed to run
> FILTER.PHP

> <form name="form1" method=post action="Filter.php">
>
> <input type="submit" name="Submit" value="Submit">

First point, the <input /> fields should be declared INSIDE the <form>
so that when the submit button is clicked the current values of the
selected items are sent to your processing script. Declared outside, as
you show above, means that they are purely cosmetic rather than
functional.

> FILTER.PHP has the following SQL (which is obviously wrong). Basically I am
> not sure how to use the array from QUESTION.PHP to filter records in
> FILTER.PHP

> $filtered = @mysql_query("SELECT * FROM Questions WHERE QuestionNo IN ( " .
> join(",", $_REQUEST['$QUESTION_NOS_FROM_THE_ARRAY']) . " )";

Nearly there, but what is '$QUESTION_NOS_FROM_THE_ARRAY'? Instead of
that, modify Jeff's example to match your field name, 'checkbox[]':

> $filtered = @mysql_query("SELECT * FROM Questions WHERE QuestionNo IN ( " .
> join(",", $_REQUEST['checkbox']) . " )";

---
Steve

 

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

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