MyBB Community Forums

Full Version: My first code -- NOOB
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey,

I've made a page myself with the functions I want. But as I am still learning PHP & MyBB codes I am unsure if my code is really clean..

I hope someone of you can tell me what I can do better or what I should improve. If you find any bugs or so, or know a better code, I would really appreciate it if you can give me advice how to make it better.

Please don't blame me for being messy, I tried my best to come with something and what actually works - but ye,, messy code

here is the source:
http://pastebin.com/CB5BEKtp

and here is the lil' jscript:

function DisplayTime(){
if (!document.all && !document.getElementById)
return
timeElement=document.getElementById? document.getElementById("curTime"): document.all.tick2
var CurrentDate=new Date()
var day=CurrentDate.getDate()
var month=CurrentDate.getMonth() + 1
var year=CurrentDate.getFullYear()
var hours=CurrentDate.getHours()
var minutes=CurrentDate.getMinutes()
var seconds=CurrentDate.getSeconds()
if (minutes<=9) minutes="0"+minutes;
if (seconds<=9) seconds="0"+seconds;
var currentDatum=day+"-"+month+"-"+year;
var currentTime=hours+":"+minutes+":"+seconds;
timeElement.innerHTML="<font style='font-size:12px;font-weight:bold;'>"+currentDatum+"&nbsp;&nbsp;"+currentTime+"</b>"
setTimeout("DisplayTime()",1000)
}
window.onload=DisplayTime

function validateForm(submit_notification)
{
	if (""==document.forms.submit_notification.item_title.value)
	{
		alert("You forget to enter a title..");
		document.forms.submit_notification.item_title.focus();
		return false;
	}
	else if (""==document.forms.submit_notification.item_summary.value)
	{
		alert("You forget to enter additional information..");
		document.submit_notification.item_summary.focus();
		return false;
	}
	else if ("0"==document.getElementById('item_status').value)
	{
		alert("Please choose a status..");
		document.submit_notification.item_status.focus();
		return false;
	}
	else if ("0"==document.getElementById('item_prefix').value)
	{
		alert("Please choose a prefix..");
		document.submit_notification.item_prefix.focus();
		return false;
	}
}

function CheckForm()
{
	if (""==document.forms.submit_update.update_summary.value)
	{
		alert("You forget to enter update text..");
		document.forms.submit_update.update_summary.focus();
		return false;
	}
	else if ("0"==document.getElementById('update_status').value)
	{
		alert("Please choose a status..");
		document.submit_update.update_status.focus();
		return false;
	}
}

Thanks in advance!!

Tankey
No one willing to post a small suggestion?Sad(
What is the table config of statuscenter_items??
Thanks for ur reply Smile

Ohh here is the link btw:
Click this first so it'll change to white theme: http://deltacommanders.com/forum/index.p...e&style=10
http://www.deltacommanders.com/forum/hier.php
NOTE: it's quite ugly on the black theme, I actually designed it for the white theme here:

The structure of it is:
`id` int(3) NOT NULL auto_increment,
  `item_summary` varchar(600) NOT NULL,
  `item_prefix` int(1) NOT NULL,
  `item_status` int(1) NOT NULL,
  `item_date` int(10) NOT NULL,
  `latest_update` int(10) NOT NULL,
  `by_uid` int(5) NOT NULL,
  PRIMARY KEY  (`id`)
bumb :$
Just released a new version, 1.3 which supports the edit of updates.

http://pastebin.com/fFZzEuFq

If someone is interested in this one, please let me know by posting here so I'll give the structures of all 3 the tables.
Quick question, is this plugin for personal use only? otherwise i would try to do the mailing part differently. With all the links of your site etc. Also try to use the update query i will copy something somebody else ones showed me is really usefull Smile

 update_query($table, $array, $where="", $limit="", $no_quote=false) 

Works much easier then having the update sql.

Then again i am not a great programmar but keep up the good work, always nice to have new people writing plugins.
Hey,

Thanks for your advice!!

Well basically I'm thinking about making a MyBB plugin for this, but it's quite hard I found out as I'm not sure yet what is possible and what is not. So atm i've created it for personal use only.

If others want to use it, they can easily change their link, as the rest is basically the same.

Again, thanks for your advice, I'll implant it later Wink!