Jump to content

[SOLVED] Numbering results


sp@rky13

Recommended Posts

Ok so in sql how can you make it return a number for each result. So I have this echo:

 

echo $row['name']." - "."[village]".$row['x']."|".$row['y']."[/village]"."<br>"; 

Which returns this:

 

Gianni23 - [village]700|495[/village]

Gianni23 - [village]699|440[/village]

Gianni23 - [village]708|475[/village]

Gianni23 - [village]699|435[/village]

Gianni23 - [village]714|456[/village]

Gianni23 - [village]633|674[/village]

......

 

How can I make it be:

 

1. Gianni23 - [village]700|495[/village]

2. Gianni23 - [village]699|440[/village]

3. Gianni23 - [village]708|475[/village]

4. Gianni23 - [village]699|435[/village]

5. Gianni23 - [village]714|456[/village]

6. Gianni23 - [village]633|674[/village]

.....

Link to comment
Share on other sites

I changed it to that with query name changed to $result (which is the wuery name) but it outputs 1's for every row????

 

Here's the query's code:

 

$result = mysql_query("SELECT * FROM village$world
JOIN player$world
ON village$world.player = player$world.id WHERE player$world.name = '$vpt_sub' $include;") or die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo "$i".$row['name']." - "."[village]".$row['x']."|".$row['y']."[/village]"."<br>"; 
}

Link to comment
Share on other sites

$result = mysql_query("SELECT * FROM village$world
JOIN player$world
ON village$world.player = player$world.id WHERE player$world.name = '$vpt_sub' $include;") or die(mysql_error());
while($row = mysql_fetch_array($result))
{
echo "$i".$row['name']." - "."[village]".$row['x']."|".$row['y']."[/village]"."<br>";
$i++;
}

Link to comment
Share on other sites

I tried that and I get the numbering but then the actual content isn't imported. So it comes up as:

 

1 - [village]|[/village]

2 - [village]|[/village]

....

 

instead of:

 

1 - [village]456|567[/village]

2 - [village]123|543[/village]

.....

 

Why is this?

 

I should have probably given you this in the first place but here's the complete code:

 

<?php $x = $_GET["x"];?>
<?php $x1 = $_GET["x1"];?>
<?php $x2 = $_GET["x2"];?>
<?php $y = $_GET["y"];?>
<?php $y1 = $_GET["y1"];?>
<?php $y2 = $_GET["y2"];?>
<?php $k = $_GET["k"];?>
<?php $k1 = $_GET["k1"];?>
<?php $world = $_GET["world"];?>
<?php $vpt_sub = $_GET["village/player/tribe_submit"]; ?>
<?php	if ($x=='on' AND $y=='')
	$include = "AND x BETWEEN '$x1' AND '$x2'";
else if ($y=='on' AND $x=='')
	$include = "AND y BETWEEN '$y1' AND '$y2'";
else if ($y=='on' AND $x=='on')
	$include = "AND x BETWEEN '$x1' AND '$x2' AND y BETWEEN '$y1' AND '$y2'";
else if ($y=='' AND $x=='')
	$include = "";

$yLow = floor($k1 / 10) * 100;
$yHigh = $yLow + 99;

$xLow = ($k1 % 10) * 100;
$xHigh = $xLow + 99;
$BetweenClause = "x BETWEEN $xLow AND $xHigh AND y BETWEEN $yLow AND $yHigh";
$con = mysql_connect("****","******","*******");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

  mysql_select_db("*****", $con);
  
$result = mysql_query("SELECT * FROM village$world
JOIN player$world
ON village$world.player = player$world.id WHERE player$world.name = '$vpt_sub' $include;") or die(mysql_error());
$stop=mysql_num_rows($result);
for($i = 1; $i < $stop; $i++)
    {
    echo "$i".$row['name']." - "."[village]".$row['x']."|".$row['y']."[/village]"."<br>";
    }
mysql_close($con);
?>

Link to comment
Share on other sites

:( :( A really weird problemjust arose. I need no spaces in the

[village] $xrow | $yrow [/village]

so I changed to:

[village]$xrow|$yrow[/village]

 

but I get this error:

 

Parse error: syntax error, unexpected '/', expecting T_STRING or T_VARIABLE or T_NUM_STRING in /the page that was being viewed on line 46

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.