 |
|
| View previous topic :: View next topic |
| Author |
Message |
Smx413 Guest
|
Posted: Thu Apr 10, 2003 12:31 pm Post subject: |
|
|
Okay I'm making a map preview script and everything comes out okay, but when I click on the link for the pop up window it pops up but each one of the links displays the same image. They all display the last entry. Here's the snippet for that section:
<?php
if (!eregi("modules.php", $PHP_SELF)) {
die ("You can't access this file directly...");
}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include("header.php");
?>
<?php
OpenTable();
/* Sort Drop Down Here */
CloseTable();
?>
<?php
OpenTable();
?>
<p align="center" class="text"><font size="3">|tBh| Map Cart</font></p>
<div align="center">
<center>
<table border="0" cellpadding="1" width="90%">
<tr>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text">Map Name</td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text">Map Type</td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text">Map Author</td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text">Map Preview</td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text">Map Download</td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text">Map Rating</td>
</tr>
<tr>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
</tr>
<?php
if ($standingsnogames == "yes") {
$where = 0;
}
else {
$where = 1;
}
?>
<?php
mysql_select_db($dbname,$dbi);
$sortby = "map_id ASC";
$sql="SELECT * FROM nuke_MapCart ORDER BY $sortby";
$result=mysql_query($sql,$dbi);
$num = mysql_num_rows($result);
$cur = 1;
echo "<ol>";
while ($num >= $cur) {
$row = mysql_fetch_array($result);
$map_name = $row["map_name"];
$map_type = $row["map_type"];
$map_author = $row["map_author"];
$map_rating = $row["map_rating"];
$map_downloads = $row["map_downloads"];
echo "<script type="text/javascript">n";
echo "<!--n";
echo "function MapPreview(){n";
echo " window.open ("MapCart/previews/$map_name.jpg","$map_name","toolbar=no,location=no,directories=no,status=no,scrollbars=no,resizable=no,copyhistory=no,width=400,height=200");n";
echo "}n";
echo "//-->n";
echo "</SCRIPT>nn";
}
?>
<tr>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class='text'> <?php echo "$map_name"?></font> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"><?php echo "$map_type" ?></td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"><?php echo "$map_author" ?></td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> <a onClick="MapPreview()">Map Preview</a></td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> <?php echo "<a href="MapCart/maps/$map_name.jpg">Download $map_name</a>"?></td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"><?php echo "$map_rating" ?></td>
</tr>
<?php
$cur++;
echo "</ol>";
?>
<tr>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
</tr>
</table>
</center>
</div>
<p class="text" align="center">
If You want a Map to be added, Please Email them to <a href="mailto:Smx413@hotmail.com">Gh3tto |2o|v|3o</a><br>
To maintain a high quality of maps, each will be checked by Gh3tto himself.
</p>
<?
CloseTable();
include("footer.php");
?> |
|
| Back to top |
|
 |
|
|
 |
Humpa President

