Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




How Do You Select All Records After Today?


I want to select records from the database using: PHP Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
All Records From Today Using Time()
I have the date stored using time () which produces an 11 digit long number which is then stored in the database as an 11 digit integer in an "int" field. I'm just trying to work out how I can find all records from today according to their int time value.

How Do You Select All Records In The Month You Are In?
I have records in the database - one of the fields is a date field. I want to select all records in the database that are in the month I am in.

For example, if it is the 12th September 2002 today and I go to the page then it selects all records from September 2002. If it is the 4th June it selects all records in June etc.

Copy Select Records To New Table
In the table Step I have multiple records for each given id. I want to save the current list of records for an id to a new Step_Old table so I can look back at what I had at a given point in time, since the records for an id in the Step table will change over time.

Now the question... does anyone have a slick way to do this, or do I need to Select all the records I want to save and then save them one by one with a while loop into the Step_Old table?

How To SELECT Records WHERE Field Contains A Particular String?
I need to SELECT records WHERE a string matches the content of a field...

eg. I have field values like:

Phone namePhone name pinkPhone name bluePhone name polka-dot
What I want is to have a MySQL query which selects ALL records which match the search term, eg. 'Phone name' returns all of the above, but not 'Phone':

Currently my query looks like this:
SELECT * FROM [table_name] WHERE [field_name] LIKE '%s' ORDER BY [value] ASC

Very Slow MySQL SELECT Query After 11 Records
I have a very weird problem

I moved my database to new IIS 6.0 + PHP 4.3 + MySQL 4.0 setup. I tried to check with myphpadmin if everything works fine, but I couldn't browse my table (125 records). I used SELECT option and found out that SELECT query up to 11 records is ok, but after that, even if I choose to limit query to 12 records, it just hangs.
I tried selecting from the beginning of the table and from the middle - same thing, but when I run query localy on mysql console, everything works fine

Select Distinct Records Within 2 Separate Tables
I have 2 tables -
1) - paid counties
2) - free counties

and I want to search both to find a distinct list of the counties used. Is there a way to search the first list (save the data into an array), then add ONLY the distinct counties from the free table into the array. Then read all the data out of the array sorted by CountyName,CountyID.

Displaying Priorty Records And Normal Records In The One Dataset.
I have a page which displays the records from the database and uses paging to display the records in groupes of 10 per page.

I now want to be able to show results depending on the database field (display) in the database (can be set to either "full" or "limited"). If the record and the field display is equal to "full" i want to then display this record at the top of the record set and display all the fields.

If the record is equal to "limited" i want to display different results and they must show after all the records which are equal to "full". I can't output two different recordsets as i use paging and only want to show 10 records per page. Code:

Looping Until Today
I want to loop through dates, stopping at the current date

I set the enddate like this
$enddate=date('Y-m-d');

which prints out as ��-04-01'

$l['cc_startdate'] comes from a DB with the column in date format

but when i do
for ($dl=$l['cc_startdate'];$dl < $enddate;$dl++)
{
print $dl;
blah

}

Today / Yesterday
What I am trying to do is show todays date as today and yesterdays date as yesterday. for example:

if ($row['postdate'] = date('Y-m-d') {
echo "Today";
} else if { ($row['postdate'] = date('Y-m-(d-1')[not sure of proper code yet still learning]);
echo "Yesterday";
} else {
echo $row['postdate'];
}

Record From Today 0 Time ()
I have the date stored using time () which produces an 11 digit long number which is then stored in the database as an 11 digit integer in an "int" field.

I'm just trying to work out how I can find all records from today according to their int time value.

Today, Yesterday And Tomorrow
OK, have a problem with setting variables that will change automatically for $today, $tomorrow and $yesterday....when I do a search by a MySQL date (20011008) it works, but I have tried multiple ways to set those variables, with no luck.

I either need help solving this problem, OR.....is there a way to simply go by NOW and use items before and after now? That would be a workaround that I could manage.

I Can Get Today In A Number Variable Out Of 365?
Is there a way I can get today in a number variable out of 365?

I'm not sure if that makes sense, so example:

January 1 would be 1

December 31 would be 365...

Get All Entries From Today (mysql)
I currently have a page that each time a user visits it, the pageid and timestamp is thrown into a mysql daabase.

so the database looks like so:
linkid time
3 2007-08-22 17:26:21
3 2007-08-20 17:26:21
3 2007-08-22 18:36:59
2 2007-08-22 18:37:21

What i need is for php to show the total amount of visits today as per a certain time zone (or if thats not possible, the past 24 hours)

soo..
Search for all occurrences where linkid = 3 today for a specific timezone (or 24 hours)

MORE SPECIFICALLY
User 1: Lives in New York (EST -5)
registers for my site and sends visitors to his linkid (3)

After two days, this is what the mysql table looks like:
linkid time
3 -=- 2007-08-22 17:26:21
3 -=- 2007-08-20 17:26:21
3 -=- 2007-08-22 18:36:59

But mysql time isn't Eastern time, its another timezone. So when a visitor comes to user1's page at 3pm EST, mysql registers the time as 2007-08-22 17:26:21

So... I want to first add/subtract the number of numbers in the mysql database depending upon the user, and then see the amount of visitors for the day.

Checking TimeStamp Against Today
How can I check if a date/time unix timestamp in the format of:

$mytime = "1186439997";

Is within 5 days of the current unix timestamp? Basically I need to check if the passed in timestamp was generated within 5 days of today?

How To Figure Out If Today Is 1st, 2nd, 3rd Thurs Of The Month?
My brain is frozen on a convenient way to figure out if today is the
1st, 2nd, 3rd, 4th, or last Thursday of the month. Basically I need
something that will figure this out for any given day for any given month.

date() has everything BUT a 0-5 return for this.



Today.php Test Error. HTTP Headers
Trying to install on xp pro with IIS. Have mysql working. I tested it with the tutorial for installing from this forum.

When I open the test script, today.php I get
"The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are"' and theres is nothing after that but a black page.

The today.php consists of

<HTML><HEAD><TITLE>Today's Date</TITLE></HEAD><BODY><P>Today's Date (according to this Web server) is<?php
echo( date("l, F dS Y.") );
?></BODY></HTML>

Ive been over and over the php.ini and my.ini and cant figure it out.

PHP Scripts To Diplay Items From XYZ Date Til Today
I'm trying to work out the SQL command script to display all items from a fixed time period til the current date.

Something like...

$sql_query = "SELECT * FROM mytable WHERE dateAdded like 'todays date - 60 days'";

MySQL Dont Show Older Than Today
I'm making a database for upcoming shows. so, what I wonder now, is there a way to show only upcoming shows, and just exclude the shows older than todays date? what I've got atm is: Code:

Expired Article - Comparing Today To Expire Date
On my front page I have a list of articles that are pulled from my database. I have just added a column (expires) to the db in order to remove outdated articles.

I'd like to compare today's date to the expires date in my WHERE statement to exlude all articles where the expires date is older than today. But I'm at a loss right now on getting it to work.

Sort Results By Date/time, Limit 5 Database Entries Of Today &/or Upcoming Days
I'm designing a website for my fraternity and in the database I have entries which contain past events, todays events, and upcoming events.  My problem is that I can not figure out how to sort the query results to display:
 
1) only past events based on the CURRENT DATE
2) only the events which fall on the CURRENT DATE or after, limiting the results to 5 entries
3) all events that fall on CURRENT DATE or afterwards

Example:   
Today is  September 15, 2007

Problem 1) Displaying all events that happened before September 15, 2007
Problem 2) Displaying only 5 results that fall on September 15, 2007 or after
Problem 3) Displaying all events that are happening on or after September 15, 2007

And obviously I would like the CURRENT DATE to change depending on what date it is, currently.

Ok so now I've been very redundant in my explanation of my problem here is the code and a link to what that particular page looks like. Code:

