Hi,
How can I see changes made by admin in the client page?What exactly I want is that I have few events in admin side when admin selects any of them the selected event must be viewed in the client page..How can I do that...Any help?

Save the admin's selections in a database then load and display those events on the client's page when the client's page loads.

How can i do tht?Can i use Enum in my database?DB i use is 'MySQL'.

PHP doesn't support enumerations. Do you mean arrays? You would have to use the insert command to insert the values and select command to retrieve the values.

I used insert command..but i got an error.What eactly i want is in admin side i have few events and checkboxes.If i check those boxes the checked events shuld be displayed on the client page.so i worte my code like this

<form action="user.php" method="post">
<?php
$str="SELECT * FROM eventdesc ";

$res=mysql_query($str);

if(mysql_num_rows($res)!=0)
{
 
while($data=mysql_fetch_array($res,MYSQL_ASSOC))
{
 echo '<tr> <td>'.  $data['eventdesc'].'</td> <td> <input type="checkbox" name="chkbx[]" ></td></tr>';

}
}

mysql_close();
?>
<tr><td align="right"><input type="submit" Value="Display"></td></tr>

user.php

$str= foreach($_POST["chkbx"] AS $key => $value){
"INSERT INTO eventdesc(show) VALUES
('{$_POST["chkbx"][0]} {$_POST["chkbx"][1]} {$_POST["chkbx"][2]} {$_POST["chkbx"][3]} {$_POST["chkbx"][4]} {$_POST["chkbx"][5]} {$_POST["chkbx"][6]} {$_POST["chkbx"][7]} {$_POST["chkbx"][8]} {$_POST["chkbx"][9]} {$_POST["chkbx"][10]} {$_POST["chkbx"][11]} {$_POST["chkbx"][12]} {$_POST["chkbx"][13]} {$_POST["chkbx"][14]} {$_POST["chkbx"][15]} {$_POST["chkbx"][16]} {$_POST["chkbx"][17]} {$_POST["chkbx"][18]} {$_POST["chkbx"][19]} {$_POST["chkbx"][20]} {$_POST["chkbx"][21]} {$_POST["chkbx"][22]} {$_POST["chkbx"][23]} {$_POST["chkbx"][24]} {$_POST["chkbx"][25]} {$_POST["chkbx"][26]} {$_POST["chkbx"][27]} {$_POST["chkbx"][28]} {$_POST["chkbx"][29]} {$_POST["chkbx"][30]} {$_POST["chkbx"][31]}')");
}

$res=mysql_query($str);
if($res)
 echo 'Success';
else
 echo 'Failure';

mysql_close($con);
?>

And this is the error i got:
Parse error: syntax error, unexpected T_FOREACH in C:\Program Files\xampp\htdocs\exphp\user.php on line 6

What I must do now?

For loop is not a function and therefore does not return anything and thats why you are getting a syntax error. I am having a difficult time understanding your code though. On the admin form you are giving all the check boxes the same name which is 'chkbx[]'. Take a look at the html that your php is generating. If you want want to name your check boxes as chkbx0, chkbx1 and so on you have to explicitly do so. So try something like the following:

while($data=mysql_fetch_array($res,MYSQL_ASSOC))
{
 $i = 0;
 $chName= 'chkbx' . $i;

 echo '<tr> <td>'.  $data['eventdesc']. "</td> <td> <input type=\"checkbox\" name=\"$chName\" ></td></tr>";

 $i++;
}

And I really don't think that the second query you created will do what you want either. It wouldn't execute and if it did it would create a new row in table eventdesc and insert everything thats in the array chkbox (which doesn't really exist at this point) in a single cell called show. And it will do this step for every entry in array chkbox. Perhaps you want something like this:

for($i=0;$i<31;$i++) {
$value = $_POST[chkbx . $i];
$id = $_POST[id .$i]
 mysql_query(UPDATE eventdesc SET show='$value' WHERE id='$id');
}

Note: You don't seem to have an unique id field in your code. But I think you should.

I sincerely recommend that you study sql INSERT, DELETE, UPDATE, JOIN, UNIQUE KEY, FOREIGN KEY before making web pages that rely on databases. Otherwise, you will struggle a lot.

I have changed code as u have given...but nothing of use... :(

Here is user.php:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  <head>
    <title> first web page</title>
  </head>
  <body>
    <p>XHTML is easy!</p>

    <form method="post" action="./user.php">
	<?php
		for($x=0;$x<6;$x++) {
			$chName = 'chkbx' . $x;
			echo "\t<div><input type=\"checkbox\" name=\"$chName\" value=\"1\" /></div>\n";
		}
	?>
	<div><input type="submit" value="submit" name="postForm" /></div>
    </form>
   </body>
</html>

And here is user.php

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
  <head>
    <title> second web page</title>
  </head>
  <body>
    <p>PHP is easy!</p>

<?php
	if(isset($_POST['postForm'])) {
		for($x=0;$x<6;$x++) {
			if ($_POST[chkbx . $x] == '1') {
				echo "chkbx" . "$x " . "was checked <br />";
			}
		}
	}
?>
</body>
</html>

I am not using database but you can insert database code in here if you want to.

Is thr any other way to go on with this... Dono wht is wrong even this code is not working...

This article has been dead for over six months. Start a new discussion instead.