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
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
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
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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.