Jump to content

ERROR: Warning: Invalid argument supplied for foreach() ????


jigsawsoul

Recommended Posts

I'm using the below code below to check which checkboxes with selected in the last form page, when at least one is selected it works just fine but when none are selected i get the following error message display five times.

 

Warning: Invalid argument supplied for foreach() in /home/hr728/public_html/_web/_admin/meeting/test2.php on line 16

 

<?php

session_start();

include '../../_library/opendb.php';
include '../../_functions/login.php';
include '../../_functions/nav-admin.php';

$result = 	"SELECT * FROM web_staff
			LEFT JOIN web_login ON web_staff.login_id=web_login.login_id
			WHERE userlevel = '2' ORDER BY firstname ASC";

$result = mysql_query($result) or die( mysql_error() );
while($row = mysql_fetch_assoc($result)) 
{	
	foreach($_POST["selectedstaff"] as $staff_id) {

		if ( $staff_id == $row['staff_id'] ) {
			//do all this ;
			echo $staff_id;
		}
	}
}
?>

 

 

Link to comment
Share on other sites

i'm not sure how to do this, i tried this below but still not luck

<?php

session_start();

include '../../_library/opendb.php';
include '../../_functions/login.php';
include '../../_functions/nav-admin.php';

$result = 	"SELECT * FROM web_staff
			LEFT JOIN web_login ON web_staff.login_id=web_login.login_id
			WHERE userlevel = '2' ORDER BY firstname ASC";

$result = mysql_query($result) or die( mysql_error() );
while($row = mysql_fetch_assoc($result)) 
{	

	if (!=empty($_POST["selectedstaff"]) ){

		foreach($_POST["selectedstaff"] as $staff_id) {

		    if ( $staff_id == $row['staff_id'] ) {
		    	//do all this ;
		    	echo $staff_id;
		    }
		    
		}
	}
}
?>

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.