Canman2005
-
Posts
669 -
Joined
-
Last visited
Never
Posts posted by Canman2005
-
-
In my sample table
ID 1 & ID 2 - these are main topics (hence `type`=1)
ID 3 & ID 4 - these are replies to main topics (hence `type`=2)
ID 3 is a reply of ID 1 as it has TOPICID set to 1 (ID number 1)
ID 4 is a reply of ID 2 as it has TOPICID set to 2 (ID number 2)
-
hi teng84
Yes, your right about what each TYPE means.
How can I do this join? Not something i've ever looked into.
Can you give me some guidance?
Thanks
-
hi php_tom
Thanks for that, I did think of that, but it seemed like alot of work.
I guess that's the best way to do this.
Thanks
Dave
-
If you need anymore info, just ask, im working on this until I either crack it or someone manages to figure it out
Thanks
-
Just to try to make it easier
So with my table example
ID | TYPE | TOPICID | TITLE | DATE | TIME
1 1 1 post 1 2007-04-04 13:23:54
2 1 2 post 2 2007-04-07 23:12:32
3 2 1 reply 1 2007-04-10 08:23:53
4 2 2 reply 2 2007-04-10 12:32:12
When the query is run, it should return the rows as
ID 2
ID 1
The reason it should return ID 2 first, is that the last row to be posted was ID4 (posted at 12:32:12 on 2007-04-10) and as ID 4 has a TOPICID as 2 then it would return row 2 (ID 2) as the first row, as that was the last replied to TOPIC.
As we are only returning rows with a TYPE as 1, then it wouldnt return ID 3 or ID 4, but ID 4 was the last posted row.
Does that make anymore sense?
Thanks
-
Hi all
I wonder if someone can help, im really really stuck.
I have a little message board that I setup, there is one table which runs the whole thing, this is a sample of the table;
-------FORUM---------
ID | TYPE | TOPICID | TITLE | DATE | TIME
1 1 1 post 1 2007-04-04 13:23:54
2 1 2 post 2 2007-04-07 23:12:32
3 2 1 reply 1 2007-04-10 08:23:53
4 2 2 reply 2 2007-04-10 12:32:12
Let me explain what each field means
ID - this is an auto ID
TYPE - 1 means its a main topic \ 2 means its a reply to a main topic
TOPICID - this is the ID number of the main topic
TITLE - the title of the topic or reply
DATE - date posted
TIME - time posted
What I currently do, is run a query to get all rows which have a TYPE as 1, basically this gets all the main topics, so if I run the QUERY
SELECT * FROM `forum` WHERE `type` = '1'
This returns all the topic posts.
Once a topic is clicked on, I run another query to get the replies to the topic clicked on, this query is;
SELECT * FROM `membersforum` WHERE `type` = '2' AND `topicid` = '".$_GET['topicid']."'
This then grabs the replies to the topic selected.
What I want to do is to alter the first QUERY
SELECT * FROM `forum` WHERE `type` = '1'
so that it returns all rows that have the `type` as 1, but ORDER these results with the first row returned, being the row that had the last reply (type 2) left on it.
Basically I want to order all rows which have `type` as 1 in an order which has the row with the last reply to it, at the top, so I can sort them by last replied.
Does that make sense?
Sorry, I tried to write this as best I can to explain my problem.
Does anyone understand what im trying to do and can anyone help?
Thanks in advance
Dave
-
Cant you store their ID number as a session when they login and then whenever they upload an image, insert the image into a table along with the users ID number.
Then you can grab the users images from that table.
Does that help?
-
Hi
Is there anyway to speed up this query? It seems to crash the server when run on a table with anymore than 40,000 records
-
Any ideas?
Am I not explaining it right?
-
Hi
I dont think I explained it very well.
Basically I want to get the ID number of all orders held in the "ordertransactions" table which were placed in August, I then want add together all the TOTAL fields in the 'orderlog' table which have the ORDER ID number of any of those orders placed in August on the `ordertransactions` table.
On my example data, it would look in the table
<< ordertransactions >>
and get the following rows (as they are the month of August)
ID DATE
876 2007-08-12
899 2007-08-14
It would store the ID numbers and then get all the rows in the table `orderlog` which have those ID numbers stored in the ORDERID field;
ID ORDERID TOTAL(£)
1 876 29.99
2 876 13.99
3 899 10.00
It would then add up all the totals for those ID's and then output it the TOTAL added together.
So it would get ID numbers `876` and `899` and look them up in the ORDERID field of the `orderlog` table, which are ID numbers 1,2 and 3 and then add up the total for the TOTAL field, outputting 29.99 + 13.99 + 10.00.
Does that make much sense?
Thanks in advance
Dave
-
Does anyone need anymore info to help me or is this all ok?
-
Hi all
I have a small online shop, i have 2 SQL tables, one called "orderlog" which stores each item the user has purchased and also a table called "ordertransactions" which store the master details of each order. Each row of the table "ordertransactions" has a unique ID number.
An example is
<< orderlog >>
ID ORDERID TOTAL(£)
1 876 29.99
2 876 13.99
3 899 10.00
ID - this is a autoincreased number
ORDERID - this is the ID number for the master order details in the table `ordertransactions`
TOTAL - this is the total for each product bought
<< ordertransactions >>
ID DATE
876 2007-08-12
899 2007-08-14
ID - this is a autoincreased number, this number is what is held in the field `ORDERID` in the `orderlog` table.
DATE - this is the date the order was placed, in the format YYYY-MM-DD.
As you can see, in the table `ordertransactions` there are 2 orders held, in the table `orderlog` you can see there are 3 rows, the first 2 rows relate to order ID 876 and the last row relates to order ID 899.
You will now notice that inside the table `ordertransactions` there is a date held in the format YYYY-MM-DD.
Okay, so what I want to do is to run a SUM query
SELECT SUM(price) FROM ***
on the `ordertransactions` table to return the total earned in a particular month. So if I run the query for the month August (08) then it would check the table `ordertransactions" for all rows where the month value equals 08, it would then grab the ID numbers for each of these rows and do a SUM on the `orderlog` table for all rows which contain those ORDER ID numbers, this would then return the TOTAL spent during the month 08.
Does that make sense?
Can anyone help, i've been trying to crack this for the last 9 hours and im getting no where fast.
Thanks in advance
Dave
-
Hi
So how can I define that so that if I use
$emails
within a INSERT statement, it would print
email@domain.com; name@domain.com;
Does that make sense?
Thanks
-
Hi all
I have a simple query
$sql = "SELECT * FROM siteusers"; $query = @mysql_query($sql,$connection) or die(mysql_error()); while ($row = mysql_fetch_array($query)) { print $row['email'].'; '; }
This basically produces something like;
email@domain.com; myname@domain.com;
How can I define these as a variable such as
$allemails;
So that I can insert it into a INSERT query.
And lastly, how can I remove the symbol ; from the last row returned
Can anyone help?
Thanks
Dave
-
Brill
Thanks so much
-
Thanks
I tried
<?php $upload_folder = '../files/904/'; $upload_files = '../files/904/904images.zip'; system('unzip -d $upload_folder $upload_files'); ?>
But that doesnt seem to do anything when I run the page.
Any ideas?
Thanks
Ed
-
Thanks
I tried
<?php $upload_folder = ../files/904/ $upload_files = ../files/904/904images.zip system('unzip -d $upload_folder $upload_files'); ?>
But that doesnt seem to do anything when I run the page.
Any ideas?
Thanks
Ed
-
Hi all
Im using the following to unzip files on the server
<?php system('unzip filename.zip'); ?>
How can you define the target of where files should be extracted?
Any help would be ace
Thanks
Ed
-
Sorry, just for easy reference really.
-
Cool
Thanks
Is there a way to firstly remove the *C* so that it isnt printed and secondly, can be it be changed so that the start tag looks like
*C-start*
and the end tag would look like
*C-end*
Thanks again
Dave
-
Sorry, might not be making much sense.
Basically I want to get rid of everything that is held between two tags, so if the page content was
-----------------------
Welcome to the page
*C*
click here
*C*
----------------------
then it would strip out the following
*C*
click here
*C*
and simply print
--------------------------
welcome to the page
--------------------------
does the make any sense?
Thanks
-
Thanks for that, but what I meant was that it would replace anything between
*C*
So it would basically use them as tags, I could change them all to
*C-start*
and
*C-end*
so that it knows what the start tag is and what the end tag is
can this be done in this case?
Thanks again
Dave
-
Hi all
Wonder if someone can help
What I have is text for each page of my site which is stored in a sql table, to print the text on the pages I use
<?php print $row['content']; ?>
The following is an example of the type of content stored
------------------------------------------------
Welcome to the contact page
*C*
page check
*C*
Please use the navigation bar above
------------------------------------------------
What I want to do is to remove the section of the content which is between and including
*C*
page check
*C*
So it would just print the content as
------------------------------------------------
Welcome to the contact page
Please use the navigation bar above
------------------------------------------------
Can this be done?
Any help would be great
Thanks in advance
Dave
-
does anyone have any clues? Im a little baffled by what to do
Help Sorting Results
in PHP Coding Help
Posted
thanks teng84, ill check that out another time, I think php_tom's idea is the easiest for the moment.
question, how can I convert an old date and time to the time() format?