sniperscope Posted January 1, 2009 Share Posted January 1, 2009 Hi all, Happy new year for all. I am desperate and shortly hopeless. I need somebody's help. Because i want to transfer a form value to another page without using Form action statement, i am using javascript popup instead of. And in another page i see nothing transfered. Here is my index page <tr> <td> <iframe width="100%" height="690" name="rank" scrolling="no" frameborder="0" marginwidth="0" marginheight="0" src="[color=red][size=3]../top/ranking.php[/size][/color]"> </iframe> </td> </tr> And this ranking.php which called inside of frame. <?php require_once('../Connections/dell.php'); $maxRows_r = 5; $pageNum_r = 0; if (isset($_GET['pageNum_r'])) { $pageNum_r = $_GET['pageNum_r']; } $startRow_r = $pageNum_r * $maxRows_r; mysql_select_db($database_dell, $dell); $query_r = "SELECT F_Name, L_Name, PR, prev_rank, rank FROM stuff_data ORDER BY rank DESC"; $query_limit_r = sprintf("%s LIMIT %d, %d", $query_r, $startRow_r, $maxRows_r); $r = mysql_query($query_limit_r, $dell) or die(mysql_error()); $row_r = mysql_fetch_assoc($r); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <SCRIPT LANGUAGE="JavaScript"> function popUp(URL) { day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=720,height=820');"); } </script> </head> <body> <?php $i = 0; do { ?> <table width="100%" height="100%" border="0"> <tr> <td rowspan="2" align="center"> <form name="form1" method="post" action=""> <input type="hidden" name="F_Name" value="<?php echo $row_r['F_Name']; ?>" /> <input type="image" name="image" src="../img/stuff/<?php echo $row_r['L_Name']; ?>/ranking.jpg" onClick="javascript:popUp('stuff_profile.php')" /><!-- Javascript helps me open Ranking.php as a popup --> </td> <td valign="top"><?php echo $row_r['F_Name']; ?></td> <td align="right"> <?php if($row_r['prev_rank']<$row_r['rank']){ echo "<img src=\"../img/icon_up.gif\">"; } else if($row_r['prev_rank']>$row_r['rank']){ echo "<img src=\"../img/icon_down.gif\">"; } else if($row_r['prev_rank']==$row_r['rank']){ echo "<img src=\"../img/icon_same.gif\">"; } ?> </td> </tr> <tr> <td colspan="2" valign="top"><?php echo $row_r['PR']; ?><br /></td> </tr> </table> <?php if ($i==4){ break; } else { echo "<br /><br />"; } ++$i; } while ($row_r = mysql_fetch_assoc($r)); ?></td> </tr> And this is stuff_profile.php <?php require_once('../Connections/dell.php'); $name = $_POST['F_Name']; mysql_select_db($database_dell, $dell); $query_r = "SELECT * FROM stuff_data WHERE first_name='$name'"; $r = mysql_query($query_r, $deli24) or die(mysql_error()); $row_r = mysql_fetch_assoc($r); $totalRows_r = mysql_num_rows($r); ?> Unfortunately, i can not transfer any variable into the stuff_profile.php. I am trying to solve this problem for 3 days. So far, i transferred value via session but in that time session send the last record always. But i want to open a popup with every single stuff. For example, if someone click the #1 stuff then popup appear and shows #1 stuff's data. if click #2 popup shows #2 stuff's data... etc. Hopefully i can find some solution. Regards Quote Link to comment Share on other sites More sharing options...
cwarn23 Posted January 1, 2009 Share Posted January 1, 2009 I would suggest using sessions however, unset the sessions when you are nolonger using them. So Try the following: ranking.php <?php session_start(); require_once('../Connections/dell.php'); unset($_SESSION['vars']); if (isset($_POST)) { $_SESSION['vars']=$_POST; } $maxRows_r = 5; $pageNum_r = 0; if (isset($_GET['pageNum_r'])) { $pageNum_r = $_GET['pageNum_r']; } $startRow_r = $pageNum_r * $maxRows_r; mysql_select_db($database_dell, $dell); $query_r = "SELECT F_Name, L_Name, PR, prev_rank, rank FROM stuff_data ORDER BY rank DESC"; $query_limit_r = sprintf("%s LIMIT %d, %d", $query_r, $startRow_r, $maxRows_r); $r = mysql_query($query_limit_r, $dell) or die(mysql_error()); $row_r = mysql_fetch_assoc($r); ?> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <SCRIPT LANGUAGE="JavaScript"> function popUp(var1,var2) { day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(var1, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=720,height=820');"); document.form+var2.submit(); } </script> </head> <body> <?php $i = 0; $id=0; do { $id+=1; ?> <table width="100%" height="100%" border="0"> <tr> <td rowspan="2" align="center"> <form name="form<? echo $id; ?>" method="post"> <input type="hidden" name="F_Name" value="<?php echo $row_r['F_Name']; ?>" /> <input type="image" name="image" src="../img/stuff/<?php echo $row_r['L_Name']; ?>/ranking.jpg" onClick="javascript:popUp('stuff_profile.php',<? echo $id; ?>)" /><!-- Javascript helps me open Ranking.php as a popup --> </td> <td valign="top"><?php echo $row_r['F_Name']; ?></td> <td align="right"> <?php if($row_r['prev_rank']<$row_r['rank']){ echo "<img src=\"../img/icon_up.gif\">"; } else if($row_r['prev_rank']>$row_r['rank']){ echo "<img src=\"../img/icon_down.gif\">"; } else if($row_r['prev_rank']==$row_r['rank']){ echo "<img src=\"../img/icon_same.gif\">"; } ?> </td> </tr> <tr> <td colspan="2" valign="top"><?php echo $row_r['PR']; ?><br /></td> </tr> </table> <?php if ($i==4){ break; } else { echo "<br /><br />"; } ++$i; } while ($row_r = mysql_fetch_assoc($r)); ?></td> </tr> stuff_profile.php <?php session_start(); while (!isset($_SESSION['vars'])) { sleep(2); } $_POST=$_SESSION['vars']; unset($_SESSION['vars']); require_once('../Connections/dell.php'); $name = $_POST['F_Name']; mysql_select_db($database_dell, $dell); $query_r = "SELECT * FROM stuff_data WHERE first_name='$name'"; $r = mysql_query($query_r, $deli24) or die(mysql_error()); $row_r = mysql_fetch_assoc($r); $totalRows_r = mysql_num_rows($r); ?> The first script box may need debuging but the basic concept is there. Basically you assign all the post data to the array $_SESSION['vars'] then when that array is avaliable, it is retrieved in the popup and converted to the regular $_POST array. Then the session array is destroyed/unset after being converted to a $_POST array. Hope that helps. Quote Link to comment Share on other sites More sharing options...
ToonMariner Posted January 1, 2009 Share Posted January 1, 2009 what is wrong with just setting the action of a form??? what happens when your user comes along and javascript is disabled? you don't allow them to participate??? Quote Link to comment Share on other sites More sharing options...
sniperscope Posted January 2, 2009 Author Share Posted January 2, 2009 I would suggest using sessions however, unset the sessions when you are nolonger using them. So Try the following: Dear cwarn23, Thank you very much for wonderful code and response. Sorry for late reply. Here is the result of code. When click at first time it's work perfect, but when clicking 2nd time with different stuff popup shows previous stuff data close the popup and click same stuff again then works ok. I mean people has to click twice. First see previous person and on second click right person. what is wrong with just setting the action of a form??? what happens when your user comes along and javascript is disabled? you don't allow them to participate??? There is no problem for me as long as detail page open as popup. And the other point is i call detail.php from inside of IFRAME. With your code it works ok unless it's open detail php inside of frame. Regards Quote Link to comment Share on other sites More sharing options...
sniperscope Posted January 4, 2009 Author Share Posted January 4, 2009 Hi, i found a solution. <a href="javascript:void(0);" onclick="window.open ('stuff_detail.php?id=<?php echo $row_r['F_Name']','','height=820, width=720, left=0, top=0, scrollbars=Yes')"> <?php Some php scripts goes here.... ?> </a> On the Stuff_detail.php mysql_select_db($dell, $dell); $query = "Select * From stuff WHERE id='$id'"; and it seems works so far. Quote Link to comment Share on other sites More sharing options...
sniperscope Posted January 4, 2009 Author Share Posted January 4, 2009 hi I really want to know that the code in my previous post seems work now, but will it make any trouble for further or advanced usage ? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.