Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 Programming Discussions
FAQ Community Calendar Today's Posts Search

Reply
 
Thread Tools Display Modes
  #1  
Old 02-05-2002, 07:39 PM
Lesane's Avatar
Lesane Lesane is offline
 
Join Date: Oct 2001
Location: The Netherlands
Posts: 1,149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

I try to determine if a variable is set and if so then the checkbox is selected. I tried it with this code but it dont works, when i execute it then all the checkboxes are checked while only one field is filled with aw so 1 checkbox has 2 be checked instead of all

PHP Code:
$result mysql_query("SELECT aw,awardsid,name, url FROM award");
         while (
$award mysql_fetch_array($result)) {
         
         if (Isset(
$award[aw]))
         
$lala="checked";
         else
         
$lala="";
         
       echo 
"<tr><td><input type='checkbox' name='aw[$award[awardsid]]' value='$award[awardsid]'";
          if (
$aw) {
          echo 
"selected $lala>$award[name]</td><td nowrap>";
          } else {
          echo 
$lala>$award[name]</td><td nowrap>";
          }
       echo 
"<img src=\"$award[url]\">&nbsp;&nbsp;&nbsp;</td>";
     } 
As you can c, i'm using this code to check if its set or not:

PHP Code:
if (Isset($award[aw]))
         
$lala="checked";
         else
         
$lala=""

Hope someone can help me out, any help is appreciated.
Reply With Quote
  #2  
Old 02-05-2002, 09:49 PM
XiXora's Avatar
XiXora XiXora is offline
 
Join Date: Nov 2001
Location: Birmingham, UK
Posts: 37
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i've laready asked 5 times for this looks like we'll have to wait to v 3 to me
Reply With Quote
  #3  
Old 02-06-2002, 06:27 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Try this...
PHP Code:
$result mysql_query("SELECT aw,awardsid,name,url FROM award");
while (
$award mysql_fetch_array($result)) {
  if (
$award['aw']!='')
    
$checked='checked';
  else
    
$checked='';
         
  echo 
"<tr>
        <td>
        <input type=\"checkbox\" name=\"aw[
$award[awardsid]]\" value=\"$award[awardsid]\" $checked>
        
$award[name]
        </td>
        <td nowrap>
        <img src=\"
$award[url]\">&nbsp;&nbsp;&nbsp;
        </td>
        </tr>"
;

Reply With Quote
  #4  
Old 02-06-2002, 06:47 AM
Lesane's Avatar
Lesane Lesane is offline
 
Join Date: Oct 2001
Location: The Netherlands
Posts: 1,149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Thanks for the replies

@firefly, that didnt worked. I tried this code and it works now :up:

PHP Code:
$lesane=$award[aw];
          if(
$lesane == "$award[awardsid]") {         
         
$lala="checked";
         } else {
         
$lala="";
         } 
Now i'm almost done with the hack but i'm stuck when you uncheck a checkbox, then the row wont be updated. The variable is still in the database. Lets say i have a award called lesane and it has currently the variable 1 in the database, now i want to uncheck it and when i click on submit then lesane must be updated as empty. Hope u can follow me and can help me out with this
Reply With Quote
  #5  
Old 02-06-2002, 06:51 AM
Admin's Avatar
Admin Admin is offline
Coder
 
Join Date: Oct 2023
Location: Server
Posts: 1
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

You need to set a hidden field saying the field WAS there, and then in the parsing if the variable doesn't exists (=checkbox is not checked) remove the row.
Reply With Quote
  #6  
Old 02-06-2002, 07:02 AM
Lesane's Avatar
Lesane Lesane is offline
 
Join Date: Oct 2001
Location: The Netherlands
Posts: 1,149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Cool, thanks Firefly. I gonna test that out.

Be Right Back
Reply With Quote
  #7  
Old 02-06-2002, 09:06 AM
Lesane's Avatar
Lesane Lesane is offline
 
Join Date: Oct 2001
Location: The Netherlands
Posts: 1,149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

i'm going crazy

i'm using the following code:

PHP Code:
<?php

