Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Checkbox Confusion - totally confused....
Old 07-15-2005, 08:30 PM Checkbox Confusion - totally confused....
Junior Talker

Posts: 1
Trades: 0
I have a form that has a number of checkboxes. Upon initial submission, the values of the checked boxes are stored as one variable via "implode" and placed into my database.

In an effort to make the form editable (that is, a user can select/deselect boxes as they wish) , I've been trying to place "checked" inside the input tag for the values that are actually in the database.

But, I can't figure out how to check to see if that particular item is in the database... I've pasted the code below and indicated where I'm having a problem.

PHP Code:

$array 
= array('Milk''Eggs''Bread''Lettuce' 'Cookies');

   
$query "SELECT * FROM qtable WHERE id='$did'";
   
$result = @mysql_query ($query);
 
   while(
$row=mysql_fetch_array($result)) {
   
$item=$row['items']; 
   
$brd=$row['brand'];
   
$st=$row['store'];
   } 

foreach (
$array as $item) {

    if ( 
$item is in database)  // THIS IS WHERE I'M STUCK
         
$chk 'checked';
    else
         
$chk '';
    echo 
"<input type='checkbox' name='$item' value='1' $chk$item<br>";


Last edited by jjfletch; 07-16-2005 at 02:07 PM.. Reason: stuck on another part...
jjfletch is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-16-2005, 06:08 PM
feraira's Avatar
BeTheBand!

Posts: 350
Trades: 0
This might help a little bit:
PHP Code:
if ( select from ?? where item "$item") {

$chk "1";

} else {

$chk "0";
}

echo(
"....... value="$chk".. "); 
feraira is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Checkbox Confusion - totally confused....
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.12372 seconds with 12 queries