Welcome to the GoFuckYourself.com - Adult Webmaster Forum forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Post New Thread Reply

Register GFY Rules Calendar
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >
Discuss what's fucking going on, and which programs are best and worst. One-time "program" announcements from "established" webmasters are allowed.

 
Thread Tools
Old 01-23-2007, 10:47 PM   #1
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
Attn PHP guys = Stupid $20 contest for stupid wannabe programmer

Ok heres the nutshell, I am trying to put together a automated accounting/inventory system for one of my projects and want to do it on my own with minimal php knowledge.

Here is how the contest works, I will ask up to 20 stupid php questions in this thread and the webmaster who provides the most 'first correct replies' gets $20 sent to their paypal or epassporte account. All 20 questions are guaranteed within one week (probably won't last more than a a couple days) otherwise the contest ends and the current winner wins. I figure I can create 20 posts getting these codes free but I guess this is a cheap ass method of giving back to all the helpers.

My first question =

I need the correct PHP code for the following statement:

If $item_title = blah
$R_Qty_1 = blah AND R_Item_1 = blah AND R_Qty_2 = blah AND R_Item_2 = blah AND R_Qty_3 = blah AND R_Item_3 = blah

Last edited by mkx; 01-23-2007 at 10:48 PM..
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2007, 10:53 PM   #2
fatdicksimon
Confirmed User
 
Join Date: Feb 2006
Posts: 226
<?php
if ($item_title=="blah) {
$R_Qty_1 = blah;
$R_Item_1 = blah;
$R_Qty_2 = blah;
$R_Item_2 = blah;
$R_Qty_3 = blah;
$R_Item_3 = blah;
}
?>

good luck
__________________
icq: 199791893
holler at me
fatdicksimon is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2007, 10:54 PM   #3
fatdicksimon
Confirmed User
 
Join Date: Feb 2006
Posts: 226
if you need something coded i may do it for free in exchange for a hard link or two if you have some traffic. if ur interested, get at me on icq.
__________________
icq: 199791893
holler at me
fatdicksimon is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2007, 10:54 PM   #4
martinsc
Too lazy to set a custom title
 
Industry Role:
Join Date: Jun 2005
Location: 127.0.0.1
Posts: 27,047
Quote:
Originally Posted by fatdicksimon View Post
<?php
if ($item_title=="blah) {
$R_Qty_1 = blah;
$R_Item_1 = blah;
$R_Qty_2 = blah;
$R_Item_2 = blah;
$R_Qty_3 = blah;
$R_Item_3 = blah;
}
?>

good luck
you forgot the closing quotes in the if statement
and the blah's below should be in quotes too...
__________________
Make Money

Last edited by martinsc; 01-23-2007 at 10:56 PM..
martinsc is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2007, 10:58 PM   #5
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
that should do, thanks

fatdicksimon = 1
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2007, 10:58 PM   #6
fatdicksimon
Confirmed User
 
Join Date: Feb 2006
Posts: 226
whoops i missed some quotes...

<?php
if ($item_title=="blah") {
$R_Qty_1 = "blah";
$R_Item_1 = "blah";
$R_Qty_2 = "blah";
$R_Item_2 = "blah";
$R_Qty_3 = "blah";
$R_Item_3 = "blah";
}
?>
__________________
icq: 199791893
holler at me
fatdicksimon is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2007, 10:59 PM   #7
fatdicksimon
Confirmed User
 
Join Date: Feb 2006
Posts: 226
Quote:
Originally Posted by martinsc View Post
you forgot the closing quotes in the if statement
and the blah's below should be in quotes too...
yeah, i just caught that, thanks!
__________________
icq: 199791893
holler at me
fatdicksimon is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2007, 11:13 PM   #8
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
is this supposed to work even if item_title = "blah blah blah" with the spaces? i got it to work with a number without spaces but not with a line of text with spaces.
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2007, 11:25 PM   #9
Zoose
Confirmed User
 
Join Date: Aug 2006
Posts: 268
Give us a better idea of what exactly you're trying to do. It gets a bit more complicated if you want to check "if title CONTAINS blah" and not "if title IS blah".

RTFM ( no offense ) - http://www.php.net/stristr
Zoose is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2007, 11:51 PM   #10
woj
<&(©¿©)&>
 
woj's Avatar
 
Industry Role:
Join Date: Jul 2002
Location: Chicago
Posts: 47,882
wow, whole $20 for answering 20 questions?
__________________
Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager
woj is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-23-2007, 11:57 PM   #11
Nookster
Confirmed IT Professional
 
Industry Role:
Join Date: Nov 2005
Location: Hollywood, CA
Posts: 3,744
If the project takes me less than an hour to code I'll do the whole shebang for $20. (You're asking rudimentary questions so I'm guessing the project shouldn't take long.)
Nookster is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 12:01 AM   #12
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
Quote:
Originally Posted by fatdicksimon View Post
if you need something coded i may do it for free in exchange for a hard link or two if you have some traffic. if ur interested, get at me on icq.
Quote:
Originally Posted by Zoose View Post
Give us a better idea of what exactly you're trying to do. It gets a bit more complicated if you want to check "if title CONTAINS blah" and not "if title IS blah".

