Jump to content

Java/Php mix issue


spur18

Recommended Posts

Hi

 

<?
$q1 = "select * from sp_down where did = '$_GET[id]'";
$r1 = mysql_query($q1) or die(mysql_error());
?>
<script type="text/javascript">
function openmypage(){
ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", "loaddown.php?id=$a1[did]", "Download", "width=675px,height=600px,left=0px,top=25px,resize=1,scrolling=1")
}
</script>

 

Im using this dialog, but its failing to get the ID number. This works fine if I just create a normal link using _blank. Is there anything special I can do to get this to work?

 

Thanks,

Shawn

Link to comment
Share on other sites

Is there anything special I can do to get this to work?

 

It helps if you put php within <?php ?> tags.

 

ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", "loaddown.php?id=<?php echo $a1['did']; ?>", "Download", "width=675px,height=600px,left=0px,top=25px,resize=1,scrolling=1")

 

Also note that $al has not been defined anywhere.

 

 

 

 

 

Link to comment
Share on other sites

This doesen't work either. I should have said I tried this also. I just tried again incase I missed something but no go.  ???

 

<?php
$q1 = "select * from sp_down where did = '$_GET[id]'";
$r1 = mysql_query($q1) or die(mysql_error());
?>
<script type="text/javascript">
function openmypage(){
ajaxwin=dhtmlwindow.open("ajaxbox", "ajax", "loaddown.php?id=<?php echo $a1['did']; ?>", "Download", "width=675px,height=600px,left=0px,top=25px,resize=1,scrolling=1")
}
</script>
<?php
//get the download list
$q1= "SELECT * FROM sp_dcat where cdid = '$_GET[id]'"; 
$r1 = mysql_query($q1) or die(mysql_error());
$q1 = "select * from sp_down where dcat = '$_GET[id]'";
$r1 = mysql_query($q1) or die(mysql_error());
if(mysql_num_rows($r1) > 0)
{
echo "<table STYLE='border-collapse:collapse;' width=675 height='25' align=center cellspacing=0>";

$col = "white";

while($a1 = mysql_fetch_array($r1))
{
	if($col == "white")
	{
		$col = "#ADBDCE";
	}
	else
	{
		$col = "white";
	}
echo "<tr><td width=20 height=25 style='border-width:1; border-color:black; border-style:solid;' bgcolor='#E9E9E9'><p align=center><img src=http://spfactor.rscsites.org/images/down_icon.gif></p></u></td>\t";
echo "<td width=333 height=25 style='border-width:1; border-color:black; border-style:solid;' bgcolor='#E9E9E9'><a href='loaddown.php?id=$a1[did]' onClick='openmypage();; return false'>$a1[dname]</a></td>\t";
echo "<td width=332 height=25 style='border-width:1; border-color:black; border-style:solid;' bgcolor='#E9E9E9'>Author: $a1[dauthor]</td>\t";
}
echo "</table>";
}
else
{
echo"No Files Found";
}
?>

 

Thats the complete page, and you can see how it works here http://spfactor.rscsites.org/downloads.php

Link to comment
Share on other sites

Where are you getting $a1[did] from?

 

Can you post the function which provides this variable please?

 

In your second post you have $a1 but it is declared after the <script>. It will need to be before if thats what is declaring it.

Link to comment
Share on other sites

ok I didn't have it correct I know im new to php, but

 

I used this now

<?php
$q1= "SELECT * FROM sp_down where did = '$_GET[id]'"; 
$r1 = mysql_query($q1) or die(mysql_error());
$a1 = mysql_fetch_array($r1);
echo "<script type='text/javascript'>function openmypage(){ajaxwin=dhtmlwindow.open('ajaxbox', 'ajax', 'loaddown.php?id=$a1[did]', 'Download', 'width=675px,height=600px,left=0px,top=25px,resize=1,scrolling=1')}</script>";
?>

 

This now instead is using the wrong information somehow it is getting the $a1 from the code below it

 

its using my [cdid] instead of my [did] :S So the ID numbers end up wrong.

 

<?php
//get the download list
$q1= "SELECT * FROM sp_dcat where cdid = '$_GET[id]'"; 
$r1 = mysql_query($q1) or die(mysql_error());
$q1 = "select * from sp_down where dcat = '$_GET[id]'";
$r1 = mysql_query($q1) or die(mysql_error());
if(mysql_num_rows($r1) > 0)

Link to comment
Share on other sites

it outputs this.

 

Array ( [0] => 2 [did] => 2 [1] => FIA-GT Maserati Setup Pack [dname] => FIA-GT Maserati Setup Pack [2] => 3 [dcat] => 3 [3] => Shawn Purdy [dauthor] => Shawn Purdy [4] => FIA-GT Maserati Setups for Various Tracks, Track list included [ddesc] => FIA-GT Maserati Setups for Various Tracks, Track list included [5] => none [dpic] => none [6] => http://spfactor.rscsites.org/downloads/setups/FIA_Maserati_Setups.zip [dlink] => http://spfactor.rscsites.org/downloads/setups/FIA_Maserati_Setups.zip )

 

The reason its getting all the info is its somehow pulling up Data for ID 2, which just happens to be the category ID I clicked on...

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.