Multiple Select From Listbox And Execute A Sql Query Select Statement
Supposing i have a html form with 2 listbox and i name it status and resolution.

So it goes <select name='status[]'>... <select name='resolution[]'>

Then i have a another php page.
$status = $_POST['status'];
$resolution = $_POST['resolution'];

Now my question is, how do i do the sql query statement?

mysql_query("SELECT * from bugs where status=$status and resolution=$resolution");

The problem is, i select 3 options form the status listbox eg. new, closed, duplicate. And from the resolution, i chose fixed, invalid.

SELECT Error: No Database Selectedin Query: SELECT * FROM Schedule
I got the above error message after reading FAQ #10 which applied to my first error. The thing is, I thought I had selected a database. This script is copied from a tutorial, and I'm just too new at this to spot my error. PHP Code:

Check Date From Input Must Greater Or Equal Today Date?
I have 3 select box. Code:

<select name="day">
<option value="1">1</option>
<option value="2">2</option>
.......
<option value="31">31</option>
</select>

<select name="month">
<option value="01"> Jan </option>
<option value="02"> Feb </option>
.....
</select>

<select name="year">
<option value="2002">2002 </option>
<option value="2003">2003</option>
</select>

When I select and click submit in form. I will have 3 variable :

$day, $month and $year

How can I check the day that I choose in form must equal or greater than today date? If it less than today date. I must print error message to user.

Script For "updated Today" Blogroll?
Hi all - I'm new to PHP and I'm trying to make a page of blog links that show (1) the most recent posts for each blog, and (2) whether that blog was updated recently.

I am happy to say I've accomplished objective #1 by using the magpie XML parser, and I now have a php page that links to the most recent blog posts from several blogs.

My issue is with objective #2. I've seen some scripts that create blogrolls using blo.gs to show recency, but I don't want a whole blogroll - I just want a simple script that says something like "if the blog was updated today, do this, otherwise, do that".

Is anyone familiar with such a script? Or do people have other ideas of how to do this?

Select Statement - Select Random ID #
I have made up a page that pull info on 13 branches of stores onto one main page. It's basically there to display all the branches on one page... then you click on the one you're interested in and then you go to a more detailed page.

Back to the main page. On the top, there's kind of a featured branch that has a bigger picture and bigger title but it's still getting pul pulled from the same table etc etc etc.

In order for me to avoid favortism to one branch (and for other branches to start complaining) I want to ramdomized the order every time someone came to page but I have no idea how.

right now I have a super simple select statement.

DNS Records
Hey everyone, I'm trying to get a DNS record of an IP using PHP's checkdnsrr() and getmxrr(). I used

echo checkdnsrr($REMOTE_ADDR);

and

echo getmxrr($REMOTE_ADDR);

but I receive an error that the PHP build does not support it, but I am using PHP 4.0.5 and in the manual, it shows that PHP 3 and 4 supports the two commands. Any help?

Next N Records
how do I create a "next n records" interface? I want to initially output a specific number of rows, and have a next/previous scenario where the user can click on either and scroll forward or back through the records. I'm currently outputting all rows through mysql_fetch_array: Code:

HOW TO GET HOW MANY RECORDS YOU HAVE IN DB
I finally discover the way how to get what I need.

Let's look to my code:

----------------------- CODE ------------------------>

$res = @mysql_query("SELECT COUNT(*) AS ToT FROM table_name");
$dato = mysql_fetch_array($res);

echo($dato[ToT]);
----------------------- CODE ------------------------>

With this code you will get how much records do you have in DB.

PS:
Whan you think that everything is over and that you are at bottom of
trying push harder to see what is under.

Last 5 Records
is there an easy way to grab the last 5 distinct records from an unindexed database?  (php/mysql)

Number Of Records
I want to find out how many records, but I am using LIMIT in mySQL so if set the limit to 20 and I have 56 records then it will display 20 instead of 56.

I have been using:
mysql_num_rows

What should I be using?

What To Do If There Are No Records In The Database
I am pulling data from the database and displaying it using the code below:

