Page 2 - Query max and min with two situation, same and different dat

if php code is the solution can you give me an example

I really don't know where to start..

Thank you so much.. , I told him my situation...but he told me that i can do it:(

Posted On: Monday 29th of October 2012 06:14:39 AM Total Views:  442
View Complete with Replies

Related Messages:

Resolved Average page display from field query   (270 Views)
hope is having a nice holiday weekend column type is (double), storing a microtime value I am trying to get the average time from a field named "prctime" from a table TEST, but I keep getting errors. PHP Code: require"connect.php"; //IgetsuppliedargumentisnotavalidMySQLresultresourcewhenIrunthis $query=mysql_query("SELECTavg(prctime)FROM`TEST'"); $result=mysql_query($query); $row=mysql_fetch_array($result); echo$row[prctime]; echo$row[0];
Best way to save HTML page in MySQl   (294 Views)
What is the best way to save a HTML page in MySQL I just need the text not the images. I intend to save several 1,000 pages. Should I create a field or referance the pages which would be saved as html files to a directory. I'm not sure what the pros/cons of each method or if there are any other ways to do this.
Custom MySQL results printing in web page   (259 Views)
Hi all, If have a table with the following fields (and a few example records): Name Age Country -------------------- David 34 UK Julia 41 USA Timothy 26 UK Andrew 21 CAN Tina 36 CAN Fiona 28 UK Matthew 19 USA Lauren 21 UK Kate 45 USA Neil 39 USA Mike 42 CAN Now, I want to print out the contents of this table in a web page to list all users but the format I want is: UK -- David 34 Timothy 26 Fiona 28 Lauren 21 USA ---- Julia 41 Matthew 19 Kate 45 Neil 39 CAN --- Andrew 21 Tina 36 Mike 42 Of course I can ge tthe whole table and sort via the country field to get: David 34 UK Timothy 26 UK Fiona 28 UK Lauren 21 UK Julia 41 USA Matthew 19 USA Kate 45 USA Neil 39 USA Andrew 21 CAN Tina 36 CAN Mike 42 CAN But, I need the country as a heading then the users printed out as I showed earlier. Hope someone can help. I have a feeling this is quite easy but I'm stumped! David
Multiple pages to one..   (220 Views)
i have a litle question.. i have a catalogue database with a order-order details and products tables. now when an order is passt it goes true an xml flash page.. but i need to mode it so i want to drop the flash and only use php. so in the databse in the order table there is orderID and user info.then in orderDetails theres the orderID and a product id so what i did up to know is extract all orders so i get orderID name price.. but know i need details so i linked it to a OrderDetails page that gives me OrderId ProductId QTY.. so thats cool but know i need to get the product details from Product Table.. so Product id gives me a descrition of the products... ahhh is there a way to make it onelol! or at least to see the order page but when you click more details or print you get the product descritption... thx !!
MySQL data insertion and page need to be refresh   (223 Views)
Hi Guys, I am new here and find this forum very interesting and helpful. I need a help from you regarding page refresh. I got a auction script, and i want that everytime someone bid and data goes into the MYSql the page refresh shows the current bid, Like once the data updated in mysql through someone place a bid and page refreshes itself, where the bid field is present on the page. I hope you understand what i mean. Thx in advance Lezzo
How can i connect my asp page to mysql database   (206 Views)
hello, i am raghvendra khandal . i am making a asp file and want to connect with mysql database. i have created a system dsn called mysql_new with myodbc created successfully. my asp is on remote machine. and my database is on local machine where i created dsn. i have added a line in asp for connecting mysql using dsn "DSN=mysql_new;uid=root;pwd=raghu;" but it is giving error like this: Error Type: Microsoft OLE DB Provider for ODBC Drivers (0x80004005) [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified /forMySQL.asp, line 11 i have also used connection string like "DRIVER={MySQL ODBC 3.51 Driver};SERVER=localhost;port=8080;DATABASE=mysql;uid=root;PWD=raghu;OPTION=3;" but it gives same error in browser could any body help me
Mysql, simple list from table over multiple pages   (221 Views)
Ok, will keep this simple. On my site i want to print out the list of entries in my database in Descending order latest entry first etc... and down the line till theres no more entries using the date field, that isn't a problem until i try to span this over multiple pages. ie flash1.php = print out the latest 3 entries (easy) flash2.php = print out the next 3 entries 4,5,6 (This is where im stuck) in flash1 i just use a while loop to step through my row array and print out 3 entries. in flash 2, i don't understand how you tell your php to print out the next 3 or however many u need to, using a simple loop from where u left off on the last page. This is the code im using on flash1 Code: $result = mysql_query("SELECT * FROM flashs ORDER BY date DESC") or die("Error! 3" . mysql_error()); $i=1; while($i
Speed of page loading. Limitations of the COUNT() / GROUP BY?   (195 Views)
On my home page I would like to display 5 drop down lists containing 100-400 geographical locations. Each location will have a set number of attributes which I would like to display in brackets next to each location in the drop down list. Because I am new to mysql and php my first thought was have a field in my database table on the same row as the locations that would represent the number of attributes (which i expect to grow over time). This number would be updated after delete or insert queries. I imagined that this method would be the quickest way to achieve the deed outcome as far as page loading is concerned. However, after reading kevin yanks chapter on advanced sql queries I am now aware that, in following this method, I would need to have tables locking whenever an insert or delete query is executed (in order to maintain synchronisation). This point made me question the speed advantage I anticipated with my primary solution. Kevin yank explains how to use the COUNT() / LEFT JOIN and GROUP BY clauses to avoid this method without the unacceptable slowness that would result from using the COUNT() query for every entry in the table. My concern however is that by incorporating a query where counting is involved on such a large scale could result in a very tediously slow loading homepage. Could anyone with experience of large databases advise me on the relative pros and cons of either method please
Query For Functionality: Users who viewed this page also viewed this page   (257 Views)
, I'm trying to figure out the best way to do a "Users who viewed this page, also viewed this page" based off data from a mysql DB. I should be able to make this work with just the PageID and UserID which are both columns in the same table. So far I was thinking I could query all the users who viewed PageID 15. Lets say that returns UserID's 1,2,4,6. I Could then run a separate query and do the totals in PHP. So if user 1 viewed page 3,4,5 and user 2 viewed 3,7,8. Then so far the results should report back that page 3 is the most relevant page so far to return. Obviously VERY inefficient. But I hope this helps to explain what I'm trying to do. If anyone could get me started on what command or type of join to use for this then I could probably do the rest. Maybe I'm over complicating thing.
Displaying username in in user page   (183 Views)
Hi all, I've labelled my textfield name as "u_username" and after filling up the text and password fields, it will passthrough an authentication process, User.php: // here i put the username into a variable $username = $_POST['u_username']; > in the index.php, i've stated the code but i tried out many times it just can't display the username. Is there something i miss out or i've done any mistakes Seeking guidance from all of you out there
INSERT Statement syntax error from ASP page   (198 Views)
Hi all, I'm getting the following error when trying to execute an INSERT statement from an ASP page: Code: Microsoft OLE DB Provider for ODBC Drivers (0x80040E14) [MySQL][ODBC 3.51 Driver][mysqld-4.1.14-nt]You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'default) VALUES('1','C:\Inetpub\wwwroot\IMG\arc2_16.png','1')' at line 1 /PwebUImages.asp, line 306 Here's the sql string on my ASP page: Code: query="INSERT INTO image (userID,iURL,default) VALUES('" & user & "','" & Server.MapPath("IMG") & "\" & fName & "','" & def & "')" In my DB the columns in the image table are set up as: userID = INTEGER iURL = VARCHAR(255) default = TINYINT Can anyone see what the problem could be I've got a feeling it's something to do with the tinyint but i'm not sure... Let me know if you need anymore info,
Webpage Database   (340 Views)
I am building a site that will have multiple products. I want to build a database with product description, pics, price, etc. and be able to have a standard page that will pull from this database and fill in the standard page with the product content. My purpose is to have a formal database rather than hundreds of HTML pages. I have had success learning a little PHP and MySQL, but I'm not sure how to approach my specific need. It seems like I should have links to specific products and I could pass parameters to MySQL functions to pull from my database, but an href doesn't seem like it could pass arguments. Any thoughts
Having trouble executing stored procedure through .net web page   (248 Views)
I am trying to execute a stored procedure through .NET but the stored procedure doesn't seem to work. I know that my code in .NET works without any errors and I am almost sure my stored procedure code is correct but it is not executing what I want it to do. In the code if I want to change the date in the drop down box and then hit the Save button it should execute the stored procedure in the Save button click event to update the record in the database. Here is the code for the Save button: Code: Protected Sub SaveButton_Click(ByVal sender As Object, ByVal e As System.EventArgs) ' Using onyxConnection Try dim @iReturnCode Dim cmd As New SqlCommand onyxConnection.Open() cmd.Connection = onyxConnection cmd.CommandType = CommandType.StoredProcedure cmd.CommandText = "cnpcuStudentSessionDate" cmd.Parameters.AddWithValue("@iProductId", lblProductID.Text) cmd.Parameters.AddWithValue("@chUserId", lblUpdateBy.Text) cmd.Parameters.AddWithValue("@dtPurchaseDate", ddlSession.SelectedValue) cmd.Parameters.AddWithValue("@dtSchEnrDate", ddlSession.SelectedValue) 'cmd.Parameters.AddWithValue("@iProductId", txtAppProjNum.Text) 'cmd.Parameters.AddWithValue("@iProductId", txtAppProjNum.Text) cmd.ExecuteNonQuery() Catch ex As Exception Dim a, b a = ex.ToString b = a.ToString Finally End Try End Sub In the stored procedure I am selecting an existing record from the database and updating it with a new date. Here is the code for the stored procedure: Code: use DB if exists (select * from sysobjects where name = 'cnpcuStudentSessionDate' and type = 'P') drop proc cnpcuStudentSessionDate go create procedure cnpcuStudentSessionDate @iProductId int, @chUserId nchar(10), @dtPurchaseDate datetime, @dtSchEnrDate datetime, @iReturnCode int = Null output With Encryption as set nocount on /* declare variables */ declare @dtNow datetime /* M003D Begin*/ declare @iIndividualId int, @dtReceivedDate datetime, @dtEnrollmentDate datetime, @vchScheduleNumber varchar(255), @vchCreditScore smallint, @siGuidesRequired smallint, @dcDeposit decimal(9, 2), @dcPendingDeposit decimal(9, 2), @dcDiscount decimal(9, 2), @dcShareDeposit decimal(9, 2), @dcNetAdjustment decimal(9, 2), @siTerm smallint, @dcPaymentAmount decimal(9, 2), @dtFirstDue datetime, @dtNextDue datetime, @dcInterestRate decimal(8, 5), @dcGrossSale decimal(9, 2), @dcInterest decimal(9, 2), @dcContract decimal(9, 2), @dcCurrentBalance decimal(9, 2), @dcContractPaid decimal(9, 2), @dcInterestPaid decimal(9, 2), @dcAccruedInterestBalance decimal(9, 2), @dcInterestPerDiem decimal(9, 2), @dcEstimatedPayoff decimal(9, 2), @siTotalPayments decimal(9, 2), @dcTotalPaid decimal(9, 2), @dtDisbursementDate datetime, @dcChargeOff decimal(9, 2), @dcInvoiceBalance decimal(9, 2), @dtInvoiceDate datetime, @iInvoiceStatus int, @dcAdjDiscount decimal(9, 2), @dcSalesTax decimal(9, 2), @dcPendingSalesTax decimal(9, 2), @iOwnerId int, @dcFinancedSalesTax decimal(9,2) --M001A /*M003D End */ --M003A Begin declare @iSiteId int, @chLanguageCode nchar(4), @iContactId int, @chProductNumber nchar(20), @vchSerialNumber nvarchar(50), @flQuantity onyxfloat, @iTrackingId int, @iSourceId int, @iStatusId int, @iAccessCode int, @vchUser1 nvarchar(30), @vchUser2 nvarchar(30), @vchUser3 nvarchar(30), @vchUser4 nvarchar(30), @vchUser5 nvarchar(30), @vchUser6 nvarchar(30), @vchUser7 nvarchar(30), @vchUser8 nvarchar(30), @vchUser9 nvarchar(30), @vchUser10 nvarchar(30), @dtUpdateDate datetime --Variables needed for incident Update. declare @iIncidentId int, @tiLCMSAccount tinyint, @iIncidentCategory int, @iIncidentTypeId int, @vchAssignedId nvarchar(255), @vchProductId nvarchar(255), @vchDesc1 nvarchar(255), @vchDesc2 nvarchar(255), @vchKeyWords nvarchar(255), @iPriorityId int, @iCode1 int, @iCode2 int, @iCode3 int, @iCode4 int, @iTime int, @iLabor int, @tiImage tinyint, @chAssignedTo nchar(10), @chInsertBy nchar(10), @dtInsertDate datetime, @tiRecordStatus tinyint, @iReminderId int --M003A End /* initialize variables */ set @dtNow = getdate() /* set default values */ set @iReturnCode = 0 if isnull(@iProductId,0) > 0 and isnull(@vchUser7,0) > 0 begin --Get the current values of the customer product record. SELECT @chLanguageCode = [chLanguageCode] ,@iContactId = [iContactId] ,@chProductNumber = [chProductNumber] ,@vchSerialNumber = [vchSerialNumber] ,@flQuantity = [flQuantity] ,@dtPurchaseDate = [dtPurchaseDate] ,@iTrackingId = [iTrackingId] ,@iSourceId = [iSourceId] ,@iStatusId = [iStatusId] ,@iAccessCode = [iAccessCode] ,@vchUser1 = [vchUser1] ,@vchUser2 = [vchUser2] ,@vchUser3 = [vchUser3] ,@vchUser4 = [vchUser4] ,@vchUser5 = [vchUser5] ,@vchUser6 = [vchUser6] ,@vchUser7 = [vchUser7] ,@vchUser8 = [vchUser8] ,@vchUser9 = [vchUser9] ,@vchUser10 = [vchUser10] ,@dtUpdateDate = [dtUpdateDate] FROM [OnyxTCN].[dbo].[CustomerProduct] WHERE [iProductId] = @iProductId --If we have successfully registered this course in the LMS, proceed. if @tiLCMSAccount = 1 begin --Set the tracking ID for the product to the Course Registered tracking id. --Sandbox: 5465 Live: 7743 Set @iTrackingId = 7743 end else begin --Set the tracking id for the product to the Course Not Registered tracking id. --Sandbox: 5474 Live: 7771 Set @iTrackingId = 7771 end if (select iTrackingId from customerProduct with (nolock) where iProductId = @iProductId) @iTrackingId begin --Update the customer product table. exec @iReturnCode = wbospsuCustomerProduct @iSiteId, --iSiteId @iProductId, --iProductId @iIndividualId, --iOwnerId @chLanguageCode, --Language Code @iContactId, --Contact ID @chProductNumber, --Product Number @vchSerialNumber, --Serial NUmber @flQuantity, --Quantity @dtPurchaseDate, --Purchase Date @iTrackingId, --Tracking Id @iSourceId, --Source Id @iStatusId, --Status Id @iAccessCode, --Access Code @vchUser1, --UDF1 @vchUser2, --UDF2 @vchUser3, --UDF3 @vchUser4, --UDF4 @vchUser5, --UDF5 @vchUser6, --UDF6 @vchUser7, --UDF7 @vchUser8, --UDF8 @vchUser9, --UDF9 @vchUser10, --UDF10 @chUserId, --chUpdateBy @dtUpdateDate, --dtUpdateDate null, --tiRecordUnlock null --tireturnType end return @iReturnCode end go grant execute on cnpcuStudentSessionDate to public go
UTF-8 web page saving to LATIN1 database   (229 Views)
Our database is set to LATIN1 and our site UTF-8. It has been like this a while and we have a lot of records in the database with charaters like where it should be showing for example. What I'm trying to do is pull these records out to a UTF-8 web page then save back to a new database set to UTF-8 but this doesn't seem to make any difference. I really want to clean the data up but think I may have got this right round my neck! Does anyone know a better way to do this
Access Database and Frontpage   (190 Views)
my name is John and I am putting some web page up and it needs a Access Database on it, well I create the web page called Contact which is a FROM the contains Access Databse. So I ran the web page put in the information and click submit and it gave me a confirmation, that work fine! so I went to the file where I save the results of the web page 'fpdb' and opened it there was nothing stored in that folder I would like to know is there anything else I was missing here like addition step to configure the Access it just a simple contact information from the web site which I would like to access the end result of it! Please let me know,
Query help for a PHP/mysql page.   (218 Views)
I'm debugging a query I'm using php to send, but when I run the page, it's giving me an error which I don't know why it's an error. I've echo'd the query that it's sending, as well as the error result. If any more information is needed, please let me know. INSERT INTO mainb (VIN, MAKE, MODEL, YEAR, VENDOR, DEALER, CUSTOMER, CUSTADDRES, ADDRESS2, CITY, STATE, ZIP, COUNTRY, CONTACT, TELNO, CUSTPO, ORDERNO, INVOICENO, INVDATE, INSERVICE, VACMODELNO, VACSERNO, GPM_PSI, GALLONS, CHENGMAKE, CHENGMODEL, CHENGHP, CENGSERNO, TRANSMAKE, TRANSMODNO, TRANSSERNO, WPUMPMAKE, WPUMPMODNO, WPSERNO, AUXENGMAKE, AUXENGMOD, AUXENGSN, PAINTCODES, PTMODULE, PTCAB, PTSTMODULE, PTSTCAB, PTSTBOOM, MISCINFO, S700NO, HYDROPUMP, HYDROPUMP#2, HYDPUMPMOD, HYDPUMPSN, HYDPUMPMOD#2, HYDPUMPSN#2, HYDROMOTOR, HYDROMOTOR#2, HYDMOTORSN, HYDMOTORSN#2, PUMPOFFMAK, PUMPOFFMOD, PUMPOFFSN, TRANCASEMK, TRANCASMOD, TRANCASESN, BLOWERMAKE, BLOWERMOD, BLOWERSN, SSMAKE, SSMODEL, SSSERIAL, PTOMAKE, PTOMODEL, PTOSERIAL, CARDRECD, UPSSIGD, SIGNBY, WATERDECAL, FOLLOWUP, EXTENDED, WIRELESSREMOTE, INSPECTORCAM, ELEGIBLE) VALUES('TEST', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '')You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'VALUES('TEST', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '', '' at line 2
Preventing duplicate submissions via PHP page (was: MYSQL n PHP help)   (254 Views)
i am creating a guestbook for wap... since wap surfing is some times timed out since it depends on the signal strengent i am getting double n more posts of the same content by the same user... so i want to write a script which checks the lastest entry in the db n match it with the present submitted entry ...if both match it needs to be redirected to diff page... i want help to pull out the lastest entry from the DB should i do it using SQL query Code: Original - SQL query Code SELECT id, name, date_format(entry_date, '%b %e') as post_time from guestbook ORDER by entry_date desc LIMIT 1, 1
Links not working in the whole page!   (252 Views)
Dear people, I need your help! Ive got this page that was working good and suddenly none of the links are working anymore (neither the images nor the buttons or text). It doesnt seem to be the JavaScript, as Ive tested it without variables and it was fine. Now Ive run out of ideas .. Anyone can give me a clue
Implications of database page sizes   (193 Views)
InnoDB's default database page size is 16K, but can be changed by recompiling the code to anywhere from 8K to 64K. My question has to do with what exactly a database page is, and what are the implications of its sizing I know very vaguely what a database page is, though it would be great if somebody reading this could explain it in their own terms. Also, what are the tradeoffs between having a smaller versus a larger database page size And what kinds of signs would alert a DBA as to the need to look into their database page size I hope somebody can point out these issues in detail.
Select distinct columns in left join query   (242 Views)
I'm trying to count the number of returned distinct results from each column on a left join query with 4 tables. Code: SELECT a.ad_id, count( w.wl_id ) AS wildnr, count( s.ds_id ) AS sitenr, count( o.op_id ) AS opnr FROM tblads a LEFT JOIN tblwild w ON a.ad_id = w.ad_id LEFT JOIN tblops o ON a.ad_id = o.ad_id LEFT JOIN tblsite s ON a.ad_id = s.ad_id WHERE a.ad_id = 247 GROUP BY a.ad_id, w.wl_id, s.ds_id, o.op_id But it counts all the returned rows (of course) of all the returned possible combinations (of course)! But the question is how can I get the three numbers from all returned disctinct results of each column Now the result is (for example): id name accom favfruit ------------------- 1 john house apple 2 john house orange 3 john house pear 4 john farm apple 5 john farm orange 6 john farm pear Which results in the count of: name = 6, accom = 6, favfruit = 6 While what I want is: name = 1, accom = 2, favfruit = 3 Anyone any idea