PHP Help

kbjradmin

New Member
Messages
512
Reaction score
2
Points
0
i am writing a script that will make someone able to easily created an html format resume; so i have blocks that represent different parts of a resume and you just piece it together. i'm making a block to create a one or two column list (depending on the length) of items. for some reason, its not working.

here's the code:
PHP:
// sets two column list for resume
function resumeList($items){
$minItems = 4;            # any list containing this many or less items will be one column
if ( count($items) <= $minItems ){
$code = '<div class="itemlist">';
for ($i = 1, $i <= count($items)-1, $i++){
$code = $code.'<p>'.$items[$i].'</p>'."\n";
}
$code = $code.'</div>';
}
else{
$numItemsHalf = count($items) / 2;
$code1 = '<div class="itemlist">';
for ($i = 1, $i <= $numItemsHalf-1, $i++){
$code1 = $code1.'<p>'.$items[$i].'</p>'."\n";
}
$code1 = $code1.'</div>';
}
$code2 = '<div class="itemlist">';
for ($i = $numItemsHalf, $i <= count($items)-1, $i++){
$code2 = $code2.'<p>'.$items[$i].'</p>'."\n";
}
$code2 = $code2.'</div>';
}
$code = $code1."\n".$code2;
}
return $code;
}

please help.
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
try
PHP:
<?php

// sets two column list for resume
function resumeList($items)
{
	$minItems = 4;            # any list containing this many or less items will be one column
	if (count($items)<=$minItems)
	{
		$code = '<div class="itemlist">';
		for ($i=1;$i<count($items);$i++)
		{
			$code = $code.'<p>'.$items[$i].'</p>'."\n";
		}
		$code = $code.'</div>';
	}
	else
	{
		$numItemsHalf = count($items) / 2;
		$code1 = '<div class="itemlist">';
		for ($i = 1;$i<$numItemsHalf;$i++)
		{
			$code1 = $code1.'<p>'.$items[$i].'</p>'."\n";
		}
		$code1 = $code1.'</div>';
	}
	$code2 = '<div class="itemlist">';
	for ($i=$numItemsHalf;$i<count($items);$i++)
	{
		$code2 = $code2.'<p>'.$items[$i].'</p>'."\n";
	}
	$code2 = $code2.'</div>';

	$code = $code1."\n".$code2;
	return $code;

}

?>
couple things that were wrong. 1, you had two extra closing brackets, and your for() syntax was incorrect. you're supposed to use ; instead of , ;)
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
no problem. if you're using notepad, try using something that checks your syntax and highlights the code for you. makes finding errors much easier ;)

i personally use zend studio 5.5, but eclipse or aptana works just as fine :)
 

kbjradmin

New Member
Messages
512
Reaction score
2
Points
0
i'm using SciTE. ok, now i have another problem. maybe the problem is just that i've been staring at a computer screen all day and can barely think. whats wrong with this code (other than the fact that its a jumbled mess):

PHP:
// sets resume code
$resumeCode = '<div id="resume">'.category('Education').resumeEdu('Clark College','Vancouver, Wa','Associates in Applied Technology','To Be Completed: June 2009'.category('Major College Courses').resumeList(array('Intro To Programming','Intro To Unix','Calculus I')).category('Skills').resumeList(array('Microsoft Office 2003/2007','XHTML 1.0, CSS','PHP','Python','Logical Problem Solving','Studied Basic Quantum Computing','Windows XP / Vista / DOS (also 95 and 98)','Debian Linux (can use VI)','Unix Shell Scripting','Higher Level Mathematics','Website Administration','Currently Studying Perl')).category('Experience').resumeExp('Webmaster','','','Designed and coded personal portfolio site. Used XHTML, CSS, and PHP. Site validated for XHTML Transitional 1.0 and CSS Level 2.1.').'</div>';

again, thank you.
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
you are missing the closing bracket on resumeEdu( ;)

PHP:
<?php

// sets resume code
$resumeCode = '<div id="resume">'.

category('Education').
resumeEdu('Clark College',
	'Vancouver, Wa',
	'Associates in Applied Technology',
	'To Be Completed: June 2009'
).

category('Major College Courses').
resumeList(
	array('Intro To Programming',
		'Intro To Unix',
		'Calculus I')
	).
	
category('Skills').
resumeList(
	array('Microsoft Office 2003/2007',
		'XHTML 1.0, CSS',
		'PHP',
		'Python',
		'Logical Problem Solving',
		'Studied Basic Quantum Computing',
		'Windows XP / Vista / DOS (also 95 and 98)',
		'Debian Linux (can use VI)',
		'Unix Shell Scripting',
		'Higher Level Mathematics',
		'Website Administration',
		'Currently Studying Perl'
	)
).

category('Experience').
resumeExp('Webmaster',
	'',
	'',
	'Designed and coded personal portfolio site. Used XHTML, CSS, and PHP. Site validated for XHTML Transitional 1.0 and CSS Level 2.1.'
).
'</div>';

?>
 
Last edited:

kbjradmin

New Member
Messages
512
Reaction score
2
Points
0
thank you again.
i would give you rep, but you are already the last person i gave rep to, so it won't let me.
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
:'( just dont' forget once you rep someone else ;)

time for bed :wavey::sleep:
 
Last edited:

kbjradmin

New Member
Messages
512
Reaction score
2
Points
0
wait... its still not working.
please help... again. :happysad:
 

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
check the code that that's being parsed into (if it's not on here already). if it doesn't get solved by tomorrow, i'll take a look at it then

i've gotta get some sleep

night
 
Last edited:

xPlozion

New Member
Messages
868
Reaction score
1
Points
0
are you getting an error? what error are you getting?

if you're not getting an error, try debugging it by using var_dump($var); to output the string to make sure that it's in the proper format to work w/ your script :)
 

kbjradmin

New Member
Messages
512
Reaction score
2
Points
0
no, there's no error.

var_dump() resulted in a NULL value being displayed.

now i'm really confused, because i know that there is something in there.



ok, here is the full code for it.

resume.php
HTML:
<?php
$id = 2;        # unique page id number
include('resumeconfig.php;');
var_dump($resumeCode);
include('config.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">

<head>

<!--Data Tags-->
<title><?php echo $pageTitle[0].$pageTitle[$id]; ?></title>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="Author" content="James Brumond" />

<!--Includes-->
<link rel="shortcut icon" href="media/favicon.ico" />
<link rel="stylesheet" href="style.css" />
<!--[if IE]><link rel="stylesheet" href="ie.css" /><![endif]-->

</head>

<body>

<script language="javascript" type="text/javascript" src="maindiv.js"></script><!--Open Centered DIV Tag-->

<?php
echo $headCode;
echo $menuCode;
?>

<div id="content">
<?php echo $resumeCode; ?>
</div>

<?php echo $footCode; ?>

<script language="javascript" type="text/javascript" src="close.js"></script><!--Close Centered DIV Tag-->

</body>

</html>



PHP:
<?php



// sets category code block for resume
function resumeCategory($title){
	$code = '<div class="category"><h1>'.$title.'</h1><hr /></div>';
	return $code;
}



// sets education code block for resume
function resumeEdu($school,$loc,$degree,$date){
	$code = '<div class="eduBlock"><p>'.$school.' '.$loc.'<br />'.$degree.'<br />'.$date.'</p></div>';
	return $code;
}



// sets two column list for resume
function resumeList($items){
	$minItems = 4;			# any list containing this many or less items will be one column
	if ( count($items) <= $minItems ){
		$code = '<div class="itemlist">';
		for ($i = 0; $i <= count($items); $i++){
			$code = $code.'<p>'.$items[$i].'</p>'."\n";
		}
		$code = $code.'</div>';
	}
	else{
		$numItemsHalf = count($items) / 2;
		$code1 = '<div class="itemlist1">';
		for ($i = 0; $i <= $numItemsHalf-1; $i++){
			$code1 = $code1.'<p>'.$items[$i].'</p>'."\n";
			$code1 = $code1.'</div>';
		}
		$code2 = '<div class="itemlist2">';
		for ($i = $numItemsHalf; $i <= count($items); $i++){
			$code2 = $code2.'<p>'.$items[$i].'</p>'."\n";
			$code2 = $code2.'</div>';
		}
		$code = '<div class="compoundList">'.$code1."\n".$code2.'</div>';
	}
	return $code;
}



// sets experience block for resume
function resumeExp($title,$compName,$date,$desc){
	$code = '<div class="exp"><h1>'.$title.'</h1><h2>'.$compName.'</h2><h3>'.$date.'</h3><p>'.$desc.'</p></div>';
	return $code;
}



//*
// sets resume code
$resumeCode = '<div id="resume">'.
category('Education').
resumeEdu('Clark College','Vancouver, Wa','Associates in Applied Technology','To Be Completed: June 2009').
category('Major College Courses').
resumeList(array('Intro To Programming','Intro To Unix','Calculus I')).
category('Skills').
resumeList(array('Microsoft Office 2003/2007','XHTML 1.0, CSS','PHP','Python','Logical Problem Solving','Studied Basic Quantum Computing','Windows XP / Vista / DOS (also 95 and 98)','Debian Linux (can use VI)','Unix Shell Scripting','Higher Level Mathematics','Website Administration','Currently Studying Perl')).
category('Experience').
resumeExp('Webmaster','','','Designed and coded personal portfolio site. Used XHTML, CSS, and PHP. Site validated for XHTML Transitional 1.0 and CSS Level 2.1.').
'</div>';
//*/



?>
 
Last edited:
Top