RTFM ( no offense ) - http://www.php.net/stristr
This works =
if ($row['item_name']=="test")

This doesn't
if ($row['item_name']=="test test-test")

I need it to be able to accept "test test-test" as the item title to lookup
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 12:06 AM   #13
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
Next question is adding up all rows in a section of a field. for example, i have a field called Total_Income with rows containing numbers like 5, 20, and 9. I would like a script that displays the total income (34). If this can be based on the payment_date containing the "payment month" written down as 04:55:21 Jan 19, 2007 PST it will be two points

So basically,

$query = "SELECT total_income FROM `db` WHERE payment_date **CONTAINS** Jan ORDER BY id DESC";

echo
Total income = total_income_of_jan
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 12:09 AM   #14
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
Quote:
Originally Posted by Nookster View Post
If the project takes me less than an hour to code I'll do the whole shebang for $20. (You're asking rudimentary questions so I'm guessing the project shouldn't take long.)
This is something that I must do myself as there is a lot of sensitive data plus I want to to be completely custom and my mind changes all the time
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 12:23 AM   #15
jMEGA
Confirmed User
 
Join Date: Oct 2005
Location: St. Louis, MO
Posts: 671
$query = "SELECT SUM(total_income) FROM `db` WHERE payment_date='Jan' ORDER BY id DESC";
__________________
Design | SEO | Photo / Video Editing
( ICQ 49354667 )
jMEGA is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 12:27 AM   #16
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
Quote:
Originally Posted by jMEGA View Post
$query = "SELECT SUM(total_income) FROM `db` WHERE payment_date='Jan' ORDER BY id DESC";

Payment date should *contain* "Jan" since this is how it is entered "04:55:21 Jan 19, 2007 PST"
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 12:45 AM   #17
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
Quote:
Originally Posted by woj View Post
wow, whole $20 for answering 20 questions?
Well mr. woj, if you do the math 11 answers guarantee you the win
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 12:50 AM   #18
jMEGA
Confirmed User
 
Join Date: Oct 2005
Location: St. Louis, MO
Posts: 671
Quote:
Originally Posted by jMEGA View Post
$query = "SELECT SUM(total_income) FROM `db` WHERE payment_date='Jan' ORDER BY id DESC";
here

$query = "SELECT SUM(total_income) FROM `db` WHERE MONTH(payment_date)='01' ORDER BY id DESC";
__________________
Design | SEO | Photo / Video Editing
( ICQ 49354667 )
jMEGA is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 12:50 AM   #19
calmlikeabomb
Confirmed User
 
calmlikeabomb's Avatar
 
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
Quote:
Originally Posted by mkx View Post
Payment date should *contain* "Jan" since this is how it is entered "04:55:21 Jan 19, 2007 PST"
Assuming you've got your db connection established..

Quote:
Originally Posted by calmlikeabomb
$Total= mysql_result(mysql_query("SELECT SUM(total_income) AS Total FROM `db` WHERE payment_date LIKE '%Jan%'"),0);

print $Total;
calmlikeabomb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 12:55 AM   #20
CyberHustler
Masterbaiter
 
CyberHustler's Avatar
 
