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




Filtering Results By DATE Value In Database


I have this code in my page for displaying some data from a database, sorted by date. i had posted a messed up version of this a while ago but I couldnt get it working even after a few suggestions. PHP Code:




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Filtering XML Results
I'm in the process of creating a page that displays multiple lines of inventory for a bunch of products (let's call them 'widgets'). The widgets are listed in XML format (they'll end up being pulled from a MySQL DB eventually). Code:

DVD Id Is Incorrect After Filtering Results
I am making a basic DVD shop and after having produced code which displays a
list of DVDs from my database, I implemented a search facility which enables
the user to search by title, director or actor.

The user can also browse the DVDs by genre. However, when the DVDs are
filtered, the id that is used to select a DVD and add it to the basket is
incorrect as they are output in a sequential manner and so the DVD placed
into the basket will be that matching the id. Here is the loop that outputs
the DVDs (I have a DVDID field as you probably have guessed):

if (mysql_num_rows ($getdvds_query))
{
for ($id = 0; $dvd[] = mysql_fetch_assoc ($getdvds_query); $id++)
{
echo "<tr>
";
echo "<td>{$dvd[$id][title]}</td>
";
echo "<td>{$dvd[$id][duration]}</td>
";
echo "<td>{$dvd[$id][rel]}</td>
";
echo "<td>{$dvd[$id][descr]}</td>
";
echo "<td>{$dvd[$id][genre]}</td>
";
echo "<td>{$dvd[$id][stock]}</td>
";
echo "<td>{$dvd[$id][price]}</td>
";

echo "<td><a href="$PHP_SELF?add=$id">add to basket</a></td>";
echo "</tr>
";
}
}

Here is the code that adds to the basket variable:

if (isset ($_GET['add']))
$_SESSION['trolley'][] = $_GET['add'];
else if ($_GET['op'] === 'clear')
$_SESSION['trolley'] = "";

Filtering Results With Php Query
This code works, but I don't know how to filter the results to where only one person is displayed..it displays all records with similar address or state or city, I would like to know how to make it display only one person when multiple search fields are entered.

I'm using PHP5, and I have searched the forums but I'm not sure exactly if I found what I'm looking for...I don't know much about php or mysql. Code:

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:

Filtering A Db With A Start And End Date
I have a MySQL table with a datetime field. I need to make a PHP script that will take all rows whose datetime field falls within that of a user-specified begin and end time. Anyone have a code snippet to do that?

Filtering Message From The Database
i have a page where people can send in MMS pictures and they get uploaded and displayed on my page, they need to type a keyword in the MMS like "sendmms" to make it work. if they also write "sendmms hey look at me" it also works since "sendmms" was at the beginning of the message and "sendmms hey look at me" get's added to the row "message" in my database. the pictures get an ID in the database and saved with the same ID on the server.

so under each picture sent in i wanted to add the comment they added after the "senmms" part.

so in short, how do i make it filter out "sendmms" and only display "hey look at me" ? and if the Page ID is let's say 13 it should display the "messsage" column for the ID in the database that has the same ID as the page ID is.

Date Is Not Being Pulled From MYSQL Database, Instead Current Date Is Displayed!
I am having trouble pulling a date from a database using PHP at the <a
href="http://www.mytuneslive.com/ameshkin69/"> following page.</a>

Here is the code. As you can see, it is just making the date the
current time. The values in the database are UNIX timestamp, and the
DATE() function is used to convert from UNIX to readable date. Can

<td width="55%" align="left" valign="top"><?php
$row_comment['timestamp'] = date("n d Y g:i A");.....

Adding Date To Results
I have a mysql database with links to files which output as links. I have added a Table called "Date" for the date the file was last indexed.

what I want to do is add a table to output the DATE without it being included in the link.

$counter = $range + 1;
while($row = mysql_fetch_row($result)) {
$fullURL = "ftp://".$row[2].":".$row[3]."@".$row[1].":".$row[4].$row[0];
$linkURL = htmlentities(str_replace(" ", "%20", $fullURL));
echo "$counter. <a href=$linkURL>$fullURL</a><br>";

How do I add the table to the end of the file to generate dynamically with the results?

Only Enter Results If Date Has Passed
I have a PHP match result system. I do not want the user to enter the result if the date has not passed. If the date has passed then $played = 'Yes', If not then $played = 'No'.

I read the date and time values of the match from the database. I then need to validate them. I could use the system clock BUT somebody could simply move the date on their machine to beat the system! Is there any other way to solve this?

Getting Results From MySQL Database In PHP
I am trying to write a php page which connects to a MySQL
Database which is supposed to get the results from a table within a
database and display the results in a table.

Below is the code that I am using:

Database Search Results
i have a paid to read website,im hosting it off my own pc..as a member you can search offers and complete them, heres where i need some help..when a member clicks submit and the offer goes to an offerdone table i need the offer to hide from them so they cant do it again,also that same offer needs to hide in the search results as well...is there somthing like onclick hide and for the results something like if duplicate hide from search or if offer found in this table hide from results...

there are 2 tables one will all my offers the other with offer they have done,also this needs to apply for each member account.i am new to all this and have made it this far to have my site up and going but im looking for those extra catchs i could really use,so that a member cant repeat an offer they have already done,

Having Trouble Alphabetizing Results From A My SQL Database
I'm a beginner and I'm having trouble figuring out the sort command (assuming that's what I'll need to alphabetize my results from a database.) Any helpful input is welcome.

Grouping Database Results In Pagination
I'm dealing with a situation where I can potentially have over 3000
results to display from a database. I'm successfully paginating the
results, 10 at a time, but don't want to display 300+ page links at the
bottom.

How can I group the pages to show, for example, the first 10 pages,
followed by a "next 10" link?

i.e., Page: 1 2 3 4 5 6 7 8 9 10 > >> Next 10

My current code:

Sorting Database Query Results
I want to know if it is possible to sort query results so that the records with a value in a certain field is displayed first and the records with the field empty thereafter.

Showing Image With Database Results
I am trying to retrieve data from a MySQL database and have got it working. Only thing is I would also like to display an image for each row. Each record has a file number and the images are all saved in an image folder and are named with the actual file number.

EG there is a record with file number 1111 and there is an image called 1111.gif in the images folder. I have included my code below. If someone can tell me how to include some html code to show the image in my php code. Code:

Problem Retrieving Results From Database
I'm trying to retrieve fields from my database with following mysql
statement:

$query = SELECT g_games.Title FROM g_collections, g_personal_reviews,
g_games WHERE (g_games.ID=g_personal_reviews.G_ID AND
g_collections.U_ID = '" . $data1['ID'] . "' AND g_personal_reviews.C_ID
= '" . $data2['ID'] . "' ) ";
$resultset = mysql_query($query);
$data = mysql_fetch_array($resultset);

3 Rows in my database comply with the above statement... though I only
get 1 to show up on my php page? How can I show all of them?

This is the php code I'm using to write the results:

while ($data= mysql_fetch_array($resultset))
{
echo $data[Title]." ";
}

My tables are as followed:
g_games
g_collections
g_personal_reviews > this table connects all others with G_ID ("game
ID"), C_ID ("Collection_ID"), U_ID ("User ID)...
users

Putting Database Results In A 5x1 Table
I have a db of tens of thousands of entries. It's not too hard to pull
all the entries and build a table that displays them one at a time, but
in my case, that will be a huge waste of space. What I want to do is
put one record in each of the columns. I thinks it's possible to do
because I have seen very elaborate thumbnail gallery scripts to do this.
I just want to be able to put two or three strings of text from each
record into each row, and a checkbox. Here's sample of what I mean:

<table width="76%" border="1" cellspacing="1" cellpadding="1">
<tr>
<td>$record1Line1<br>$record1$Line2<br>
<input type="checkbox" name="$record1checkbox" value="checkbox"></td>
<td>$record2Line1<br>$record2$Line2<br>
<input type="checkbox" name="$record2checkbox" value="checkbox"></td>
<td>$record3Line1<br>$record3$Line2<br>
<input type="checkbox" name="$record3checkbox" value="checkbox"></td>
<td>$record4Line1<br>$record4$Line2<br>
<input type="checkbox" name="$record3checkbox" value="checkbox"></td>
<td>$record5Line1<br>$record5$Line2<br>
<input type="checkbox" name="$record5checkbox" value="checkbox"></td>
</tr>
</table>

I want to pull about 200 records at a time from the db and display as
described above. How can I tell php to take five records from my result
set and display above, then loop through the result set until I'm done?

Populating A Drop Box With Results From Database
I have a MySQL database with a table (category) with two fields, catId (int) and category (char(50)). What I want to do is to get all category names in this database and place all of them into a dropdown box on a web page so that the user can choose from the list of available categories.

Displaying Database And Getting Unwanted Results...
I want to display everyone in the database, but only if the 'level' field is larger than 0.  Well, this works fine for most of the database... but if the last entry in the database is 0, then it prints it anyways.

Is there anyway around this?  I tried adding an if statement before the last bit where I echo out the table rows, but it was killing the entire table, or still showing the same results. Code:

Function To Fetch Database Results
I have a function that is supposed to fetch all the results from my table "games". There are two database records in that table. My function is supposed to display all of the records, but it only displays one. I also use a function to display a certain template. Here is the coding for both functions and my index. Code:

Counting Results From A Mysql Database
I want to know how many results throw a query in order to know if they have reached a limit.I.E.

$sql = mysql_query ("select * from classifieds where user='$username'");
while ($row = mysql_fetch_array($sql)){}

I want to check lets say that only 10 classifieds per  'username' can be created. If ten or more classifieds are in the database for that 'username' then show error message.

Displaying Results From Database In A Particular Format
How do I display results from a database in a particular format.  For example the following text in this format including the lines in stored in the database:

Quote“Hello,

Welcome to the news for 11/06/07.

Thanks”
When I echo the results using the usual, <? echo $row_news[‘news’]; ?> it doesn’t echo the information in the database in the format it is stored for example it will display like this.  Quote“Hello, Welcome to the news for 11/06/07. Thanks”  How do I get it to display in the format it in displayed in the database?

Display Results From A Database On Multiple Pages
I am new to PHP and Mysql but am really determined to learn these techniques. I have some script that reads and displays results from the databse onto a page. However, I really wish to limit the number of results that are displayed to 10 per page and then have the next/privious links under the results. With these results, the results under the email field should be hyperlinked so that the person viewing the results should double click on the email link and send the person an email. How can i do that? I have to learn this technique.

The code is:-

Navigating Database Results And Problem With Link
I am loading results from mysql database and displaying on my page and then dynamically displaying only 5 results per page. On each page I have a POST button so that if user wants to POST something on form he should be able to do it whether he is on page 5 or page 1. When I first time loads the results on page 1 this POST button works fine but when I go to page 2 and click on POST it gives following error

"
CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:
"
and then even if I go back on page1 it starts giving me same error.

Navigating Database Results And Posting New Values
I am trying to dynamically display results that I retrieve from my database i.e. only 5 results per page and code should automatically compute how many pages it needs and create links for each page. I have also added a link at the top of my page so that if user wants to POST new data he can post it. Problem is that when I click on page 2 or 3 or any numbered page and click on POST link it gives me following error
"CGI Error
The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are:

And it did not tell about any header etc. Code:

POST To Mysql Database And Email Results?
I have a simple html form that POSTs to a mysql database. Can I, and if so, how can I, have it post to the mysql database, and email the form results too.

I also have some other html forms that just mail() the results. So I can do both things separately, but I'm not sure how to combine them.


Download Database Search Results As Text File?
Can someone please tell me how to query a database and then download results as a text file.

Populating Form From Database, Then Passing Results To Next Page
I have a multiple select input in a form that's being populated by a row
from my database as such:
<input type="checkbox" name="subm[]" value="$row[ID]">

That part is working fine as I can check the displayed page using View
Source and see that the value is the correct row number from the
database. It is then being submitted on a form by $_POST method to
another page where I want to evaluate the checkboxes and display the
contents of the entire row that corresponds to each value="$row[ID]"
that have been checked. But I can't seem to get it to work. I'm having a
problem passing the selected value. Can someone point me in the right
direction?

$query = ("SELECT * FROM `table`");
$result = mysql_query($query);

print "<p>Data for Selections:";
print "<table border=2><tr><th>You chose:";

foreach ($_POST['subm'] as $value) {
print "<tr><td>";
print "$row[ID];
";
print mysql_field_name($result, 1) . ": " . $row[name]."<br>";
print mysql_field_name($result, 2) . ": " . $row[address]."<br>";
print mysql_field_name($result, 3) . ": " . $row[city]."<br>";
print "</td></tr>";
print "</table>
";
}

if (!isset($_POST['subm'])){
print "<p>No matching entry ";
}

mysql_close();

DATE Doesn't Get Into Database
I have a HTML-form with a 10width field in which you can enter a date. But whatever I enter. In the database I always find 0000-00-00. The variable comes through. I checked that. Does anybody know what I do wrong ?

Date Database?
The admin assistants can enter the number of hours that each employee has worked on a particular date in a particular month (hours are variable depending upon customer demand) and at the end of the month need to run off a pay slip for each employee containing the following data:

I know how to add, delete and modify the data, the only thing im not sure of is the databse structure for the dates.

Inserting Date Into Database
I have a pretty simple news code that inserts the data, and then is retreaved, with a pretty simple scheme. I have a date column set at timestamp(14), and I'm trying to insert NOW() as the date. I browse with phpmyadmin and all it has is 14 zero's. PHP Code:

Displaying Date From A Database
All I need to do is change the date so it reads, for example, May 1999 when it's displayed on the page. Code:

Inserting Date In Database
I have form which allows a user to select a date as part of the form.
On submitting i am getting no update to the database and no error message.
To try and test it i created a shorter version which sets up the variables except the date.This gives the same result.ie no update. Code:

What Is The Proper Date Format For A Txt Database?
I would like to know what format should be used when writing to a txt file. I am trying to search between a start date and a ending date and list any variables For example.

if (($sDate <= $jdate && $eDate >= $jdate))

then I have it list the variables it will work if searching between months and days but it does not work if I have different years. I will get all years printed out.

my date format is m/d/Y 6/13/2001

If I search for example start date = 6/01/2001 and the ending date = 6/09/2001

I will get the correct month and day dates but I also get anything from the year before and including year in the future.

Date & Time Format In Database.
I'm using MySQL database, the problem is I've setup that user input the Date format in dd/mm/yyyy (example: 14may2007) and Time (example: 12:00pm). How do I convert it to Date & Time format in database format before insert into database? Sorry, noob here.

Calculating Dates From A Date In The Database?
I`m using this format of dates:

$entry_date = strftime("%B %e, %Y %H:%M:%S", time());
And that time gets saved into the database (birth in ownedpets database):

$res = mysql_query("SELECT id, owner, pet_type, pet_name, birth, food, play, datetime FROM ownedpets WHERE id=$id");
$rows = mysql_fetch_row($res);
mysql_free_result($res);

So let`s say in this case, the database birth value ($rows[4]) is October 19 2007 20:00:00. What do I do to tell php to check to see if the current date (hours and all don`t matter) is 21 days after the $rows[4]?

Why I`m looking for this task:
For the pets system, if the pet is 21 days after it`s birth, it will be an adult. But if it is not 21 days after it`s birth, it will still be a baby.

Today's Date In Database Insertion
How do I insert today's date in a certain database row without using the date() function for a string?  For example, when you use PHPMyAdmin to insert a new table row and there's a column with the type "date", it gives you options such as CURDATE, NOW, etc.  How would I use that in a database query?

Convert Date From A Database Query
I have a simple database for events. I have a column named "date" that I would like to display as "March 8, 2007" on the webpage. What do I need to add to change the date format? Here is my php code:

Reading And Displaying A Date From A MySql Database
I've just started using php, and although I am very impressed by it,
there are some things with which I am confounded!

What I'm trying to do is read in a Date from a mySql database and then
display it on screen (the Date is in the usual yyyy-mm-dd format).

If I use SQL on phpadmin
SELECT Date
FROM details
WHERE details.Name = "Paul Lee"
LIMIT 0 , 30

The result comes up 2005-01-01, so this seems to work.
But if I use the following:

$db = mysqli_connect("localhost","root","");
@mysqli_select_db($db, "personnel") or die ( "Unable to select
database" );
$query = 'SELECT Date FROM details WHERE details.Name = "Paul Lee"
LIMIT 0, 30'

$result=mysqli_query($db, $query);

echo "<br>";

echo $result;

mysqli_close($db);

I get "Object id #2" displayed on screen.
I have tried to use the explode function to separate the months, year
and day using the "-" as a delimeter, but this doesn't work, and I
can't seem to get the other php date/time functions to work either.

Inserting A Date Into A Microsoft Access 97 Database
I was wondering if anyone could help me insert a short date into microsoft access 97 using php? i can insert text no problem but i can't seem to be able to insert a date properly. i have been using

//$date = "#" . "$sqlmonth" . "1" . "$cboyear" . "#";

$strSQL = "INSERT INTO tblSupport (tDate) VALUES ($date)";
$result = odbc_exec($connect, $strSQL);

Note: i can insert a date if i hard code it like putting in #01

How To Find The Last Accessed Date Of A MySql Database
How to find out the last accessed date of a MySql Database. I have around 200 databases in my server some are used and some are not in Use, I want to remove the database that are not in Use. SHOW TABLE STATUAS gives me last updated Date. In my case there are some database which are not updated at all, but...

Insert Server Date / Time Into Database
I currently have the following to insert a variable into a database:

$zip = $db->escape($_POST['zip']);
$db->query("INSERT INTO zip SET zips = '$zip'");

I would like to also add the date & time the submission was made.

Help With Displaying Selecting A Date Range And Displaying Results
I wish to create a simple form that allows the selection of a start date and a stop date with the ability to select what columns to be displayed in the result page.

Pulling Data From A MySQL Database With PHP Date Code??
I am trying to find ways to retrieve data by date from a mysql database.
What I would like to do is to have the option for people to retrieve a file
that was entered in the week before the current day (something like click
here for all drinks added in the last week) I have tried to make this code
work, the only way I can is to manually change the date every day, I would
like it to do it automatically.

Taking Date Of Birth From User And Sending It To A Mysql Database
i have created a form that takes a users date of birth as 3 seperate values $day $month and $year i do not know how to combine these values into a single value called $dob.
I tries using just a singal value to take the date however it did not work, even after I had formated my database.

Filtering HTML With PHP
I am using PHP to set up a message board which interfaces with a mySQL database. I am trying to filter malicious HTML code that users would try to leave on the message board. I want to strip all HTML tags except the <A HREF> tag.

Filtering Out Bad Input
I am currently building a website, with a built in news and comment, so far i know have been able to filter out thing such as swear words, however is it possible to filter of say f someone held down the ===================================================== ============= key

Is there a way to prevent this or will i have to have some sort of statement that counts how many times the = or other char is grouped together?

Filtering RSS Content
I need to install an rss aggregator on a website. The catch is that it
should only pull in items from feeds which contain certain keywords.

Any idea how this can be done or if such a content managing software
already exists?


Dirty Filtering
does any one has a list of dirty words, do not post in this forum, but show me url. PHP Code:


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