Jump to content

[SOLVED] php/mysql


Greaser9780

Recommended Posts

I posted this ? in mysql but no one has really been there for hours.Just wondering if anyone over here would have some insight.

I decided to put rank in my game table.For the life of me I cannot figure out how to update and set the rank.

I have the table already set up to display the clan name ordered by wins descending.

Then everytime a gamer reports the loss I can automatically run the update in my php file when the losses and wins are reported.

UPDATE `game` SET `rank`='?' ORDER BY ASC

Can't fill in that ?

Link to comment
https://forums.phpfreaks.com/topic/38727-solved-phpmysql/
Share on other sites

I already figured out how to report a loss/win. query the db and display the number of wins/losses for each clan. I list that all on a table for each game. I am trying to set up a way to rank each clan by number of wins. Then display Rank,Clan Name, Wins, Losses, and Clan Id in my table for that game.

I don't know what CRON is?

Link to comment
https://forums.phpfreaks.com/topic/38727-solved-phpmysql/#findComment-186069
Share on other sites

Would probably be alot easier to just set numbers down the left hand side of my table 1-25 and then list the first 25 clans of my query. On the other hand if a game only has 5 clans at the moment I don't want to have to change the page everytime someone creates a new clan.

Link to comment
https://forums.phpfreaks.com/topic/38727-solved-phpmysql/#findComment-186071
Share on other sites

Done that already. I am trying to display to my users what place each clan is in. How do I place a seven next to the clan in 7th place and so on. Here's how I set up the table so far. I have one of thes queries for each item (clan name, wins, losses, id):

<?PHP

$sql="SELECT `clan_name`,`wins`,`losses`,`message`,`clan_id`,`link`,`last_battle` FROM `table`  ORDER BY `wins` DESC";

$res=mysql_query($sql) or die(mysqll_error());

while ($row = mysql_fetch_array($res))

{

 

$list = "<table width='20%'>";

$list .= "<td>";

$list .= "<td >".$row["clan_name"]."</td>";

$list .= "<td>";

$list .= "</table>";

echo( $list );

}

?>

 

Link to comment
https://forums.phpfreaks.com/topic/38727-solved-phpmysql/#findComment-186074
Share on other sites

when you loop through them you just add to a number. Your table is also kind of weird - you had no rows and many open cells.

<?PHP

$sql="SELECT `clan_name`,`wins`,`losses`,`message`,`clan_id`,`link`,`last_battle` FROM `table`  ORDER BY `wins` DESC";

$res=mysql_query($sql) or die(mysqll_error());

$rank = 1;

print '<table>';

while ($row = mysql_fetch_array($res)){

    print "<tr><td>Rank: $rank</td><td >".$row["clan_name"]."</td></tr>";

    $rank++;

}

print '</table>';

?>

Link to comment
https://forums.phpfreaks.com/topic/38727-solved-phpmysql/#findComment-186078
Share on other sites

TY jesirose. I figured it would surround $rank=1, but I didn't know that putting 1+1 would make it increment while printing a table from a query. I never would of tried it in a million years. I am going to be creating a lot of these types of tables for my site. Is there anywhere here where I can find more info on them. Next Task is to find out how to display winning or losing streak.

Link to comment
https://forums.phpfreaks.com/topic/38727-solved-phpmysql/#findComment-186099
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.