You are here: Re: checkbox + columns « PHP SQL « IT news, forums, messages
Re: checkbox + columns

Posted by strawberry on 05/19/06 18:34

This seems to work...

<?php

include('path/to/connection/script'); //Connection Script

$table="table_name"; //Your table
$field= $_POST['FIELD']; //The fields submitted by the form below

if ($field)
{
$fields = implode($field, ","); //Proabably too crude but works for
now
$query = "SELECT $fields FROM $table;"; //The resulting query
$result = mysql_query($query) or die ("Couldn't execute query.");
while ($row = mysql_fetch_array($result,MYSQL_ASSOC))
{
echo $row[$fields]; //Show the results
}
}

?>
//The 'values' and 'Checkbox descriptions' below could both be
dynamically generated but,
//in any event, the 'values' must match your table's column names.
<FORM METHOD="POST" ACTION="<?=$self?>">
<INPUT TYPE=checkbox NAME=FIELD[] value=field1>Checkbox 1<br>
<INPUT TYPE=checkbox NAME=FIELD[] value=field2>Checkbox 2<br>
<INPUT TYPE=checkbox NAME=FIELD[] value=field3>Checkbox 3<br>
<INPUT TYPE="submit" NAME="submit">
</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

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