473,387 Members | 1,669 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Problem in Else part

Hi,
Here is the script which i am working in this script i am trying to search some events for that i developed this .Its working but if there is no events means i want to display there is no event found like this in else part if i added like this

else
{
echo"No events found"
}

it wont consider that is else its displaying else part also from the begining so tell me in this script how to give else part.





<html>
<form name="form1" method="post" action="">
<p>&nbsp;</p>
<table width="200" border="0" align="center">
<tr>
<td>Select </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>';


$a = range(01,12);

//var_dump($a);

echo'<select name="month">';

foreach($a as $month)
{

echo'<option>'.$month.'</option>';

}

echo'</select>';
$a = range(2000,2010);

//var_dump($a);

echo'<select name="year">';

foreach($a as $year)
{

echo'<option>'.$year.'</option>';

}
echo'</select>';
?>&nbsp;</td>
</tr>
</table>
<p align="center">
<input type="submit" name="Submit" value="Submit">
</p>
<p align="center">&nbsp;</p>
<p align="center">&nbsp; </p> <br>
<table width="900" border="0" align="center">
<div align="center"><b>Search Details</b></div>
<tr bgcolor="#E1E1E1">
<td width="246">Events</td>
<td width="246">Countryname</td>
<td width="215">Date</td>
<td width="217">Month</td>
<td width="194">Year</td>
</tr>
<?PHP
include('connect.php');
if($_POST['Submit'])
{

$edit="select * from addevent where date='$_POST[date]' AND month='$_POST[month]'";
echo $edits=mysql_query($edit);
//$row = mysql_fetch_row($edits);
$number = mysql_num_rows($edits);
while ($rows=mysql_fetch_assoc($edits))
{
print "<tr bgcolor=\"#CCCCCC\">
<td bgcolor=\"#FFFFFF\">" . $rows['event'] ."</td>
<td bgcolor=\"#FFFFFF\">" .$rows['countryname'] ."</td>
<td bgcolor=\"#FFFFFF\">" .$rows['date'] . "</td>
<td bgcolor=\"#FFFFFF\">" .$rows['month'] . "</td>
<td bgcolor=\"#FFFFFF\">" . $rows['year'] . "</td>
</tr>";
}
echo"<B>Totally $number events are found</B><br>";
}
//var_dump(($_POST['date'])!=$edif['date']);
?>
</table>
<p>&nbsp;</p>
</form>
</html>
Jul 17 '07 #1
5 1479
hi

$edit="select * from addevent where date='$_POST[date]' AND month='$_POST[month]'";
echo $edits=mysql_query($edit);
$number = mysql_num_rows($edits);
if($number!=0) // here the number of rows returned by the query is checked //and then process is continued
{
while ($rows=mysql_fetch_assoc($edits))
{
print "<tr bgcolor=\"#CCCCCC\">
<td bgcolor=\"#FFFFFF\">" . $rows['event'] ."</td>
<td bgcolor=\"#FFFFFF\">" .$rows['countryname'] ."</td>
<td bgcolor=\"#FFFFFF\">" .$rows['date'] . "</td>
<td bgcolor=\"#FFFFFF\">" .$rows['month'] . "</td>
<td bgcolor=\"#FFFFFF\">" . $rows['year'] . "</td>
</tr>";
}
echo"<B>Totally $number events are found</B><br>";
}
else
echo"<B>No events are found</B><br>";

//var_dump(($_POST['date'])!=$edif['date']);
?>



Try this change and then come again if any doubts persists
Jul 17 '07 #2
if i give like wat u send it shows error but if i give
else
{
echo "no events found";
}

like this but its not working (else part is not working).can u tell me some other idea

thanks



hi

