t_machine
-
Posts
104 -
Joined
-
Last visited
Never
Posts posted by t_machine
-
-
hi, I really hope someone can help with this problem.
I have two tables. One stores userid, cur_timestamp(timestamp), earn(float 8,2)
The second table has uid(this matches the userid), time_paid(timestamp), paid_amt(float 8,2)
Table 1.
+----+----------+---------------------+--------------+
| id | userid | cur_timestamp | earn
+----+----------+---------------------+--------------+
Table 2.
+----+----------+---------------------+--------------+
| id | uid | time_paid | paid_amt
+----+----------+---------------------+--------------+
The first table adds a row each time a userid gets a money so there will be many entry for each userid.
The second table stores each time the admin pays the userid.
What i am trying to do is write a sql query to first check if the userid in table 1 has a sum of $50 and has not been paid yet or has earned $50 or more since the last payment(which should check table 2 to see if they received a payment yet).
Thanks for any help on this. I do not even know where to start
-
Thank you very much, works perfectly
-
hi, I have a table that stores dates with the mysql CURRENT_TIMESTAMP. This stores each entry with the format (2008-11-12 00:11:08).
The problem I am having is getting the results for the current date. The following query will explain what I mean.
$sql = "SELECT * FROM my_table WHERE date_field = CURDATE()";
This does not give any results even though the current date is the same as a few records in the database. Any help would be greatly appreciated.
Thanks:)
-
Hi, I have a database that stores data each day using the time() function. How can I run a query to get results from the previous week.
Example:
Table -> id, name, date_added( time() )
How can I select all names from 1 week ago.
Thanks for any help
-
Thanks for the reply
I tried this code so far but I am sure it's on the wrong path
$lastmonth = mktime(0, 0, 0, date("m")-1, date("d"), date("Y")); $wsnow1 = date("F,Y", $lastmonth); $wsdformat = '%M,%Y'; $sql = "SELECT COUNT(id) + 1 AS rank FROM {TOPUSER_TBL} WHERE id>(SELECT * FROM {TOPUSER_TBL} WHERE DATE_FORMAT(FROM_UNIXTIME(date_added), '".$wsdformat."') ='".$wsnow1."' AND userid='$mid') AND DATE_FORMAT(FROM_UNIXTIME(date_added), '".$wsdformat."') ='".$wsnow1."'";
-
I'm wondering if anyone could help with this problem.
I have a table that stores id(autoincrement), userid, date
Each time a vote is casted a new entry is added to the table with the userid and current date. What i am trying to do is get the rank for that user last month by counting the amount of times their user id exists for the last month and comparing that to others for that month.
I can't seem to construct a query for what i need done. Any help would be greatly appreciated.
Thanks
-
Thanks very much for the reply That is exactly what I needed.
-
hi, i am using a tutorial I found that gets the image src, image type but does not show how to get the name itself.
example:
$data = 'Some text here <img src="images/myimg.jpg" border="0"> more text.'; $pattern = "/src=[\"']?([^\"']?.*(png|jpg|gif))[\"']?/i"; preg_match_all($pattern, $data, $images); echo $images[0][0]; //src=images/myimg.jpg echo $images[1][0]; //images/myimg.jpg echo $images[2][0]; //jpg
How can I get "myimg" from the src url?
Thanks for any help
-
Thanks for the replies
I tried this and it seems to do the trick
for($i =0; $i<$count; $i++){
if($i == ($count -1)){
echo 'this is last in the loop.';
}
}
-
Thanks for the replies I will expand a little on my example.
In my example the "10" is defined but in my codes the number is determined by the results in a database. I am using the "for" loop to display the results and would like for it to reach the last result and echo some extra content.
Thanks
-
I'm trying to get the last value in the for loop so I can assign a value to it.
Example:
for($i =0; $i<10; $i++){
if(is_last_value_do_something){
echo 'this is last in the loop.';
}
}
Thanks for any help
-
This could be a difficult one and not sure if there are any solutions. I would like to get the url that a page lands on using most likely cURL from a dynamic url.
Example:
dynamic url: http://www.mysite.com/tutorial/2352
landing url: http://www.mytutorials.com/create-cool-icons.html
Is there any way to get that landing url using php?
Thanks for any help
-
Hi, I am wondering if anyone could help with this problem. I would like to save images from the url in a folder on my server.
Example
http://www.google.com/intl/en_ALL/images/logo.gif [link to google image]
How can i save the logo.gif in my folder "images/"
Thanks for any help
-
Thanks for the reply.. I actually want to display results that are within the current month
example
Select * FROM table_name WHERE date="THIS MONTH"...
What can I replace THIS MONTH with to get the results for the current month
Thanks for any replies
-
I have a sql query that already gets the current date using DATE(NOW()) but how can i get the current month instead?
Any help would be greatly appreciated.
-
Thank you all for the prompt replies I went with sasa as it used mysql to do the calculation instead of looping through thousands of results.
-
Thanks for the reply I know how to order them but how would i user a " WHERE userid='2' " tell where that user's page view rank.
Thanks
-
hi, i have a database that stores views to a user's profile. Is there a script i could use to sort the views and tell what number the user ranks in page views?
example:
user 1 (200 views)
user 2 (400 views)
user 3 (20 views)
user 4 (1000 views)
How can I tell where user 2 ranks with php? In this case it would be second..
Thanks for any help.
-
I hope someone can help with this as it is very important to the database script I am using.
The script is used to cache msql queries but the aggregate() is stripped from php5.
This is the aggregrate used
aggregate($db, "sqlCache");
I must also mention this is getting it's data from a class file so $db = new dbcon($host, $user,.....);
How I can replace the aggregrate()? Any help is greatly appreciated.
-
I have a table that has columns "id", "hits" and votes" . Is there a way to write the sql query that will sum(hits)+sum(votes) and display the results where the totals are the largest.
Any help will be greatly appreciated.
-
Thanks very much The array was what i needed. I just made sure to check first it is an array and during the loop check if it's the first result. If it is the first result, I just remove the "OR". Works great!
-
I am wondering if anyone can help with this. I already know the basics of searching mysql but if the user has a space, it does not treat the search as "OR".
Example:
Seach phrase => "cool car"
Notice the space? For some reason my results are only if the exact phrase cool car exists but not cool bike or red car.
How can I have it search mysql and return any matches even if the phrase does not exists?
Thanks
-
Thank you very much for your prompt reply. It works perfectly
-
Hi, I am wondering if this is possible. The following example will demonstrate what I would like to achieve.
Example:
$myarray = array("text1"=>"apples", "text2"=>"banana", "text3"=>"pineapple");
$mystring = 'I like eating text1 but text3 is my favorite.';
//result
I like eating apples but pineapple is my favorite.
How can I achieve the result using the array and string.
Thanks for any help
[SOLVED] The best way to write this sql
in MySQL Help
Posted
Thanks I figured out how to write the query. Sub queries saved the day.