Comparing Results From Two Tables
I am having some major trouble comparing information from 2 tables. I am attempting to verify the information in similar columns, so that I can come up with a number. The columns are setup as varchar(30). The basic idea of the program is to obtain the Qualifying results for a race, and then add them to the table with Race results. Code:
View Complete Forum Thread with Replies
See Related Forum Messages: Follow the Links Below to View Complete Thread
Comparing 2 Tables
SELECT userid from userstable Then check a table named Hospital... for userid Then what i need to do is a while loop which will "only" while loop through users that are not in the hospital table but are in the user table..... meaning only people out of hospital will be queried but "all" out of hospital users must be ran through the while loop.. is this possible in one query?
FYI: Test Results Comparing Different Methods Of Resizing Images
I posted this in alt.php, but as a reply, so now I'm posting it here for people who might have missed it but still could find it useful. I compared the smooth image resampling used in PHP to create good quality thumbnails of large images, used commonly in image galleries. i compared ImageMagick and PHP (with GD2) and compiled some statistics below. I ran two test. Both used a set of 10 photos around 3MP in size. On the first test, I created two thumbnails for each photo, one 700 pixels in width and another at 120 pixels in width. On the second test, I created just one thumbnail, 120 pixels in width. Time was counted in "minutes.seconds." TEST#1 -- IMAGEMAGICK* ----------------------------------------------------------- METHOD TIME IMAGE QUALITY thumbnail 1.33 good sample 0.24 bad resize 1.33 good size/geometry 0.42 good TEST #1 -- GD2 (PHP) ----------------------------------------------------------- METHOD TIME IMAGE QUALITY Imagecopyresampled 1.57 good TEST#2 -- IMAGEMAGICK* ----------------------------------------------------------- METHOD TIME IMAGE QUALITY thumbnail 0.26 good sample 0.19 bad resize 1.13 good size/geometry 0.06 good TEST #2 -- GD2 (PHP) ----------------------------------------------------------- METHOD TIME IMAGE QUALITY Imagecopyresampled 0.56 good *ImageMagick Command Methods: thumbnail : convert -thumbnail $destSize $sourceFile $targetFile sample : convert -sample $destSize $sourceFile $targetFile resize : convert -resize $destSize $sourceFile $targetFile size/geometry : convert -size $destSize $sourceFile -geometry $destSize $targetFile CONCLUSIONS: ----------------------------------------------------------- There were four different imagemagick commands I tried out in all. Overall, the winner came out to be the imagemagick command. This method beat out PHP by a good margin, creating thumbnails in about 1/3 the time it took PHP with similar quality in the first test, and then taking the cake in the second test by creating thumbnails in about 1/10 the time as PHP. Imagemagick seems to increase in performance compared to PHP when creating a smaller thumbnail versus a relatively large thumbnail, as seen by test #2 versus test #1. This means that a site creating small thumbnails will see even more of an advantage by using Imagemagick.
Formatting SQL Results In Tables
Fairly new to all this, but, I can return results from MySQL into a table without any problems - but what about formatting. I need the 6 columns to be of fixed width. Currently, due to the variable length of the data in the columns, they keep changing each time I cycle through a set of results.
Print Results From Two Tables Linked Together
I need to be able to pull data from a table (product_status, which has many other fields) and cross reference it with data in another table (warranty). The data in product_status lies in a field called warranty_number, and is simply an id number (1,2,36,etc.) The data in table warranty, field warranty_comment, is text (30 day warranty, one year warranty, etc.). The warranty table also has a field called warranty_id, which corresponds to each text entry in the table. This number matches the number in table product_status, field warranty_number. So I need to be able to print results of product status, but instead of printing simply the number in field warranty_number, it needs to check table warranty, field warranty_id, then match the number, then pull the text from warranty_comment and print along with all the other results from product_status. I have some code that works, but it is not at all designed for this, so I won't post. Is this enough info to explain what I need? I have tried searching, but found nothing that I could see that would help.
Display Results From Multiple Tables
I have two tables, one table (article_cat) has four fields ("id", "title", "feature1", and "feature2") and the other table has six fields (articles) has ("id", "cat_id", "title", "content", "feature1", and "feature2"). I am looking to display the "title" from the "article_cat" table that has "feature1" with a value of 1. And I want to display beneath that all the "title" results from the "articles" table where "feature1" has a value of 1. I have tried this a thousand ways with no luck. Code:
Results From Two Db Tables Into One Html Table?
I have a query below that gets its results and puts them in a table. The current results are from two fields in a db table. I am wondering if it is possible to create a second query to get results from a different db table and echo them out in the same html table as the ones already there? Code:
Setting Radio Buttons Via A Tables Results.
I'm generating a dynamic table based on a SQL call to a database. For each row returned I need four radio buttons in a group which somebody can make a decision on. The above is no problem but what I want to do is at the same time set the radio buttons to the correct figure based on the data returned. PHP Code:
Results Of Same Field Names But Different Tables In MySQL Query.
I have a SQL string with a couple of JOINs that works perfectly in command prompt. I get results for all the fields selected just fine. But when I put it into a PHP page, I can't make variables(?) out of fields that have the same field name from different tables. Here's the SQL statement: $sql = "SELECT orders.companyid,orders.ordernum,orders.address,tb l_ih_accounts.company,tbl_ih_accounts.address FROM orderstatus ". "LEFT JOIN orders ON (orderstatus.ordernum = orders.ordernum) ". "LEFT JOIN tbl_ih_accounts ON (tbl_ih_accounts.id = ihid) ". "WHERE submitted <> 'yes' ORDER BY orders.ordernum ASC"; Then in the "WHILE" clause after the database is queried: $o_address = $row[orders.address]; $ih_address = $row[tbl_ih_accounts.address]; I've tried it without the table names in the $row statements, but then I'll just get the results for tbl_ih_accounts.address. I'm thinking there must be some way to uniquely "name" the results of a particular field up in the SQL statement, and then just use that unique name in the WHILE. But I have no clue, and can't find anything about anything like that.
Query Array, Sort Results And Display In Seperate Tables
The problem I have it breaking out the results and displaying them (broken out) alphabetically in seperate tables. For instance, I have generated (bookmarked) tables, one for each letter (A-Z) and want to display all recordsets with say, last name beginning with "A" in one 2 column table, "B" in another 2 column table, and so on... each table would have two columns (with 2 background colors alternating), each cell containing values of one recordset. Even more tricky is if I have an odd number of cells, still generating the last cell with empty values (for asthetics). And can anyone say "sort" (yes, I am nuts)? The ability to sort the whole mess by any column value. I have looked at freeware and other third part apps, but they can only do what I already can do (mine is actually cleaner) but not as complicated.
Retrieving,Sorting & Displaying Multiple Results From Mutliple Tables
I need to know how to run a php / mysql query to do the following. I have 1 database (lets call it "database" for now) within this database there are multiple tables ("News","Feature","Header_feature") For NEWS I need only the 6 latest results pulled from that table and displayed in a table. The "News" table has the following columns "ID","Title","Date","Body","Image" For Feature I need only 1 result retrieved from the database and displayed under the variable $ticker as it will display as a scrolling marquee within a table. The "Feature" table has the following columns "ID","Ticker". For Header_feature I need only 1 result retrieved from the database and displayed in the following manner <a href="$link"><img src"$header_feature">[/url] The "Header_feature table has the following columns "ID","image","link" How would I code this all into 1 page? I cant seem to get the query to do everything I want it to and display the results properly. You can see what I have so far at www.getlivemedia.com The $ticker is the scrolling text near the top of the page and the news is obviously the bulk of the page and $feature_image is the broken image.
Generating Multiple Alternating Columns And/or Tables Within Tables
I am having a little bit of trouble generating the code for a table with 2 columns. The columns contain tables within themselves. Not sure why as that part was an existing design. Here is the output so far and it is correct but not how i want it to be (i'll explain) Code:
Search Brings Back Different Results Or Sometimes No Results
The problem Iv got is that when searching the site - it brings back different results or sometimes no results. For example: "i026", "i 026" and "026" do not bring back results for "I-026" which is the correct model number. Any ideas on how to make it search more variations or of a "Did you mean... I-026" script?
Comparing A String
I'm making a function to make a page using fasttemplates. The problem is that when the function is called it's got to check the value of $content if it's signup.htm it's got to make the sign up page. And if it contains .htm use that as page and if none of those just print the content of the string. This what i have so far but it doesn't work the way i want it to. What's wrong?
Comparing Dates
Is it possible to compare dates? For example: I have a site that displays releases dates (in MySQL format) for upcoming CDs. However, I need to compare the current date with the release date to decide whether or not to display a release date at all.
Comparing Two Dates
I need to compare two dates, first one being when the page is loaded (e.g. now()) and a date in the future (an event). then to do a count of this eg. $startdate="05/07/03"; $eventdate="08/07/03"; so....in the case above there would be 3 days remaining... can anyone help, or give me a few pointers how to acheive this....??
Comparing A Url String
Hi i'm no php programmer but a big part of my site now uses it after i payed someone to automate alot of it. However, now ive spotted a problem. I have a link exchange script which searches another sites url to make sure my link is present before it automatically adds their link. I've noticed though that if the url they use is a level deeper than the one it looks for, the script cant find it. I need to make it more flexible. Can anyone help? This is the script part that i *think* looks for my url on their page: function check_link($str) { $lookup = <<<ERT <a href="http://www.mydomain.com/"> ERT; if (strpos(@implode(" ",@file($str)),$lookup)){ return 1; } else { return 0; } } ------------------ If the link they use is e.g http://www.mydomain.com/keyword/ the script wont find it. Does anyone know how i can make it accept a url aslong is it contains my domain in part of it?
Comparing Timestamps
I would like to know how to take 2 timestamps and compare them to see if the difference is greater than 24 hours. I tried just using the huge numbers and doing the math, but it doesn't work.
Comparing A PHP, CFM, And ASP Script
Just because I thought it would be fun, and I just recently installed these things on my computer, I wrote a little script that reaches into a little database table and outputs a list of the things in there. I did this in PHP, ColdFusion(.cfm), and ASP. Here are the scripts. PHP: <?php mysql_connect("adam", "root", ""); mysql_select_db("test"); $query = mysql_query("SELECT * FROM first ORDER BY fname ASC;"); while($fetch = mysql_fetch_row($query)) echo $fetch[0] . " " . $fetch[1] . "<BR>"; ?> Alternate PHP using objects: <?php mysql_connect("adam", "root", ""); mysql_select_db("test"); $query = mysql_query("SELECT * FROM first ORDER BY fname ASC;"); while($fetch = mysql_fetch_object($query)) echo $fetch->fname . " " . $fetch->lname . "<BR>"; ?> ASP: (using VBscript) <% DIM cn, rs, sql SET cn = Server.CreateObject("ADODB.Connection") cn.Open "MySQL" SET rs = Server.CreateObject("ADODB.Recordset") sql = "SELECT * FROM first ORDER BY fname ASC" rs.open sql, cn DO WHILE NOT rs.EOF Response.Write rs("fname") & " " & rs("lname") & "<br>" rs.MoveNext LOOP %> CFM: <CFQUERY name="name" datasource="MySQL"> SELECT * FROM first ORDER BY lname ASC </CFQUERY> <CFLOOP QUERY="name"> <CFOUTPUT> #name.fname# #name.lname#<br> </CFOUTPUT> </CFLOOP> Well, since I've been coding in PHP straight for the past 6 or 7 months, the PHP code took me about 10 seconds at most to write. The CFM code, while definitely simpler, took me a little more time to perfect. I'm pretty new to the language, but it is mostly pretty simple and easy. The ASP code took the longest. I'm pretty new to ASP as well, but it was a bit more complicated than the other two. Let me just say I'm not a fan of the ASP method of doing things. PHP is possibly the best server side scripting language out there. I'm just learning these others to "expand my horizons" so to speak. Perl is coming soon.
Comparing Two Arrays
What i need to do is compare two arrays and return an array that only has those that are not in the main table.It's similar to what you could do with SQL. Array 1 - List of Everything Array 2 - List of Some of Array 1 What i want to obtain is Those of Array 1 that are not in Array 2. I would prefer not to do the following: function getUnique($array1, $array2) { foreach ($array1, $key => $value) { $array2_key = array_search($array2,$value) if ($array2_key === false) $result_array[] = $value; } return $result_array; } Is there any simplier way of doing this...any predefined function in php that could do this?
Comparing Day And Time
i want that if the user tries to login with incorrect password more than 3 times, then he should not be allowed to login for 24 hours. i m trying to save the current day and time and then comparing the same when the user logs in. My problem is how to compare current date and time. Is there some alternate way to do the same?
Comparing Arrays
I've got two uploaded files which I need to find out the diffrencies between. So I read them into two arrays and though I could compare them. And when I looked at the files, the problem arose. Coz the files looks like this: Code:
Comparing Variables?
I have a problem. I,m trying to check the value of a variable. This variable is being set by radio buttons in a form. The form variable is being posted to another page. $salutation is the var in question. PHP Code:
Comparing Hh:mm:ss (Duration)
I have LOGIN and LOGOUT time of the visitors of my homepage. Right now I want to know the duration between those two range of time. I have the data in TIME field format (MySQL) as follow hh:mm:ss. So, for example I'd like to know the duration of this login session: LOGIN: 14:45:32 LGOUT: 15:03:24 How can I compare that ?
Comparing Dates
In my database, the Valid_end column is formated with the date datatype. My question is, after getting the values from the database, is it possible to compare them just like normal numbers in PHP. Or is there a much efficient way to do this. PHP Code:
Comparing Problem
The problem is like this, There are a number of $rows resulting from the query described below. There is a variable named payment, this has for example the vualue 2. lets say the query had 5 results, the i want to do a compare that it shows only 2, depending on the value of $payment $query = "SELECT a.oproep,b.oproep, a.react, b.react, a.logid, b.logid, a.persid,b.persid, a.logemail, b.logemail,a.persemail,b.persemail FROM reactie a, reactie b WHERE a.logid = b.persid AND b.logid = a.persid AND a.logid='$logid' "; $result = mysql_query($query); ......
Url Comparing Not Working With GET
I'm trying to write a function which takes a given url, runs it through a database and verifies whether it is in the 'allowed' list, 'banned' list or neither. This is my function (I've added quotes to make it easier for you to understand): Code:
Comparing Dates
I have this database with lots of info all time stamped with this format "May 15 2007 9:44AM". What I would like to be able to specify a date range and have only entries that are in that date range be pulled from the table so that I can post the results. I know this must be possible but I have no idea host to even start.
Comparing Dates
In my db table, my date field uses YYYY-MM-DD, but if you compared 2007-6-1 to 2007-06-01 you would get FALSE. What can I do about this? I'm passing days using the GET method and then populating an events div with events from a db table that match the D M and Y. I would like it to work for both numbers with and without leading zeros.
Comparing Date
i have requested the selected date from another page and the current date is taken from session. now i want to check one condition that if the selected date is greater than the todays date then open a form else do not open. but the date comparison code is not working. here is my code: $user_sel_date=$_REQUEST['myseldate']; $mycurrentdate=$_SESSION['mycurrdate']; if ($user_sel_date >= $mycurrentdate) { echo "inside the if"; } else echo "outside the if";
Comparing Arrays
My program has 2 sets of data. One is the id column from a tab delimited file and it needs to be compared with the id column returned from a mySql query. The program needs to start with the data in the tab file id column and then compare ONE of the tab file ids to ALL of the ids in the user table. If a match is found, an Update query is run. If a match is not found, an Insert query is run. Code:
Comparing Arrays
I have a MySQL database which has a load of musicians on it. Each musician has a field that stores their influences, which are separated by commas, e.g: The Beatles, The Beach Boys, Kiss etc etc. Now, what I would like to do is start with the influences of one musician, and then compare it to all the others to find the closest matches - i.e find the musicians that have (say) more than three influences i common. This would then allow you to see which musicians had the most influences in common with the primary one, the one you started with. Here's what I have in mind, it seems a little laborious - load the influences of the primary musician into an array using the explode command. Then step through each of the other musicians in a loop, each time putting their influences in to an array and checking to see how many matches there are between the two arrays. Whenever there is at least one match, the name of the musician and the number of matches would be put into a third array. This array would then be sorted at the end, so that the musicians with the most matches would be at the top, and the script could then display them. This would probably work, but if looking at several hundred or several thousand musicians, it would surely be quite slow - is there a better way? I don't particularly want to use a separate, normalised table at this point - I know it would be the quickest way but it would involve a lot of restructuring for me. I know that PHP has several clever inbuilt routines that might do this job for me, so if anyone can suggest anything I'd appreciate it.
Comparing Objects
I've got an array of objects that are instantiated based on an ID, but it's possible that multiple objects of the same ID may be added to an array. I've tried using array_unique to get rid of duplicates, but if the object contains a null data field, it throws some error messages. How do I get PHP to compare objects by a certain field rather than every variable (null or set) declared in an object?
Comparing Dates
I am attempting to make a way so that my users have to be 13 years old in order to register, is there any easy way to do this, or am i coding 3 if else statements to compare current day and current month, and current year to the posted y/m/d?
Comparing Array Values
I'm developing a database that holds information about crew members. There are 7 categories of service types. Crew members can be associated with any number of categories. I'm working on an update form to add or delete categories for a crew member. I first issued a query to find the member's categories. I issued a second query to list all possible categories. I want to show a checkbox for any possible categories that aren't in the member's individual category list. If the member is in categories 1 and 2, but not in 3 or 4, I want to show a checkbox for categories 3 and 4. I can get the two category lists to print, but I can't figure out how to compare them. Here is the code I have for the select statements: Generates the list of member categories: $cat_query = "SELECT crew_category.crew_id, crew_category.category_id, category.category_desc FROM crew_category, category WHERE crew_category.crew_id = "$crew_id" and crew_category.category_id = category.category_id"; $cat_result = mysql_query($cat_query); Generates the list of all possible categories: $all_cat_query = "SELECT category_id FROM category"; $all_cat_result = mysql_query($all_cat_query); I'm just developing my programming skills (as I'm sure you can tell), so I apologize for my ignorance! Thanks in advance to anyone who can help!
Comparing Variable Problem
Is this the correct php code that will retrieve a variable from a form and turn it into a variable in the script. For instance, the user types in an address in a form, I want to use that address to compare against known addresses in a database, would I use the code below to take the address entered in the form and make it the variable 'formaddress'?
Comparing Array Contents
i'm having a small problem with getting information into a database. Basically, i've got a form with some elements in it, such as: name phone address for example. I pass these values to a function which finds out whether the action is associateds with the form is to insert, update or delete info from/to the database (using an HTML "hidden" field.) The field names in my database are the same as in my form. (name, phone etc...). Using mysql_fetch-field, I have an array with the field names in it. I read the values passed from the form into an array called $values with the form fields as keys ? I would like to set the entry as 'NULL' for each field in which there is no data to enter. I thought the best way to do this was by comparing the contents of both arrays, and where there was a key in $values corresponding to the fieldname, somehow assign the contents of $values to that fieldname in the query.
Creating Two Dates And Comparing Them
I need to create Date A from form fields and then subtract that from Date B (also created from form fields). That will give me the difference in time so I can apply an hourly rate to that result. The dates will be year, month, day, hour, minute (30 min increments). I can handle the majority of the program's logic, but the time part has me a little stymied. I pretty sure I'm going to need to build a date from the form inputs, but I can't really find anything similar to compare to. This is for a reservation script where a person can specify a start and end date and from that a total cost will be generated. No database is involved here.
Comparing String Lengths
I was wondering if anyone had any ideas on how I would go about determining which of 4 values grabbed from a database had the largest string length. My situation is that I have a link to a pop-up window which has dynamic content in a table. I am trying to have the "height" of the pop-up window, that is stated in the link determined by what will show in the pop-up window that day by looking at the database. I have already built a simple algorithm for the height based on how many rows will show in the table in the pop-up window, but since I wan't the width of the pop-up window to be constant, each row height can vary a bit depending on how long the strings are for certain (up to 4) columns in each row and this can mess up the simple algorithm I have now which just looks at how many rows will display to determine the height. Of course I could just go overboard with my calculations for each row, but sometimes I would end up with a lot of white space at the bottom of the pop-up which I don't want. So I figured if I can determine which value (column) in each row has the longest string, then I could determine how many lines (height) that row took up in order to get a more accurate overall height for my pop-up window. *Confused? Yes, I am a bit crazy So basically all I need though, as I said above is an effecient way to compare 4 string lengths to find out which is the longest.
Comparing A Text File
I was wondering if this is possible: Compare a row from a table to a row from a text file, and if that row is not in that text file, then delete it from that table, and move it to another one. Say for example I read in a text file and assign the following variables: PHP Code:
Comparing/Convert Dates
I need to convert two dates to text. For example i have: 2007-06-05 11:57:00.000 and 2007-06-08 03:12:00.000. I need to compare these two dates and tell the difference in text such as "3 days and 3 hours and 15 minutes" OR such as "3 days and 3 hours" how would I go about doing this?
Comparing Utf-8 Encoded Text
I don't know if you would classify "mysql" as a program but mysql and php are two seperate entities, call them whatever you like, but i'm trying to make a point that I THINK that they treat strings differently, and have different methods of parsing strings. I am storying text from many different languages in my mysql with charset utf-8, and collation utf8_bin all the text being parsed in the php script is also encoded in utf-8, as the script is saved in utf-8 charset. now i am wanting to allow users to sign up or register with my website, and be able to choose usernames in foreign alphabets if I am going to do this, i need to be positive that I can successfully compare usernames from any language encoded in utf-8, and test for their uniqueness. for example fredrico who is from spain signs up at my website, when he chooses his spanish username I will query the mysql db for WHERE username='$fredrico' I need to be positive that $fredrico compared to any other utf-8 encoded string can successfully find a match with only the same spanish characters. in other words for this to work, I need to know if the letter aleph in hebrew encoded in utf-8 is unique and will never equal another character from another alphabet Is this true?
Comparing Dates With Strtotime()
I'm building a schedule script--well, modifying one I built last year--to add an event every second and third Sunday of the month. However, when I try to find that Sunday, and compare to my timestamp, I run into trouble: $myDays = getMyDays(); Code:
Comparing 2 Arrays In A Loop
I have 2 arrays: $array1[] = 'hello'; $array1[] = 'how'; $array1[] = 'are'; $array1[] = 'you'; $array1[] = 'bob'; $array2[] = 'hello how'; $array2[] = 'are you steve'; I want to compare $array1 with $array2, and if any value of $array1 is found in $array2 I want to perform an action I know this has to be in a loop, i'm confused about how to set it up.
Comparing Time Stamps
As the title of the topic suggests in trying to compare to sets of time stamps for a 24 hour or more difference I have a database with a Timestamp field set to CURRENT_TIMESTAMP (so when anything is updated or inserted the timestamp is set to the time that happens) I couldn't find anything relevant either with a google attempt.
Comparing Street Addresses (abbreviations And Such)
I have a database table that contains street addresses in the following format: 123 Any St. 456 Some Rd. 7789 That Blvd. etc. I.e. Street number, street name, standard abbriviation of road type. Now, I have a web form where people will type in an address. The problem is for what I have in the database (123 Any St.) a person might type in: 123 Any St. 123 Any Street 123 Any 123 Any Street Apt. 4D 123 Any St. # 4D #4D 123 Any St etc. What would be my best bet here? What I need is a sort of "best match" ability (I'm assuming), but I'm unsure how to do it. Anyone have any really good ideas? Note: I'm not interested in Apartment numbers. They should be ignored. I'm only concerned with building locations.
Comparing Strings To Show Differences
I would like to have a feature that displays the changes/differences made to a body of text after someone edits something. ie: I go to edit Entry1, this is what I have... Quote: Hello, this is the entry. I make some changes and then hit preview, and this is what it shows: Quote: Hello, this is not the entry. Therefore you can visually see the differences/what you changed. Any ideas?
Comparing Two Times Using Unix Timestamps
I want to use the unix timestamp to select a time like this code displayed below. Currently its using the strftime function of php but its not accurate because its comparing two string values and I want it in timestamp interger format. PHP Code:
|