Industry Role:
Join Date: Feb 2006
Posts: 27,891
<? ?> ...thats how much php I know
__________________
“If you can convince the lowest white man he’s better than the best colored man, he won’t notice you’re picking his pocket. Hell, give him somebody to look down on, and he’ll empty his pockets for you.”
CyberHustler is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 01:02 AM   #21
mkx
Confirmed User
 
Industry Role:
Join Date: Nov 2003
Location: Toronto
Posts: 4,001
Quote:
Originally Posted by calmlikeabomb View Post
Assuming you've got your db connection established..
winner


fatdicksimon = 1
calmlikeabomb = 1
mkx is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 02:09 AM   #22
calmlikeabomb
Confirmed User
 
calmlikeabomb's Avatar
 
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
This would probably suit your first question a little nicer:

Again, assuming you've already got the db connection established...

Quote:

<?

ob_start();

/* Generally with apps like you are making you want to store all information in the database and calculate totals such as total items in inventory, total sales, total debt ect on the fly. Cause it's information that is constantly changing and would be a real pain if you had to edit the source file of your app each time you made some $$, sold an item, restocked, got something new in stock, etc.

Make a separate table for your items with fields such as ID, ItemTitle, Description, Onhand, Warehouse, Cost, etc (a field for each piece for product information you will be storing). With that being said let's iterate through the products table rows and create a clickable list of products that will take us to a page for viewing more information (could just as easily be a form for editing the product. We will assume this file is called admin.php make sure this file is protected with cookies, sessions, http authentication, .htaccess, whatever. */