$db = mysql_connect("localhost", "root");

mysql_select_db("pyramid",$db);

$result = mysql_query("SELECT * FROM table where area='Wales'",$db);

while ($myrow = mysql_fetch_row($result)) {

echo "blah blah";

}
?>

What do I do if there are no records? At the moment it just doesn't display anything. How do I get it to display a message saying there are no records?

Updating Records
I am know to PHP i've been tring to do this **** for days now could someone PLEASE help me. Ok Im tring make an admin page where user can update multiple records at same time using checkboxes.Im using email as primary key.

Here is the code

**form page**

<form action="update.php" method="post">
<input type="submit" name="submit" value="Select First 10 Names">
</form>

**update.php**

<?php

if ($submit =="Select First 10 Names")
{
?>
<form method="post" action="<?php echo $PHP_SELF; ?>">

<hr size=3>
<?php

$query = mysql_query("select * from Names order by Last_Name limit 10");
while($row = mysql_fetch_array($query))

{
$first_name= $row["First_Name"];
$middle_name = $row["Middle_Name"];
$last_name = $row["Last_Name"];
$email = $row["Email"];
$photo=$row["Photo"];
?>

<table width="100%" border="0" >
<tr>
<td align=right width=50%>
<?php
echo "First Name: <input type=text name="first_name" size="30" maxlength="40"value="$first_name" ><br>
";

echo "Middle Name: <input type=text name="middle_name" size="30" maxlength="40" value="$middle_name"><br>
";

echo "Last Name: <input type=text name="last_name" size="30" maxlength="40" value="$last_name"><br><br>
";

echo "Email: <input type=text name="email" size="30" maxlength="40" value="$email" readonly><br><br>
";

echo "Photo: <input type=text name="photo" size="30" maxlength="70" value="$photo"><br><br>
";

echo "<input type="checkbox" name="email[]" value="$email"><b>Update?</b>
";

?>
</td>
<td align=right width=50%>
<?php
echo "$photo";
?>
</td>
</tr>
</table>
<hr size=3><br>
<?php
}
?>
<input type=submit name=submit value="Update Enteries">
<input type=reset>
</form>
<?php
}
if ($submit=="Update Enteries")

