xwishmasterx
-
Posts
186 -
Joined
-
Last visited
Posts posted by xwishmasterx
-
-
PHP can surprise me sometime. I added your line:
$result = mysql_query($sql) or die("MySQL Error: ".mysql_error());
And now it works fine
thanks
-
I am trying to create a simple form for inserting to a database table.
It seems the data from the form are passed through the "insert" script, but nothing is added to the table.
My question is: what is required to insert new data to a table? must all fields have a value for the new data to be added?
-
Just had to add that the members team id should be same as the teams team id
-
thanks for your answer.
I think my problem is I do not fully understand the GROUP function. If I change GROUP to this:
GROUP BY vtp_members.team_id
It only outputs one row, allthough there are 3 different values. Why does it group different values?
-
I have a problem with the below code:
<?php $sql_ranks = ("SELECT vtp_members.id, vtp_members.name, vtp_members.teamleader, teams.team_name, count(vtp_tracking.id) surfs FROM vtp_members, vtp_tracking, teams WHERE vtp_members.team_id=".$_GET['t']." AND vtp_tracking.credit_members_id=vtp_members.id AND vtp_tracking.action_date > '$last_sunday' AND vtp_tracking.action_date < '$next_sunday' GROUP BY teams.team_name ORDER BY surfs DESC"); $rsranks = mysql_query($sql_ranks); echo "<br><table align='center' valign='top' border='0' width='300px'> <tr><td colspan='2' align='center'><font size='2px'><b>Team Rankings (Current Week)</b></font></td></tr> <tr><td><font size='2px'><b>Team</font></td><td align='right'><font size='2px'>Total Surfs</font></td></tr>"; while ($row = mysql_fetch_array($rsranks)) { echo "<tr><td><font size='2px'><b>".$row[team_name]."</font></td><td align='right'><font size='2px'>".$row[surfs]."</font></td></tr>";} echo "</table>"; ?>
Problem is that the last output (".$row[surfs].") is the same for all teams. It seems it is not making a total of all id's and not per team_name.
anyone can see what I am doing wrong. I need to sort by team_name and the surfs should display the total of the members with team_id is ".$_GET['t']."
-
well the problem is this
".$_GET['t']."
I get unexpected T-STRING error
Same error on other page:
buildings.php?t=$_GET['t']&r=$_GET['r']')
Not sure how to write it as doing:
echo "$_GET['t']";
works just fine
-
I have this little code that I cannot get to work
$sql_buildings = ("SELECT castle, treasury, huts, [b]leader_id[/b] FROM teams WHERE team_id=[b]".$_GET['t']." [/b]"); $rsbuildings = mysql_query($sql_buildings); if($rsbuildings[".$_GET['t']."] == 'leader_id' ){
The problem is this part:
if($rsbuildings[[b]".$_GET['t']."[/b]] == '[b]leader_id[/b]' ){
How can I write it to have these to values work?
-
what do you mean "outside of them"?
My code is:
echo " alot of text here and then treasure holdings: ".$row[team_treasure]." and some more text here";
using your (and my) way just returns this:
round(845.56999999999999,2)
-
How can I round this with 2 decimals:
echo " $row[team_treasure] ";
I've tried round($row[team_treasure],2) but doesn't seem to work inside my echo tags :/
-
thank you both. Sometimes you just need someone else to take a look too find the stupid mistakes
-
I have an error somewhere in the form as it does not output what I want it too. I know the form itself is working as I have added an echo to see if the form inputs are processed.
the code:
<?php $amount = $_POST['amount']; $member = $_POST['member']; $sql = ("SELECT name FROM vtp_members WHERE name=".$member." "); $result = mysql_query($sql); $numrows = mysql_num_rows($result); if($numrows = '1') { while($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "You sent ". $amount . " to " . $member . ".<br />"; } } echo " ".$amount." and ".$member." "; ?>
It outputs the last echo correct.
is there anyone who can see what I'm doing wrong?
-
I am need of some help on how to create a form with multiple receivers between tables.
table1.field1 value is 10000
the form should allow a person to enter the id for those members to receive(separated by a comma) and the amount they each receive from table1.field1
then of course add the amount too each members account, and subtract the total from table1.field1 (and of course check if the value is high enough to distribute the desired amount between members.
I need a little hand to get started here, so hopefully someone is willing to point me in the right direction
-
Thats the last part of it..thank you for that!
My "REAL" problem is I know how to get the info needed from the database, I just tried my script and it returned:
Team 12 has surfed: 3 sites
by using this code (end of it)
while ($row = mysql_fetch_array($result)) { echo "Team ".$row[team_id]." has surfed: ".$row[surfs]." sites";}
I don't know how to get these results and then apply you update code.
The math part should be applied to the ".$row[surfs]." result, and then "UPDATE" into table 'teams' where ".$row[team_id]." = team_id
I hope I make sense, just started learning php a few days ago.
-
I am in need of suggestions on how too achive this:
I have a surf exchange and whenever a member has viewv a site, it ads this members Id and time to a table called vtp_tracking.
I have now created a team script, so I can count the total of surf for members within this team from the vtp_table.
What I am in need of is this:
I would like to add a bonus for the teams, so my idea was this: every hour run a cronjob to get the results for the last hour by team id lik so:
WHERE vtp_members.team_id="teamid" AND vtp_tracking.credit_members_id=vtp_members.id AND vtp_tracking.action_date>date_sub(NOW(),interval 60 minute
I believe the above code will work fine and get me the results for team members for the last hour.
Problem: how can I get this result, multiple it with the value from another field and divide by 100 and add this to a third field?
eg: (result from above * value from other field / 100) then add to a third field.
Anyone willing to try and answer this one?
-
I was wondering how to write something like this:
if (table1.column1 + table2.column2 > table3.column3 then .....
I am confused where to put ( ) and '
-
I have two (2) forms on the same pages, each with 3 buttons. When a button is clicked, it will include the desired page. Since I have 2 of these forms, clicking one of them will refresh the page thus "delete" the info former retrieved from the other form.
Is there a way to make the page "remember" the last form action?
-
I tried, using the code you suggested:
SELECT vtp_members.id, vtp_members.name, vtp_members.email, count(vtp_tracking.id) surfs FROM vtp_members, vtp_tracking ON vtp_tracking.credit_members_id=vtp_members.id WHERE YEARWEEK(vtp_tracking.action_date = YEARWEEK(CURDATE()) GROUP BY vtp_members.id ORDER BY surfs DESC
This however did not return any results (and it should). Anyway I can do a test just return the result of YEARWEEK?
-
It all depends..How is WEEK defined? Is WEEK from monday to sunday or what?
-
Well, it's a little hard too explain, since I'm pretty new too all this php...
I have a surf script, that add the the time, everytime a member views 1 page.
So the code I posted, returns the name of the surfer and how many pages they've surfed.
Problem is the code will show last 7 days from current date, and not this week. So..
if I could make the codesomthing like this: "2011-03-28 10:40:30 > 2011-03-23 10:40:30",
I could setup a cron to change the date every Sunday at midnight, by simple updating the "LESS THAN" value.
Hope it makes sense
-
Hi Keith
I tried that, but couldn't get it too work.
If I could use somthing like this: "2011-03-28 10:40:30 > 2011-03-23 10:40:30"
it would be exellent, as I can setup a cron to change the dates!
(maybe the "2011-03-28 10:40:30" could be converted to one number (20110323104030)?
-
let me try asking anotherway , or alternativ; From the previous code:
vtp_tracking.action_date > DATE_SUB(CURDATE(), INTERVAL 7 DAY)
is there away to substitue "DATE_SUB(CURDATE(), INTERVAL 7 DAY)" with a specific date?
I know the action.date format is "2011-03-28 10:40:30"
but saying "2011-03-28 10:40:30 > 2011-03-23 10:40:30" ; doesn't really make sense.
-
I have this piece of code that show the number of pages surfed for the last 7 days:
SELECT vtp_members.id, vtp_members.name, vtp_members.email, count(vtp_tracking.id) surfs FROM vtp_members, vtp_tracking WHERE vtp_tracking.credit_members_id=vtp_members.id AND vtp_tracking.action_date > DATE_SUB(CURDATE(), INTERVAL 7 DAY) GROUP BY vtp_members.id ORDER BY surfs DESC
How can I make it count for within a timeframe..say monday to monday?
-
feeling stupid..did try that, but was selecting wrong table...
-
How should it look if I want to make a query where a field value should be lower than another field?
....WHERE total_points<max_points");
Simple question regarding "if" statements
in PHP Coding Help
Posted
I have a table where a filed called "recruitment" can either be "0" or "1" Why does my below code not work?
to ask in another way: how do I make the if statement to check if the value is "1" or "0"?