if(!isset($_GET['item'])) {//Not viewing a specific item so show the item list.

$res=mysql_query("SELECT ID, ItemTitle FROM ProductsTable");
while($row=mysql_fetch_assoc($res)) {$x++;
$ItemMenu .="$x) <a href=\"admin.php?item=$row[ID]\">$row[ItemTitle]</a><br/>";

}

print $ItemMenu;

unset($res, $row, $x);

}else{/* We are viewing an item. Here you can show all the items details or even a form that allows you edit the item with an UPDATE query. */

$res=mysql_query("SELECT * FROM ProductTable WHERE ID='$_GET[item]' LIMIT 1");

if(mysql_num_rows($res) < 1) {//If no matching record is found redirect to admin.php

header("Location: admin.php"); ob_flush(); exit();

}else{//Item has been located, store row details into associative array.

$Item=mysql_fetch_assoc($res);

/* Now here is where you gotta get creative. You've got the record pulled from the database now along with all the details from each field. You just gotta refer to them like this inorder to use the information: $Item[FieldName]*/

echo"Title of Item: $Item[ItemTitle] <br/> OnHand Stock: $Item[OnHand]<br/>,etc of course use any html you want just refer to the $Item[] array to access your item details.";

}

/* Hope this can get ya going. BTW, I didn't execute any of that code. Let me know if you have any problems - I did glance for bugs, but didn't use an editor to type it (easier to over look syntax errors if the editor doesn't do color coding). Keep us advised.. */

?>


Last edited by calmlikeabomb; 01-24-2007 at 02:12 AM..
calmlikeabomb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 02:20 AM   #23
calmlikeabomb
Confirmed User
 
calmlikeabomb's Avatar
 
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
http://rafb.net/p/OdT5zc28.html - Here's the same code color coded. Soon as I opened the code in my editor I noticed I missed a brace. Follow the link to the updated code. You should be able to just establish your connection after that output buffering on line 2 (haha, which I also forgot. Just add: ob_start();) and then edit those sql queries and be on your way.
calmlikeabomb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 02:21 AM   #24
Natural Cause
Confirmed User
 
Join Date: Oct 2006
Location: AIM: NaturalCause911
Posts: 222
This thread is pretty stupid.
Natural Cause is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 02:24 AM   #25
Jamie
Confirmed User
 
Join Date: Apr 2001
Location: CelebPay.com
Posts: 2,517
Real dev's don't have time for this bullshit
__________________
CelebPay: Promote Celebrity Reviews
i/c/q - :1851935
Jamie is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 02:27 AM   #26
calmlikeabomb
Confirmed User
 
calmlikeabomb's Avatar
 
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
Keep your money. I've got time to help out - not in this thread to make any $.
calmlikeabomb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 03:26 AM   #27
bizarredollars
Confirmed User
 
Join Date: Mar 2006
Location: bizarredollars.com
Posts: 1,582
Spend the $20 on a book.. SAMS was one of the best investments I ever made. Knowledge = Power.
__________________

[email protected]
icq: 205-252-550
bizarredollars is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 03:34 AM   #28
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,196
Quote:
Originally Posted by calmlikeabomb View Post
Assuming you've got your db connection established..
Well, (and not picking on any one in particular, so far all answers 2 have this problem) using the contains Jan works fine if we only have one years data in the db, otherwise we are going to get multiple years worth of data totalled.

(using Calm's statement as base)
$Total= mysql_result(mysql_query("SELECT SUM(total_income) AS Total FROM `db` WHERE payment_date LIKE '%Jan%' and payment_date like'2007'"),0);

However, it would be better to store the date in a proper date field and be able to hit it with a between function.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 03:35 AM   #29
sarettah
see you later, I'm gone
 
Industry Role:
Join Date: Oct 2002
Posts: 14,196
Quote:
Originally Posted by Jamie View Post
Real dev's don't have time for this bullshit
Well, at 4 in the morning I do. lololol.

Just woke up, time for coffee.
__________________
All cookies cleared!
sarettah is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 03:51 AM   #30
aico
Moo Moo Cow
 
Join Date: Mar 2004
Location: Washington State
Posts: 14,748
Hello World
aico is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 03:51 AM   #31
Natural Cause
Confirmed User
 
Join Date: Oct 2006
Location: AIM: NaturalCause911
Posts: 222
SELECT SUM(TotalPrice) AS [TotalPrice], COUNT(OrderID) AS [Sales], MONTH([Date]) AS [Month], YEAR([Date]) AS [Year]
FROM [Order]
WHERE OrderStatusID = 4 -- Complete
GROUP BY Month([Date]), YEAR([Date])

I just wrote that, nice and simple and it tells me how much ive made for each month of each year
Natural Cause is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 10:58 AM   #32
calmlikeabomb
Confirmed User
 
calmlikeabomb's Avatar
 
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
Quote:
Originally Posted by sarettah View Post
However, it would be better to store the date in a proper date field and be able to hit it with a between function.

Duh, but he is a newbie! He gets what he asks for

You're right though - he should be using a date, datetime or int data type storing time();
calmlikeabomb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 11:01 AM   #33
Klen
 
Klen's Avatar
 
Industry Role:
Join Date: Aug 2006
Location: Little Vienna
Posts: 32,235
When i need to found out something about php then i got php forums,i always found answer about php there.
Klen is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 11:03 AM   #34
RawAlex
So Fucking Banned
 
Join Date: Oct 2003
Location: In a house.
Posts: 9,465
I would also recommend you get a decent PHP manual... I have an older one here from SAMS that is pretty good, there are any number of decent PHP references with examples out there. The PHP website is quite good too, although sometimes a little less than encouraging!
RawAlex is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 11:04 AM   #35
hjnet
Confirmed User
 
Join Date: May 2002
Location: European Union
Posts: 3,815
For the small chance that all the "blah"s are the same value you can also use

<?php
if ($item_title == "blah")
{
$R_Qty_1 = $R_Item_1 = $R_Qty_2 = $R_Item_2 = $R_Qty_3 = $R_Item_3 = "blah";
}
?>

(Correct me if I'm wrong)

Last edited by hjnet; 01-24-2007 at 11:06 AM..
hjnet is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Old 01-24-2007, 12:08 PM   #36
calmlikeabomb
Confirmed User
 
calmlikeabomb's Avatar
 
Join Date: May 2004
Location: SW Palm Bay, Florida
Posts: 1,323
There is no such thing as a single right answer in programming.

It's all about semantics and pragmatism : - )
calmlikeabomb is offline   Share thread on Digg Share thread on Twitter Share thread on Reddit Share thread on Facebook Reply With Quote
Post New Thread Reply
Go Back   GoFuckYourself.com - Adult Webmaster Forum > >

Bookmarks



Advertising inquiries - marketing at gfy dot com

Contact Admin - Advertise - GFY Rules - Top

©2000-, AI Media Network Inc



Powered by vBulletin
Copyright © 2000- Jelsoft Enterprises Limited.