PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have created a query below: I need to know how to pass different values of $monthid to the query.
<?php
$currentuser_GetData = "dave";
if (isset($_SESSION['MM_Username'])) {
$currentuser_GetData = (get_magic_quotes_gpc()) ? $_SESSION['MM_Username'] : addslashes($_SESSION['MM_Username']);
}
$monthnum_GetData = "6";
if (isset($monthid)) {
$monthnum_GetData = (get_magic_quotes_gpc()) ? $monthid : addslashes($monthid);
}
mysql_select_db($database_Connect, $Connect);
$query_GetData = sprintf("SELECT sum(transactions.amount) FROM transactions WHERE MONTH(transactions.date) = %s AND transactions.userlogged = \"%s\"", $monthnum_GetData,$currentuser_GetData);
$GetData = mysql_query($query_GetData, $Connect) or die(mysql_error());
$row_GetData = mysql_fetch_assoc($GetData);
$totalRows_GetData = mysql_num_rows($GetData);
Basically I want the query to run 12 times on the same page, and display the resuts in 12 different places. I could repeat this code 12 times but is there a way to use an array or something similar?
The data is in a table of transactions throughout the year and I want to retrieve totals per month per user. (and eventually per category as well, but I haven't got to that yet.)
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I want to create a table that displays totals of all the transactions in June for a specific user.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I changed my query and it works almost how I wanted it to. It will do.
Thanks Blackbeard for the help.
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]