Joined: 23 Apr 2002 Posts: 3429
|
Posted: Thu Apr 10, 2003 12:33 pm Post subject: |
|
|
I think you want to change that "while" loop to this:
while ($row = mysql_fetch_row($result)) {
[ This Message was edited by: Humpa on 2003-04-10 15:41 ] |
|
| Back to top |
|
 |
Humpa President

Joined: 23 Apr 2002 Posts: 3429
|
Posted: Thu Apr 10, 2003 12:52 pm Post subject: |
|
|
But, there seem to be other issues.
I'm not quite sure what is going on, but you had the counter for you "while" loop outside of the "while" loop, for one thing.
The $cur++; is down further in the code .. after the "while" loop.
(but it wouldn't have worked that way, anyway)
[ This Message was edited by: Humpa on 2003-04-10 15:54 ] |
|
| Back to top |
|
 |
Smx413 Guest
|
Posted: Thu Apr 10, 2003 12:55 pm Post subject: |
|
|
sorry pasted the old version, new version =
<?php
if (!eregi("modules.php", $PHP_SELF)) {
die ("You can't access this file directly...");
}
require_once("mainfile.php");
$module_name = basename(dirname(__FILE__));
get_lang($module_name);
include("header.php");
?>
<?php
OpenTable();
/* Drop Down Sort Menu Will Go Here */
CloseTable();
?>
<?php
OpenTable();
?>
<p align="center" class="text"><font size="3">|tBh| Map Cart</font></p>
<div align="center">
<center>
<table border="0" cellpadding="1" width="90%">
<tr>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text">Map Name</td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text">Map Type</td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text">Map Author</td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text">Map Preview</td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text">Map Download</td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text">Map Rating</td>
</tr>
<tr>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
</tr>
<?php
mysql_select_db($dbname,$dbi);
$sortby = "map_id ASC";
$sql="SELECT * FROM nuke_MapCart ORDER BY $sortby";
$result=mysql_query($sql,$dbi);
$num = mysql_num_rows($result);
$cur = 1;
echo "<ol>";
while ($num >= $cur) {
echo "<script type="text/javascript">n";
echo "function openpopup(){n";
echo " window.open ("MapCart/previews/$map_name.jpg","$map_name","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=600,height=200");n";
echo "}n";
echo "</SCRIPT>nn";
$row = mysql_fetch_array($result);
$map_name = $row["map_name"];
$map_type = $row["map_type"];
$map_author = $row["map_author"];
$map_rating = $row["map_rating"];
$map_downloads = $row["map_downloads"];
?>
<tr>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class='text'> <?php echo "$map_name"?></font> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"><?php echo "$map_type" ?></td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"><?php echo "$map_author" ?></td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> <a onClick="openpopup()">Map Preview</a></td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> <?php echo "<a href="MapCart/maps/$map_name.BIT">Download $map_name</a>"?></td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"><?php echo "$map_rating" ?></td>
</tr>
<?php
$cur++;
}
echo "</ol>";
?>
<tr>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> </td>
</tr>
</table>
</center>
</div>
<p class="text" align="center">
If You want a Map to be added, Please Email them to <a href="mailto:Smx413@hotmail.com">Gh3tto |2o|v|3o</a><br>
To maintain a high quality of maps, each will be checked by Gh3tto himself.
</p>
<?
CloseTable();
include("footer.php");
?>
[ This Message was edited by: Smx413 on 2003-04-10 18:10 ]
[ This Message was edited by: Smx413 on 2003-04-10 18:17 ] |
|
| Back to top |
|
 |
Smx413 Guest
|
Posted: Thu Apr 10, 2003 1:01 pm Post subject: |
|
|
| all the other things work out fine, the names/ authors/ etc it's just the map preview that's been messing with me =/ |
|
| Back to top |
|
 |
Smx413 Guest
|
Posted: Thu Apr 10, 2003 1:30 pm Post subject: |
|
|
| some new light, okay yeah everything gets updated, except for the map preview. Well I only had 2 previewd in initially. I added a third just to see if it'd have it's own or have sumthing else...Well the third one had it's link, but the others were assigned the same link. So it is infact using the last entries URL for all. =/ |
|
| Back to top |
|
 |
Smx413 Guest
|
Posted: Thu Apr 10, 2003 3:07 pm Post subject: |
|
|
| Quote: |
On 2003-04-10 15:52, Humpa wrote:
|
The increment variable is the last part of the loop. The } after it is the closing for the loop. |
|
| Back to top |
|
 |
Humpa President

Joined: 23 Apr 2002 Posts: 3429
|
Posted: Thu Apr 10, 2003 7:42 pm Post subject: |
|
|
You still are not doing anything to pull the different rows out of the sql query in the "while" loop.
I still think you should be using something like this for the "while" loop (try it):
| Code: | while ($row = mysql_fetch_row($result) {
$map_name = $row["map_name"];
$map_type = $row["map_type"];
$map_author = $row["map_author"];
$map_rating = $row["map_rating"];
$map_downloads = $row["map_downloads"];
echo "<script type="text/javascript">n";
echo "function openpopup".$cur."(){n";
echo " window.open ("MapCart/previews/$map_name.jpg","$map_name","toolbar=no,location=no,directories=no,status=no,scrollbars=yes,resizable=no,copyhistory=no,width=600,height=200");n";
echo "}n";
echo "</SCRIPT>nn";
?>
<tr>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class='text'> <?php echo "$map_name"?></font> </td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"><?php echo "$map_type" ?></td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"><?php echo "$map_author" ?></td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> <a onClick="openpopup<?php echo "$cur" ?>()">Map Preview</a></td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> <?php echo "<a href="MapCart/maps/$map_name.BIT">Download $map_name</a>"?></td>
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"><?php echo "$map_rating" ?></td>
</tr>
<?php
$cur++;
} |
I also added in code so that the openpopup function is named differently each time thru the loop (openpopup1, openpopup2, etc) .. I think this is what you are trying to do.
[ This Message was edited by: Humpa on 2003-04-10 22:47 ] |
|
| Back to top |
|
 |
Smx413 Guest
|
Posted: Thu Apr 10, 2003 7:52 pm Post subject: |
|
|
that produced a "Parse error: parse error, unexpected '{' in /www/i/incubus2305/htdocs/ghettoromeo/modules/Map_Cart/index.php on line 70"
I added an extra ")" to it so it was:
while ($row = mysql_fetch_row($result)) {
it loaded but nothing at all was called, the whole table was completely blank this time. Before the loop did work fine, well for the rest, the map name, the download link, the author, and rating all came out fine. It produced the right links etc, it's just the map preview would always give out the last entry. For instance the last map would be blah.jpg all the links would be blah.jpg. The names of the map would come out fine. For instance the first 3 were cheeeseyroper, cityshoppa, and gangjaroper. So the loop seem to work fine minus the preview. |
|
| Back to top |
|
 |
Smx413 Guest
|
Posted: Thu Apr 10, 2003 7:57 pm Post subject: |
|
|
i put it back to how I had it since the last try didn't work, and didn't output anything at all. Here's what it looked like with the one I posted above:
http://www.vega-nick.com/ghettoromeo/modules.php?name=Map_Cart
stumper eh?
btw: when you look at it the Preview Maps button won't change when you highlight it, it appears as normal text, it is a link tho.
[ This Message was edited by: Smx413 on 2003-04-10 23:02 ] |
|
| Back to top |
|
 |
Humpa President

Joined: 23 Apr 2002 Posts: 3429
|
Posted: Thu Apr 10, 2003 8:07 pm Post subject: |
|
|
ok .. I see.
You just need to add that code to the function openpopup and the onClick="openpopup",
like I did (at least I did something right ):
echo "function openpopup".$cur."(){n";
<td width="15%" bgcolor="<?php echo"$color4" ?>" align="center" nowrap><p class="text"> <a onClick="openpopup<?php echo "$cur" ?>()">Map Preview</a></td> |
|
| Back to top |
|
 |
Smx413 Guest
|
Posted: Thu Apr 10, 2003 8:12 pm Post subject: |
|
|
nope no luck that time either, not sure what's going on.. there's something wierd going on...naw I'm jus play'in. You squashed another bug. You da man! Thanks alot. |
|
| Back to top |
|
 |
Humpa President

Joined: 23 Apr 2002 Posts: 3429
|
Posted: Thu Apr 10, 2003 8:18 pm Post subject: |
|
|
Well, each time thru the loop, you were making a function openpopup, so you had three function openpopup's and the browser will just use the last one - I think.
I was trying to give them each a unique name, and thus the same name to the onClick=
What happened with my last edit?
Did you "view source"? Were the javascript function openpopup's named openpopup1, 2 and 3? .. how about the onClick='s ?
[ This Message was edited by: Humpa on 2003-04-10 23:20 ] |
|
| Back to top |
|
 |
Smx413 Guest
|
Posted: Thu Apr 10, 2003 8:20 pm Post subject: |
|
|
| so each time it was just being overwritten hence only the last one existing |
|
| Back to top |
|
 |
Smx413 Guest
|
Posted: Thu Apr 10, 2003 8:22 pm Post subject: |
|
|
| indeed, each were incremented =) nice. |
|
| Back to top |
|
 |
Humpa President

Joined: 23 Apr 2002 Posts: 3429
|
Posted: Thu Apr 10, 2003 8:23 pm Post subject: |
|
|
hmmmm ... I seem to have deleted my post.
Does it work now? |
|
| Back to top |
|
 |
Smx413 Guest
|
Posted: Thu Apr 10, 2003 8:24 pm Post subject: |
|
|
yep  |
|
| Back to top |
|
 |
|
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|