include("config.php");

if (isset(
$submitok)) {


if (
$delete) { 
foreach(
$delete as $val) {
$query "DELETE FROM award WHERE aw='$uid'"
$result mysql_query($query) or die("SELECT Error: " mysql_error() . " in Query: $miet"); 
 }
if(
$result) {
print (
"deleted");
} else {
print (
"not gedeleted");
}
}


    foreach(
$aw as $val) {
    
$lala="UPDATE award SET aw='$val' WHERE awardsid='$val[awardsid]'";
    
$result mysql_query($lala) or die("SELECT Error: " mysql_error() . " in Query: $query");
       }
if(
$result) {
print (
"updated");
} else {
print (
"not updated");
}

    }

else {


?>


<center>
<h3>Awards
<hr width="75%" color="#00AAFF">
</h3>
</center><br>
<form action="<?PHP $PHP_SELF ?>">
<table width="100%" cellspacing="0" cellpadding="5" border="1">
 <tr>
  <td>Awardsname</td>
  <td>Button</td>
 
 </tr> 

<?php

include("config.php");

$result mysql_query("SELECT aw,awardsid,name, url FROM award");
         while (
$award mysql_fetch_array($result)) {
         
$lesane=$award[aw];
          if(
$lesane == "$award[awardsid]") {         
         
$lala="checked";
         } else {
         
$lala="";
         }
         
       echo 
"<tr><td><input type='checkbox' name='aw[$award[awardsid]]' value='$award[awardsid]'";
          if (
$aw) {
          echo 
"selected $lala>$award[name]</td><td nowrap>";
          } else {
          echo 
$lala>$award[name]</td><td nowrap>";
          }
       echo 
"<img src=\"$award[url]\">&nbsp;&nbsp;&nbsp;</td>";
     
     if(!
$award[aw]) {
     
$uid="aw[$award[awardsid]]";
     } else {
     
$uid=""
     }
     } 
 echo 
"<br><tr><td colspan=2 align=center>";
 echo 
"<br><input type='hidden' name='delete[]' value='$uid'>";
echo 
"<br><br><input type='submit' name='submitok' value='Submit'>";
echo 
"</td></tr></table></form>";

    }
?>
I have currently 2 awards in the database

1. Awards name with the awardsid 9 and aw is also 9
2. Lesane with the awardsid 13 and aw is empty (means not checked)

So when i execute the script then i c awards name selected and lesane is not selected and if i check the code by <input type =hidden then i c:

<input type='hidden' name='delete[]' value='aw[13]'>

so thats right, lesane is not selected and have the id 13.

Now i'm totally confused because when i click on submit then it deletes lesane totally and when i uncheck the award with the name "awards name" then that aw is not gonna deleted because only the input type = hidden was lesane

So my questions are:

Whats the delete query to delete only the aw row from awards where awardsid=?
&
How is it possible to delete the aw row from the award called "Awards Name" when i uncheck him?


I hope u have a solution
Reply With Quote
  #8  
Old 02-06-2002, 09:51 AM
badr511 badr511 is offline
 
Join Date: Dec 2001
Location: asia
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

working now or not
Reply With Quote
  #9  
Old 02-06-2002, 10:07 AM
badr511 badr511 is offline
 
Join Date: Dec 2001
Location: asia
Posts: 6
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

firefly why ican't download attachment
Reply With Quote
  #10  
Old 02-06-2002, 10:15 AM
Lesane's Avatar
Lesane Lesane is offline
 
Join Date: Oct 2001
Location: The Netherlands
Posts: 1,149
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

No, its still not working.

When i try 2 unselect a checkbox and press on submit then he must delete the variable from that table :?:
Reply With Quote
Reply


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

Forum Jump


All times are GMT. The time now is 04:21 AM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2024, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04257 seconds
  • Memory Usage 2,294KB
  • Queries Executed 11 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (5)bbcode_php
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (1)pagenav
  • (1)pagenav_curpage
  • (1)pagenav_pagelink
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • pagenav_page
  • pagenav_complete
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete