Hi,
In my script i used three script files like,
1.event_add.php(it consists 3 fields one is event,subject and last one is country)
2.event_main.php(it consists 3 fields one is event,subject and last one is country
3.event_view.php(it consists only one field that is subject)
First form i am adding some events to the database and then i created one form that is event_main.php in this whenever i am adding events its directly added into that main page(i-e event_main.php) so if i click this file then it will displays all records in the database.I gave link (event_view.php link)into events field in event_main.php file so if i click that event it will display subject for the particular event.using this concept i created my scripts first two scripts are working but if i click link which i gave in event_main.php (i-e event field) it goes to event_view.php but its not displaying the records.It shows blank page only(Its not taking the database value).(I am using the same code in another one script but thats working).If i give echo in front of this query
echo $edit1=”select subject from addevent where event =’$event'”; then it displays like this in browser
$edit1=”select subject from addevent where event =””;
and if i specified some field name like this
$edit1=”select subject from addevent where event =’deepavali”; then it displays subject for that particular event.
If i am adding these two lines in event_view.php
error_reporting(E_ALL);
ini_set(‘display_errors’, True);
Then it displays on notice like this
Notice: Undefined index: event in C:wampwwwadmineventevent_view.php on line 12
Here i pasted three scripts:
—————————————–add_event.php———————————-
<?PHP
include(‘connect.php’);
$date=$_POST[‘date’];
$month=$
$year=$_POST[‘year’];
$event=$
$country=$_POST[‘country’];
$sub=$
if(isset($_POST[‘submit’]) && $
{
$query=”insert into addevent values(‘$date’,’$month’,’$year’,’$event’,’$country’,’$sub’)”;
mysql_query($query);
echo “Events added”;
}
?>
<form action=”” method=”post”>
<table width=”304″ border=”0″ align=”center”>
<tr>
<td>Date</td>
<td><?php
//here can give any range, even a to z, jan to dec etc
$a = range(01,31);
//var_dump($a);
echo'<select name=”date”>’;
foreach($a as $date)
{
echo'<option>’.$date.'</option>’;
}
echo'</select>’;
?>
<?PHP
$b = range(01,12);
//var_dump($a);
echo'<select name=”month”>’;
foreach($b as $month)
{
echo'<option>’.$month.'</option>’;
}
echo'</select>’;
?>
<?PHP
$c = range(2000,2010);
//var_dump($a);
echo'<select name=”year”>’;
foreach($c as $yr)
{
echo'<option>’.$yr.'</option>’;
}
echo'</select>’;
?>
</td></tr>
<tr>
<td>Event</td>
<td><input type=”text” name=”event”></td>
</tr>
<tr>
<td>Countryname</td>
<td><input type=”text” name=”country”></td>
</tr>
<tr>
<td>Subject</td>
<td><textarea name=”subject”></textarea></td>
</tr>
<tr>
<td colspan=”2″><div align=”center”>
<input type=”submit” name=”submit” value=”Add”>
</div></td>
</tr>
</table>
</form>
————————————main_event.php————————————————-
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv=”Content-Type” content=”text/html; charset=iso-8859-1″>
</head>
<body>
<form name=”form1″ method=”post”>
<?php
include(‘connect.php’);
$sql=”SELECT * FROM addevent “;
// OREDER BY id DESC is order result by descending
$result=mysql_query($sql);
?>
<table width=”90%” border=”0″ align=”center” cellpadding=”3″ cellspacing=”1″ bgcolor=”#CCCCCC”>
<tr>
<div align=”center”>
<h1>List Of Events</h1>
</div>
</tr>
<tr>
<td width=”6%” align=”center” bgcolor=”#E6E6E6″><strong>Event</strong></td>
<td width=”6%” align=”center” bgcolor=”#E6E6E6″><strong>Country</strong></td>
<td width=”53%” align=”center” bgcolor=”#E6E6E6″><strong>Date</strong></td>
<td width=”15%” align=”center” bgcolor=”#E6E6E6″><strong>Month</strong></td>
<td width=”13%” align=”center” bgcolor=”#E6E6E6″><strong>Year</strong></td>
</tr>
<?php
while($rows=mysql_fetch_array($result))
{
// Start looping table row
?>
<td bgcolor=”#FFFFFF”> <a href=”event_view.php”><?php echo $rows[‘event’]; ?></a>
</td>
<td align=”left” bgcolor=”#FFFFFF”><?php echo $rows[‘countryname’]; ?></td>
<td align=”center” bgcolor=”#FFFFFF”><?php echo $rows[‘date’]; ?></td>
<td align=”center” bgcolor=”#FFFFFF”><?php echo $rows[‘month’]; ?></td>
<td align=”center” bgcolor=”#FFFFFF”><?php echo $rows[‘year’]; ?></td>
</tr>
<?php
// Exit looping and close connection
}
mysql_close();
?>
</table>
</form>
</body>
</html>
——————————————————event_view.php—————
<html>
<style type=”text/css”>
<!–
.style3 {color: #FFFFFF; font-weight: bold; }
–>
</style>
<form name=”form1″ method=”post” action=””>
<table width=”900″ border=”1″ align=”center”>
<tr bgcolor=”#666666″>
<td width=”246″><span class=”style3″>Subject</span></td>
</tr>
<?Php
include(‘connect.php’);
error_reporting(E_ALL);
ini_set(‘display_errors’, True);
$event=$_GET[‘event’];(error points this line only undifined index:event in C:wampwwwadmineventevent_view.php on line 12)
$edit1=”select subject from addevent where event =’$event'”;
echo $sql=mysql_query($edit1) or die(mysql_error());
$number = mysql_num_rows($sql);
//echo $numbe= mysql_fetch_row($sql);
//var_dump(mysql_num_rows($edits1));
while($editf=mysql_fetch_assoc($sql))
{
print “<tr bgcolor=”#CCCCCC”>
<td bgcolor=”#FFFFFF”>” .$editf[‘subject’] .”</td>
</tr>”;
}
?>
</table>
</form>
</html>
Thanks