PHP Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me

The Shed is going Social! Join us on FaceBook and Twitter and chime in on the conversation.

Go Back   Dev Shed ForumsProgramming LanguagesPHP Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 1st, 2000, 12:39 AM
mouserdj mouserdj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 77 mouserdj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
I am currently working on a phonebook system whereby people can add their own names to the database. So I also have an edit facility. Within my form however I have 3 checkboxes. What I need to know is say someone clears their checkbox, how do I get that to clear the table field?? At the moment, if they de-select the field then it adds it doesn't change the field. Also note, i created a separate column for each of the checkbox fields (they are called roles1, roles2, and roles3). I have included my code for how I can tell if the box should be checked or not. Thanks for your help.

Dave

<?php
// Check Box 1
echo "<input type='checkbox' name='roles1' value='EH&S Representative' ";

if (ereg("EH&S Representative", $myrow[roles1]))
{
# if database field value =yes then

echo "checked";
}
printf (">EH&S Representative");

?>

Reply With Quote
  #2  
Old June 1st, 2000, 01:44 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
see ,,, you can find out wether user has selected the check box or not using isset() function

eg:

if (!isset(roles1)){
$roles1="Not Selected";
}

$result=mysql_query("UPDATE phonebook set roles1='$roles1'",$con);

------------------
SR -
shiju.dreamcenter.net

"The fear of the LORD is the beginning of knowledge..."

[This message has been edited by Shiju Rajan (edited June 01, 2000).]

Reply With Quote
  #3  
Old June 1st, 2000, 01:51 AM
mouserdj mouserdj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 77 mouserdj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Can you see any reason why the following script would not update my database when each of the field is past to it? I had it working earlier but have found now that nothing is being updated...

<?php

// setup database connection

$db = mysql_connect("localhost", "root");

// specify database to use

mysql_select_db("development",$db);

// specify query to use

mysql_query("UPDATE staff SET
fname = $fname,
sname = $sname,
location = $location,
dept = $dept,
report = $report,
btitle = $btitle,
phone_extension = $phone_extension,
phone_int = $phone_int,
phone_ext = $phone_ext,
fax = $fax,
phone_mob = $phone_mob,
alt_email = $alt_email,
roles1 = $roles1
roles2 = $roles2
roles3 = $roles3
WHERE fname=$fname AND sname=$sname");

print ("<font size='2' face='Frutiger, Verdana, Arial, Helvetica, sans-serif'>");
print ($fname);
echo $mysql_query;
print (" ");
print ($sname);
print ("<p>");
print ("Details have been added!");
print ("</font>");
?>

Reply With Quote
  #4  
Old June 1st, 2000, 03:50 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan
Query is wrong..you missed commas.


<<
roles1 = $roles1
roles2 = $roles2
roles3 = $roles3
WHERE fname=$fname AND sname=$sname


try this:


mysql_query("UPDATE staff SET
fname = $fname,
sname = $sname,
location = $location,
dept = $dept,
report = $report,
btitle = $btitle,
phone_extension = $phone_extension,
phone_int = $phone_int,
phone_ext = $phone_ext,
fax = $fax,
phone_mob = $phone_mob,
alt_email = $alt_email,
roles1 = $roles1,
roles2 = $roles2,
roles3 = $roles3,
WHERE fname=$fname AND sname=$sname");


------------------
SR -
shiju.dreamcenter.net

"The fear of the LORD is the beginning of knowledge..."



[This message has been edited by Shiju Rajan (edited June 01, 2000).]

Reply With Quote
  #5  
Old June 1st, 2000, 04:13 AM
pwluky pwluky is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 109 pwluky User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 14
If this doesn't work you must put all variables between parenthesis, like:

mysql_query("UPDATE staff SET
fname = '$fname',
sname = '$sname',
location = '$location',
.
.
.
roles1 = '$roles1',
roles2 = '$roles2',
roles3 = '$roles3',
WHERE fname='$fname' AND sname='$sname'");

[This message has been edited by pwluky (edited June 01, 2000).]

Reply With Quote
  #6  
Old June 1st, 2000, 04:33 AM
Shiju Rajan's Avatar
Shiju Rajan Shiju Rajan is offline
.Net Developer
Dev Shed Novice (500 - 999 posts)
 
Join Date: Feb 2000
Location: London
Posts: 987 Shiju Rajan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 3 h 26 m 22 sec
Reputation Power: 14
Send a message via MSN to Shiju Rajan Send a message via Yahoo to Shiju Rajan

If this doesn't work you must put all variables between parenthesis, like:


That is right. you should do that....

Reply With Quote
  #7  
Old June 1st, 2000, 07:14 PM
mouserdj mouserdj is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: May 2000
Posts: 77 mouserdj User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 13
Thanks guys, that worked the treat. I originally did have the single quotes but in my desperate attempt to sort out what was going on I took them out. All appears to be working perfectly now. Thanks again!

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming LanguagesPHP Development > Clearing checkbox property

Developer Shed Advertisers and Affiliates



Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 


Powered by: vBulletin Version 3.0.5
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

© 2003-2013 by Developer Shed. All rights reserved. DS Cluster - Follow our Sitemap