{
if (is_array($email))
{
while (list($key,$value) = each($email))
{

$query= mysql_query ("update Names set
First_Name = '$first_name'
Middle_Name= '$middle_name'
Last_Name='$last_name'
where Email='$value'");
}
}
}
?>

Need Help With Deleting Records
I'm trying to add a link on the display of a record to delete that record.

The main part of the record is stored in pw_event, then there are several rating fields for that record stored in pw_rate, and there is also several records for the first record stored in pw_whois.

I need to have a link that will deleted everything for that record in all three tables.

Here is my display script:

PHP Code:

Retrieving Records With Between
I am trying to convert my asp website to php. So far so good, but I am having a problem with my SQL Statement that needs to us the Between. Here is what I am using:

$sql = "Select * From tblTrack Where DateEntered Between $start and $end";

the vars start and end come from the same form. I don't have a problem when I hard code the dates, but when I use the variables, it won't retrieve anything.

Delete Records
I`m just trying to figure out the best method to delete my records and wondered if it was possible to do a DELETE statement to remove any records that don`t match. Here is my code so far:

$Query="select blah its huge:-)";
$RESULT=mysql_query($Query);
$my_rows=mysql_num_rows($RESULT);

for ($a=0; $a<$my_rows; $a++){
mysql_data_seek($RESULT, $a);
$Array = mysql_fetch_array($RESULT);
printf("%s<BR>", $Array['Email']);}

My Query returns Matched Records, what I would like to achieve is deletion of the records that didn`t match, would it be possible to do that under the printf statement. So delete all the records in the table that don`t match up to $Array['Email']??

PHP/MySQL Records Per Row
Is there any way to have the records pulled from a mysql database display like this in a table:

record1 | record2
record3 | record4

etc: I've been thinking about this for about three months and have yet to come to a good solution.

Inserting Records
I'm trying to insert as many as records as possible but less than 100 into a table. First, i get the count inorder how many to add and then depending on the count, i get so many blank form fields to enter. Now, I noticed something really strange.

1.Only the last entered record is inserted into the table.
2.For example, when I type a name, Let us assume "WORLD", only w is inserted into the table and the rest is not.It is the same with all the form fields.whether, i'm trying to enter text or a number,only the first character is inserted.This sounds weird. Could somebody pls tell me why is this peculiar behaviour Here is the code:

Insert Records
When I try to insert a records in the database "socios", it doesn't inserted at all. Code:

Different Hyperlinks To Different Records
I'm displaying few records from a mysql table - pretty straight forward one. For each record i display on the form, i want to add a link to it.so, each link would display a different page(an html). PHP Code:

Displaying Some Records Once Only
I'm building a database via mysql/php which brings back records of events. My problem is that I only want to show the Venue for the event once and then list the events for that venue. ie Code:

Deleting Records
I've been trying to delete records since a week and i'm not able to do it. Before with this script, i was doing so many things at a time and i was confused.But, now, i just displaying the records from a table N trying to delete them.Would somebody pls guide me.

I just wanna set the delete flag(i.e, i want to set the RBS_DELETE column to Y or something) when i check a check box to delete it. I've some 5 records displaying on my form and i want to check 3 of them and when i check them and hit submit, i want the RBS_DELETE column to have some value. PHP Code:

How Do You Sort Records?
I have a db table "person" that I can sort by title, first_name,
last_name, or city with no problems at all because "title",
"first_name", "last_name", and "city" are columns in the table.

The requirement is to ALSO sort by department NAME. Problem is, I
can't do that in the "person" table because the column is
"department_id" which is a foreign key constraint to the department
table.

How do I sort the person records by department_name based on this?

I am using PHP 4.3.2 and MySQL 4.0.10

Now, second problem and even more of a problem:

The requirement is to ALSO sort by state NAME and country NAME. The
fields "state" and "country" in the "person" table contain only an
abbreviation of state and country; the corresponding full name of each
state and country are found in respective XML files in /xml/state.xml
and /xml/country.xml

Compare Records
is it possible to write a query to compare records in 2 tables, like if the number of records in the  2 tables are equal the query should return 1 if not equal the query should return 0. this can also be done in php like, get the number of records from one table and get number of records in another table, compare it and do the operation. but i wanted to know if its possible to do the compare records using the query itself.

for example, if one table has 5 records, this should be compared with another table, if this table has 5 records, then the result of the query should be 1 else 0. if i use joints, it will return all the 5 records. so not sure how to make this in a query. anyone have any idea ?

Display Records
I want it to display all the records meeting the criteria specified in the script, but it only shows one records and should show about ten. any thoughts or pointers to get it to display more than one record. Code:

DESC Records
i want to make all the records be shown in a decending order, i've tried using:
$sql = 'SELECT * FROM `repair` ORDER BY `repair` . `id` DESC';

Records Won't Delete
mysql_query("DELETE FROM guestbook WHERE id = '$recnum'"); It works fine on my local server but it doesn't delete records on the remote server. any ideas?

Count Records
How can I count how many records are in a table that match a news_id? I have this at the moment, but it doesn't seem to work. Code:

Retreiving All Records From Sql Db
IM trying  to get cost values out of the db with a specific ID which is assigned to an item ID but i only get the last record in the database.

$lala = mysql_query("SELECT `cost` FROM `table` WHERE `ID` = '1'");
while ($la = mysql_fetch_row($lala)){
$start = 0;
$overall = $start+=$la[0];
}

echo("$overall");
...

Return Last 3 Records
I want to return the last 3 records added to my table called towns. 

sql = "select * from towns limit 3"

This only returns the first three rows, I want the last 3.  My primary key field is townID.


Copyright © 2005-08 www.BigResource.com, All rights reserved