$edit="select * from addevent where date='$_POST[date]' AND month='$_POST[month]'";
echo $edits=mysql_query($edit);
$number = mysql_num_rows($edits);
if($number!=0) // here the number of rows returned by the query is checked //and then process is continued
{
while ($rows=mysql_fetch_assoc($edits))
{
print "<tr bgcolor=\"#CCCCCC\">
<td bgcolor=\"#FFFFFF\">" . $rows['event'] ."</td>
<td bgcolor=\"#FFFFFF\">" .$rows['countryname'] ."</td>
<td bgcolor=\"#FFFFFF\">" .$rows['date'] . "</td>
<td bgcolor=\"#FFFFFF\">" .$rows['month'] . "</td>
<td bgcolor=\"#FFFFFF\">" . $rows['year'] . "</td>
</tr>";
}
echo"<B>Totally $number events are found</B><br>";
}
else
echo"<B>No events are found</B><br>";

//var_dump(($_POST['date'])!=$edif['date']);
?>



Try this change and then come again if any doubts persists
Jul 17 '07 #3
dafodil
392 256MB
Hi,
Here is the script which i am working in this script i am trying to search some events for that i developed this .Its working but if there is no events means i want to display there is no event found like this in else part if i added like this

else
{
echo"No events found"
}

it wont consider that is else its displaying else part also from the begining so tell me in this script how to give else part.




...............
..............
How about replacing echo"<B>Totally $number events are found</B><br>";
with these:

If($number!=0){
echo"<B>Totally $number events are found</B><br>";}
else
{
echo"No events found";
}
Jul 17 '07 #4
Hi,
thank u
now my code is working with else part
How about replacing echo"<B>Totally $number events are found</B><br>";
with these:

If($number!=0){
echo"<B>Totally $number events are found</B><br>";}
else
{
echo"No events found";
}
Jul 17 '07 #5
Hi


Again i got the problem that is else part is working but if i give like this


if($total!=0)
{
echo"<B>Totally $total events are found</B><br>";
}
else
{
echo"<center><b>no events found</b>";
}

if i run the search script then it shows no events found (without clicking submit) button but after clicking submit button if there is no records then only i want to display no found pls help me how to do this.If i gave if($_POST['submit']) its working.How to give else part without using $_POST['submit']
help me
thanks

Hi,
thank u
now my code is working with else part
Jul 18 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Iain Bishop | last post by:
I'm trying to model objects for the following problem: A building site contains assemblies, each of which can contain other assemblies and/or materials. I have modelled this using a Site...
1
by: gerrymcc | last post by:
Hello, I hope it's okay to post to the three groups simultaneously. I've got a set of four applets, all of which use the same GUI, except for one change. I want to reuse the 100+ lines of setup...
8
by: babak | last post by:
Hi everyone I have a problem with Iterators and containers in STL that hopefully someone can help me with. This is what I try to do: I have an associative (map) container and I have a...
4
by: FBM | last post by:
Hi, I am working on a program that simulates one of the elements of ATM. The simulation stores events which occurs every some milliseconds for a certain amount of time. Every time that an event...
2
by: Chris H | last post by:
I am having a problem with pagination, basically the problem is happening in the "PREV / NUMBERS / NEXT" links, it appears as if the reason is becasue the increment and decrement operators aren't...
19
by: 叮叮当当 | last post by:
hi, all when a email body consist with multipart/alternative, i must know when the boundary ends to parse it, but the email lib have not provide some function to indicate the boundary end,...
2
by: cool17 | last post by:
#include "expression.h" #include <stdlib.h> #include <stdio.h> #include <string.h> xContainer splitTerm(string,int,int);
3
by: Rene | last post by:
Hello to all! For a long time I have been "fighting" a problem compiling an OpenGL program which uses GLUT. First I have put a question in a Watcom group (I want to use this compiler) to which I...
0
by: JohnK82 | last post by:
Hi guys I have a webcontrol that displays an article in multiple parts. You can jump back and forward between the parts (I call them sheets) by clicking on a label. Each sheet has a label. The...
18
omerbutt
by: omerbutt | last post by:
AJAX PROB WITH MULTIPLE RECORDS helo iam having problem in ma code will any body look out an help, i am trying t add sale record in the database and the checkthe quantity of the part slod and...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.