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




Compare Values From CSV.....


I have a CSV file which contains data from the search engines, which includes search engine, keyword, number of applicants and number of visits.

However in some cases there is repitition however I want to merge those figures together.

An example of what I mean....




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Timestamp Compare..
Hi there,

I've got two sets of dates,

start / end

and

start / end


If I convert my dates into timestamps - is there a quick way to
compare them & see if any of the dates overlap.. ?

Im using a MYSQL database, & the dates are in text format - eg
20060527 etc (year month day)..

Though - Im at the very start of the database - so would storing the
start/end dates in Timestamps be faster ? (use a MYSQL query command
??)

Compare Two Dates
Comparing UNIX timestamps is no biggie but i have
to compare dates like this

$expiry_date="01/22/2007 05:42 PM";

to be compared with

$now= "01/22/2006 05:42 PM";

and just want a simple TRUE/FALSE return for the condition

"If expiry date has arrived? if its expiry date today or expiry date has passed?"

Compare Images
Does anyone know a simple way to compare two images to see if they are
the same? The filenames of the images will be different, but if the
image data is the same I would like to test for that.

The files will be jpeg images.

Compare Date
How do i compare two date in YYYY-MM-DD format to determine which one is earlier?


Compare 2 Arrays
$array1=[ifcfg-eth2 ifcfg-eth0:1 ifcfg-eth0:2 ifcfg-eth1:1]
$arra2=[eth0 eth1 eth2]

i am trying to compare them both using array_diff
how can change the 2nd array so as to get the result in ifcfg-eth2
cheers..

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 ?

Timestamp Compare
I want to compare a timestamp value from mysql and if it is more than 2 days old then delete. Hoq do i compare 2 timestamps with php?

How To Compare Three Strings?
Can anyone tell how i go about comparing three strings
to see if they are the same?

I'm building an Email list system, where users can upload
three of their friends Emails.

I want to check, to make sure they don't load up the same
Email three times.

I was thinking something like this, But  strcmp only compares
two strings. I need to compare three
strcmp (string $email1, string $email2, string $email3)

How Does One Compare 2 Arrays?
I'm going to have a select on two different tables, the difference i need to insert to a third, I can load the two up as arrays, but now i need compare the two arrays, and have the output entered into a third array so i can enter that one back into a table...

suggestions?

array 1 Touched files (select few from a HUGE of 5,000+ files)
array 2 all files (from same folder)
array 3 difference between the two

Date Compare
i have a db that stores a date in a table with a specific column.

db=test
table=test_date_compare
column name=date_inserted

ok i hv a php form that allows user to input date and it enters in the above column (date) as in format eg: 21/03/2007

now i wat i would like to do is i would like to compare date of today and the date in the database if it is lesser then todays date it deletes that row of data. deleting the row of data i know how but the problem comes wen coparing the date i dunno how to ...

Comparing User Input Values In A Form With Database Values
I want to compare user input values in a form with my database.
Basically I want to check whether the user exits in my database.
What mysql command can do that?

Compare Two Word Documents Using Php
In my system I want to compare two word documents ,but my server is a
Linux one and thats y I cant create COM object .

Any othermethods to find this one .I think to connect PHP to some
other mightt be useful for this.....

Code Compare Text
For example I have a paragraph

$p1 = "bla bla bla";

And I have an array:

$a1 = array("word1","word2","word3");

How to check that:

$p1 has one or more member of array $a1?

Compare Tables To Disallow Row
I have 2 tables, the first one names "site_users" contains a list of users and their information. The second table called "user_status" contains information about whether a user is banned, etc. I am trying to get a list of the users from "site_users" that are not banned in "user_status".

I tried using a join but I did not get the results I need. How can I select results based on a certain condition in the second table? PHP Code:

How To Compare Complex Strings?
i got a DB, in mysql, with more than 12000 records, each record has some values as name, surname, city, zip code and address. My task consists to find all record with the same address. Here is the biggest problem because, while city and zip code are entered with a drop down list, and so there are no possibilities to got differences, the address is entered manually in an input text. Code:

MySql Read And Compare .
I need a small QUIZ script for my site . I could not find the right script for me, so I decided to do it myself, BUT I am not a a big php programmer . So . The quiz is supposed to have 25 questions, with 3 answers each . BUT ! the thing is that some questions can have one, two or three right anwers correct, and all the right answers have to be corect for the hole question to be corect . So that is my main problem .

The script reads from the database the question number ID, the question, the answers (A1, A2, A3) and the value for each answer. (R1, R2, R3 ) . like for A1 R1=0 , that means R1 is wrong . and so on . each question has 3 answers .

I CAN NOT get right the code that makes variables for each $_POST and the code that should compare it with the value from the database . Code:

Compare Rows After Changes And Return Changes
I have a 33 column table with information that is changed by a multitude of users. I would like to keep track of the last changes made to any one row in the table. Here is what I thought of so far but believe there has to be a better way:

Once a user clicks update, the update script grabs whats in the given row, either saves it to an array or temp table then writes the new info to the perm database, grabs it, compares the two against each other to figure out what changed and adds it to the "update_changes" table, ready to grab by whoever wants to see it.

This seems like a round about way of doing this and I have to believe php and mysql are smarter than this. Everytime I run into a problem, I find after hours of searching that there IS a built in function that does what I need Can anyone point me in the right direction?

Compare Items In An Array...
I have been getting on fine with basic coding until I stumbled accross a problem. I cant seem to figure out how to check to see if a value in one array is in another array - and if so just simple report back "true" or "false".

Lets call the two arrays LOCKS and KEYS. Doing a print_r($locks) would give: Code:

How To Compare The First Digit Of A Number?
if($row[PurchaseNo]==$_post[firstprize]{};

the $row[PurchaseNo] is one digit , while $_post[firstprize] is four digit
how to compare $row[PurchaseNo] with the FIRST digit of $_post[firstprize] ?

Date Compare Mysql Eventcalendar
At the moment i use following code to display booked days in a different color in an eventcalendar. It works, but it's very slow. Anyone suggestions to make it work faster?
php code :

Compare Two String Dates Using An IF Statement?
How do I compare two date stored within a database with datatype 'date'?

The dates are stored within a PostgreSQL database table in the format
"Y-m-d".

PHP/MySQL Calendar Compare Question
Most of the events in the calendar are all-day affairs, but some occur at
specified times. So I have two separate fields in the event table, one for the
DATE (required) of the event and one (optional) for the TIME of the event. For
events that span multiple days, I have them enter the event once per day, but
could automate that sometime.

ANYWAY, here's my question:

When I am displaying a calendar, for each date in the month displayed, I search
the event table for events on that date. BUT, I was not able to use an = in the
where clause, I guess because a date in MySQL always has the hours, minutes, and seconds attached. I played around with trying to change the $dateToCheck so it had hours, minutes, and seconds attached, but somehow never could get it right.

I ended up with a query like this:

SELECT * FROM $thisTable where START_DATE >= '$dateToCheck' AND START_DATE <
'$dateAfterToCheck'

Is there a more elegant way for me to accomplish this?

Compare The IP Address Of A Visitor To A List.
I came across this free script on the net that compares the IP address of a
surfer to a list (1.list). If there is a match, the surfer gets the message
banned. If there is no match, the rest of the php script runs.

Is there an easy way to tweak the file so that
1. If there is a match of the surfers IP address to one in the list
(1.list), rather then get a banned message, the rest of the php script runs.
2. If the surfers IP address does not match any of the IP address in the
list (1.list), then instead of echo 'banned' the surfer is redirected to
another webpage.

<?php
$IP = $_SERVER['REMOTE_ADDR'];
$IP_array = file('../info/1.list');
$IP_array = str_replace("
", "", $IP_array);
$IP_array = str_replace("
", "", $IP_array);
foreach ($IP_array as $IP_test) {
if (substr_count($IP, $IP_test) != "0") {

Compare Two Names Based On Characters
I wasn't sure how to describe what I want in the subject line so
hopefully this post will allow me to further explain. I have a table
where I have names of people who have filed evictions against their
tenants. These plaintiffs have no mailing street addres. They have a
city, state, and zip code. In another table, I have a massive listing
of those plaintiffs who have filed evictions against their tenants but
each record includes a full mailing address; street, city, state, and
zip.

What I'm trying to figure out is how to write a little PHP program to
compare the name fields of table 1 (without address) into table 2
(with addresses) and replace the address in table 1 with the address
from table 2 based on the match. I would also like the capability to
match combined fields from table 1 into table 2, meaning, if I were to
combine name, city, state, and zip in table 1 and combine name, city,
state, zip in table 2, I will most likely have the ability to reduce
the list.

Scan Directory, Compare To Dbase
What I am trying to do is this:

1. display all photosets in a database (easy)
2. can all (sub)directories (medium level)
3. compare the results and display the sets that are not yet in the database, link them and create a way to add those as well (frustration level)What I have so far is the follwing: PHP Code:

Compare Contents Of Two Arrays And Display What DOESN'T Match
I've got two arrays that I need to compare. One is $roomNums and the other is $roomNumsBooked. The point is to compare $roomNumsBooked against $roomNums (both arrays) and then display what DOESN'T match so I can get the rooms currently available.

I've written a script that works, but it seems every-so-clumsy. I was wondering if I could somehow use preg_match to do this but my prevous experiments have failed. Here's what I've done that works:

*******************************************
$roomNums = array('A','B','H','J','K','L','M','P','T');
$roomNumsBooked = array('A','B','L','T');
for ($i = 0; $i < count($roomNumsBooked); $i++)
{
for ($j = 0; $j < count($roomNums); $j++)
{
if ($roomNums[$j] == $roomNumsBooked[$i])
{
$roomNums[$j] = &#390;'
}
}
}
print_r ($roomNums);
echo '<br>'
echo 'Available Rooms: '
for ($i = 0; $i < count($roomNums); $i++)
{
if ($roomNums[$i]!= &#390;')
{
echo $roomNums[$i] , ', '
}
}
*******************************************

The echoed result is H, J, K, M, P which is correct, but is there a better, more efficient and/or elegant way to do this?

Better Ways Compare Strings: Exact Matches
I'm creating a lot of arrays. Some of the arrays carry words
that get duplicated...

For example:
$aCities = {"Durham", "Raleigh", "Raleigh-Durham", "Salem", "Winston", "Winston-Salem" }

I've been using stristr alot but that ends up meaning that I
must take the arrays out of alphabetical order and in the
end it complicates things on my part. I'll comparing it to the
strcmp() function right at the moment but I ran into some
difficulties with strcmp() a couple nights ago, along the lines
of having to convert the strings in the array lower-case (all
my arrays are currently stored in a ucwords() format). The
dashes in the names also present a bit of a problem.

The way I'm currently doing the comparisons...

function GetCity($sSearchThis) {
$aAllCities = GetAllCitiesArray();
// make sure parameter is lowercase
$sSearchMe = strtolower($sSearchThis);
foreach ($aAllCities as $sThisCity) {
if (stristr($sSearchMe, $sThisCity) !== FALSE) {
return($sThisCity);
}
// default to raleigh
return("raleigh");
}

What's the best way to accomplish this or is there a better
way under the following conditions:

(1) The item passed in IS a string (not an array).
(2) A default string is always returned when no match is found.
(3) The alphabetical order of the array must remain alphabetized.
(4) The dashes are not required.

Compare 2 Dates Problem (select * From 2 Days Ago)
I am having a problem with comparing 2 dates with eachother. I wan't to select everything from a table from today and 2 days ago. PHP Code:

How To Compare Encrypted Password Stored In DB With Unencypted One
I need to compare the encrypted password stored in mySQL database with one which I am getting from login form submit. Scenario is as follows: There is stored password in the table users which I need to compare in login process with one which user enters into this form:

<form method=post action="mycheck.php">
<input type=text name=user>
<input type=password name test_password>
<input type=submit name="login">

The passed password value in mycheck.php is not encrypted but rather the original entry - although I do not understand this why. For sure if I compare this raw entry with one sititng in the DB there is no comparission since they are totally different. How to go over this? Where is the problem hidding.

Read / Compare Binary Password Field?
We have a program that stores passwords in a SQL database using the following SQL proceedure;

update master.dbo.sysxlogins
set password = convert(varbinary(256), pwdencrypt(@new)), xdate2 = getdate(), xstatus = xstatus & (~2048)
where name = @loginame and srvid IS NULL

Would it be possible to read and compare a password entered in an input box using php, to check the passwords match?

Compare Current Value In Loop To A Previous Looped Value
Im trying to compare a current value in a loop to all of the previous examples to assertain if a value is unique or not. Code:

Process To Compare Records For Updating, Is There Am Efficient Technique?
I have a large database where the records have many fields (80+) and have users periodically updating it by submitting uploads.

Is there a quick and efficient manner to compare the record that is being uploaded to the one that already exists in the DB before updating?

The records have over 80 fields, so stepping through every field would be painful, and why update the record if nothing has changed.

Is there some binary or boolean manner to weight both the existing record against that being offered, and if they are equal then do not go through the process of uploading and importing.

Any ideas welcome.

Is There A Quick Way To Compare The Results From Two Arrays And Note The Diffences?
is there a quick way to compare the results from two arrays and note the differences?

I have two identical tables in MySql (backup and current table) and I want to work out the differences between them (i.e. what fields are different). I could construct some long function, but I was wondering if anyone had a quick method (I am just learning PHP).

Adding New Values To An Array That Already Contains Values..
is it possible to append new values to an array that already has values in it??

say, i have my existing array;

existing array;
$array = array([66314] => 66314 , [66315] => 66315) ;

then , when i check my checkbox on my next page, the ids should be appended to the $array:

array that needs to be added to the $array;

$array = array([66316] => 66316,[66317] => 66317,[66318] => 66318);

how should it be done??

REQ How Would I Compare Multiple Date Fields In One Table To Find The Latest Entry Opps
i didn't explain it correctly before
my table is like this

example fields:
ID name username outcome date1 date2 date3 (etc..) - date15 price1 price2 price3 (etc..)

I know that Mysql query order by will compare records on a specific date, but how do i compare
multiple fields within the same record. Want to find the latest date within the record..

Assigning Values With Other Values
Say one has an array like such:

array("lang=english", "nomusic=true", "name=Fred", "menu=false");

Is there a function in which I input the array and it makes all the things into variables with the other things as the content like:

$lang="english";
$nomusic="true";
$name="fred";
$menu="false";


Question On Using "strcmp" To Compare Unicode Strings
I am confused by the rule of comparing two unicode string using
function "strcmp". For exmaple, using "strcmp" to compare two Chinese uincode string, depending on what rule can "PHP" decide one string is greater or less
than the other string?

Compare Record With Session Variable And Update Record If Different
I'm trying to figure out how to create a session variable from a recordset field value in a mySQL database and compare this with subsequent values from the same field each time the page reloads. When the value of the field changes (as a result of a user update) I want to trigger an event (redirecting to another page). It's probably a very basic PHP function but I am a newbie with this language.


The Old "compare Dates" Thing
I've been looking all over the place for a compare dates script that will work in my instance. I can't find one. This shouldn't be difficult, unless you're like me and get nose bleeds when trying to do anything related to numbers. I'm having a hell of a time wrapping my head around strtotime() and the epoch. Plus, I can't see straight right now

Here's what I want to do.

1. user joins.
2. thank you email is sent
3. if account is not activated within 3 days, send a reminder email

// i think it's like this
$today
$date_joined
$cutoff_date = ($today + 30 days)
if($date_joined >= ($cutoff_date - 3 days)) {
//do something
}
1. user joins
2. user has 30 days to try account
3. 3 days before account is to be deleted, reminder email is sent

// again, I'm "thinking"
$date_joined
$reminder_date = ($today + 3 days)
if($date_joined >= $reminder_date) {
do something
}

How To Compare 2 Dates In Mysql As Mysql Treats Dates As String ?
I'm trying to compare two dates in MYSQL. But its not treating the dates as numbers, but as strings. I try using strtotime but that did not work.

Set Values Once
let say that i want to allow someone (the site admin maybe) to chose
certain configuration values, for instance

* number of products per page
* picture widht
* back color
....

Right now, i just have all those info in a php page, so it can't be
modified
$number of products_per_page = 20;
$picture_widht = 2;
$back_color = #FFFFFF;

I could keep this info in the database, but i should read it every time
a page is rendered... (open connection, query, close conn)

What would be the best way to do what i'm need? Is there any chance to
"read once, keep value for ever" ?

Checkbox Values
Basically, I have 2 checkbox's which are printed out for each record within my table. On the next form, each checkbox is tested for being "checked" and the database is updated accordingly.

This is fine. My problem is that I dont want users to be able to select both check-box's at the same time. After talking to "andnaess" on an earlier post and doing some reading, I decided upon using some javascript to do what i wanted.

I have found a script which does exactly what i want, and i am now incorporating it into my original php script.

I am having problems assigning a name and value variable with an array to my checkbox's. Is this possible, or have i got the wrong idea?

Combo Box Values
I have values in a combo box where datas are coming
loaded dynamically. When an user selects a particular value and press search, even after refreshing the page, I want to keep the value same as the user selects. For example suppose if I selects
value PHP from combo box, after submitting the combo box should
value highlighted must be PHP. IS there any way I can do this?

Reading Url Values
I am able to pass values to the URL as this shows. I can get the id value and select data from mysql, but I cannot access the ln value. I have use various combos and acannot get it to read the ln value and display it. What am I doing or not doing? I have used get, post and result:

$id=$_GET[id];
$ln=$_POST[ln];
echo $_RESULT[ln]

Echo Certain Values Only
I'm creating a table that has 7 columns. In the first column, I'd like to show My_SQL data. The data contains multiple fields, but there is one that matters most right now.

Right now, I show this data with:

<?php echo $row_UserData['Number'];?>

However, I only want to echo this value if another value of the same row ($row_UserData['Code']) equals a certain number.

How would I write a conditional statement like this?

2 Values In A Loop
In a guestbook the im building, I want to set the <tr> bgcolor in a difrent color each msg (the same effect is also here in these forums).The code is a while loop (to get mysql results). How can I do it ?

Monetary Values
What is the best way to remove all characters except digits from a string? ie: I may have a value: '$4,000.00' but all I want is 4000

Values From A Form
I have a form (search.html) that has 1 textbox and 3 listboxes. When I submit this form to a php file (search_res.php), I am using $HTTP_POST_VARS to get the values which is fine.

But then in my php file(search_res.php) I again have a listbox with 2 options. When I choose either one of these options to display the search results either by "Price" or "Name" I lose the values of the main form (search.html). How can I keep these values from the main form in my search_res.php page?

How Do You Add Values In Rows Together
I am using the following code to take records out of a Mysql database and display them on an HTML form. $myrow[8] is a number. At the bottom of the table, I want to display the sum of all the $myrow[8] values added together. Code:


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