vb.org Archive

vb.org Archive (https://vborg.vbsupport.ru/index.php)
-   vB3 Programming Discussions (https://vborg.vbsupport.ru/forumdisplay.php?f=15)
-   -   Trouble with custom select field (https://vborg.vbsupport.ru/showthread.php?t=147833)

Antivirus 05-22-2007 02:27 AM

Trouble with custom select field
 
I've created an array for my dropdown select field (in AdminCP) based on unique fields in a table like so:

PHP Code:

$dbdmas $db->query_read("SELECT DISTINCT dmaname_clean, rank FROM " TABLE_PREFIX "dma ORDER BY dmaname_clean");

$dmas[0] = 'None Selected';
while (
$dma $db->fetch_array($dbdmas))
{
     
$dmas[$dma['rank']] = $dma['dmaname_clean'] . " (" $dma['rank'] . ")";




As you can see, I added the 'None Selected' to the beginning of the array, and it shows as first value in the select field, however my problem is that when I select the value of 'None Selected', and save it, it inserts the value of '0' into the database. I want it to enter a blank value or NULL instead.


My code in AdminCP which is using the select menu is as follows:
PHP Code:

print_select_row($vbphrase['task_filter_dma'], $dmas$taskft_dmanamearray0101); 


The field in the table allows NULL values. Anyone know what my problem is please?

Eikinskjaldi 05-22-2007 02:54 AM

its pretty much impossible to help you when you don't show your saving-to-the-database code. You have basically shown us all everything except the code of interest. :erm:

Adrian Schneider 05-22-2007 04:31 AM

Use
PHP Code:

$dmas[''] = 'None Selected'

instead, before saving to the DB, set it NULL (not quoted) , or if 0, remove that column from your query so it falls back on the default (empty string or NULL).

Antivirus 05-22-2007 02:43 PM

(doh) i could swear i tried that already but i must have been mistaken, as that certainly works for me. Thanks again SirAdrian.


All times are GMT. The time now is 01:07 AM.

Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.

X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.00939 seconds
  • Memory Usage 1,719KB
  • Queries Executed 10 (?)
More Information
Template Usage:
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (3)bbcode_php_printable
  • (1)footer
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (6)option
  • (1)post_thanks_navbar_search
  • (1)printthread
  • (4)printthreadbit
  • (1)spacer_close
  • (1)spacer_open 

Phrase Groups Available:
  • global
  • postbit
  • showthread
Included Files:
  • ./printthread.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/class_bbcode_alt.php
  • ./includes/class_bbcode.php
  • ./includes/functions_bigthree.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
  • printthread_start
  • bbcode_fetch_tags
  • bbcode_create
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • printthread_post
  • printthread_complete