469,148 Members | 1,383 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,148 developers. It's quick & easy.

text comparison

Hi, I'm having a problem with one query. My database has the following
fields: id(int), time(int), and groupfield(enum - 5 possibilities). I
want to select all the rows where the time is between let's say 12 and
24 and the group is specified by the user using a html drop list. The
variable is named $group. Please help me to write that query. Thanx in
advance. Here's some part of the code for convenience:

<?php
if($group != "" && $group != "nic")
{
$link=mysql_pconnect("localhost", "t00c00l", "") or die ("cannot
connect");
mysql_select_db ("t00c00l_uk_db") or die ("Problem w/ database");
// and below is my problem... how to add the condition about the
right group
$query2="SELECT * FROM pareto WHERE (time<=24 && time>12)";
$result2=mysql_query("$query2") or die ("No luck this time");
$array[]= mysql_num_rows($result2);
mysql_free_result($result2);

mysql_close($link);
}
else
{
?>

<form action="<? echo $PHP_SELF; ?>" method="post">
<BR><BR><BR>
GRUPA: <BR>
<select name="group">
<option selected value="nic">-----
<option value="aaa">aaa
<option value="bbb">bbb
<option value="ccc">ccc
<option value="ddd">ddd
<option value="eee">eee
<option value="fff">fff
</select>
<input type="submit" value="GO">
</form>
<?
}
?>
Jul 20 '05 #1
1 1967
sks
Something simple like

select * from table where time >= 12 and time <= 24 and group=XXX

Hi, I'm having a problem with one query. My database has the following
fields: id(int), time(int), and groupfield(enum - 5 possibilities). I
want to select all the rows where the time is between let's say 12 and
24 and the group is specified by the user using a html drop list. The
variable is named $group. Please help me to write that query. Thanx in
advance. Here's some part of the code for convenience:

<?php
if($group != "" && $group != "nic")
{
$link=mysql_pconnect("localhost", "t00c00l", "") or die ("cannot
connect");
mysql_select_db ("t00c00l_uk_db") or die ("Problem w/ database");
// and below is my problem... how to add the condition about the
right group
$query2="SELECT * FROM pareto WHERE (time<=24 && time>12)";
$result2=mysql_query("$query2") or die ("No luck this time");
$array[]= mysql_num_rows($result2);
mysql_free_result($result2);

mysql_close($link);
}
else
{
?>

<form action="<? echo $PHP_SELF; ?>" method="post">
<BR><BR><BR>
GRUPA: <BR>
<select name="group">
<option selected value="nic">-----
<option value="aaa">aaa
<option value="bbb">bbb
<option value="ccc">ccc
<option value="ddd">ddd
<option value="eee">eee
<option value="fff">fff
</select>
<input type="submit" value="GO">
</form>
<?
}
?>

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Indra Heckenbach | last post: by
37 posts views Thread by spam.noam | last post: by
25 posts views Thread by electrixnow | last post: by
8 posts views Thread by John | last post: by
8 posts views Thread by addoty | last post: by
2 posts views Thread by Justin Fancy | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Mortomer39 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.