Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 How to give a field a default value
JimR Offline
Junior Member
**
Posts: 15
Joined: Jun 2012
Post: #1
How to give a field a default value
odd ask I know but how ever here it is
I want to add a default value to a thread field by way of a database query
an example

PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
$select=$db->query("select * from ".TABLE_PREFIX."threadfields_data where tid ='".$post['tid']."'");
$num_rows = $db->num_rows($select); //rows for the record only 1 or 0
// if no row format the address
switch ($num_rows){
	case 0:
		// no record add the default address to the collection address fields
		$GLOBALS['threadfields']['add1']['value'] == $sub.$build;
		break;
	case 1:
		// do nothing
		break;
}

the variables $sub & $build have already been defined and need to become the default.
Currently I am inculding a php file within the template which defines my variables however with this I get parse errors am I putting the code in the wrong place ... does it need to be placed in a plugin that calls a hook before xthreads ?

02-26-2013 05:11 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
How to give a field a default value - JimR - 02-26-2013 05:11 AM

 Standard Tools
Forum Jump: