Page 1 of 1

Drop Down: Per Page: Array Problem...

Posted: Tue Jan 20, 2004 10:42 pm
by johnsonnc
i am trying to create a drop down box for page views this the code i am trying to it with and it seems to work a side from this error:

Warning: Cannot use a scalar value as an array in /home/quickj2/public_html/tracq/devlopment/gui_ctl_http.php on line 119

Warning: Cannot use a scalar value as an array in /home/quickj2/public_html/tracq/devlopment/gui_ctl_http.php on line 134

Warning: Cannot use a scalar value as an array in /home/quickj2/public_html/tracq/devlopment/gui_ctl_http.php on line 135

Warning: Cannot use a scalar value as an array in /home/quickj2/public_html/tracq/devlopment/gui_ctl_http.php on line 136

Warning: Cannot use a scalar value as an array in /home/quickj2/public_html/tracq/devlopment/gui_ctl_http.php on line 137

Warning: Cannot use a scalar value as an array in /home/quickj2/public_html/tracq/devlopment/gui_ctl_http.php on line 138

here is the code:

Code: Select all

function create_dropdown($name,$item_array){
	echo "<select name ="$name">";
	foreach ($item_array as $key => $value)&#123;
	echo "<option value="$value">"$value"</option>";
	&#125;
	echo "</select>";
&#125;


// create per-page drop
if(empty($perpage)) &#123;
$perpage&#1111;0]= 5;
$perpage&#1111;1] = 10;
$perpage&#1111;2] = 15;
$perpage&#1111;3] = 25;
$perpage&#1111;4] = 50;
&#125;
else &#123;
switch ($perpage) &#123;
	case 5:
		$perpage&#1111;0] = 5;
	break;
	case 10:
		$perpage&#1111;0] = 10;
	break;
	case 15:
		$perpage&#1111;0] = 15;
	break;
	case 25:
		$perpage&#1111;0] = 25;
	break;
	case 50:
		$perpage&#1111;0] = 50;
	default:
		$perpage&#1111;0] = 5;
		break;
				&#125;

$perpage&#1111;1]= 5;
$perpage&#1111;2] = 10;
$perpage&#1111;3] = 15;
$perpage&#1111;4] = 25;
$perpage&#1111;5] = 50;
&#125;
create_dropdown("Per Page", $perpage);

thanx for help in advance...

Posted: Tue Jan 20, 2004 10:56 pm
by microthick
Make sure that $name has square brackets as part of the name.

like

options[]

or

skills[]

etc.

no go...

Posted: Tue Jan 20, 2004 11:06 pm
by johnsonnc
the error is @ 115 and beyond... the switch starts at line 114... sorry should have said that...
so it's really not even getting that far to have $name be a issue

Posted: Tue Jan 20, 2004 11:53 pm
by Gen-ik
Switch commands don't like int values.

This won't work...

Code: Select all

<?php

$value = 1;

switch($value)
{
    case 1:
        echo "one";
    break;
}

?>
This will work...

Code: Select all

<?php

$value = "1";

switch($value)
{
    case 1:
        echo "one";
    break;
}

?>
As far as I know you can't give switch() and array either, so if $perpage is an array when you give it to the switch() it won't know what to do with it.

tried that... nothin'

Posted: Wed Jan 21, 2004 10:41 am
by johnsonnc
ya i thought about that but that didn't work either gave me the exact same thing....