assigning result from a query to a variable within frames
Moderator: General Moderators
-
armysierra
- Forum Newbie
- Posts: 5
- Joined: Fri Jun 21, 2002 4:20 am
assigning result from a query to a variable within frames
HELLO THERE,
i have a simple query in where i want to store the result to a variable that i could use in other pages or wthin the frameset.
ex:
MAIN.PHP3
$query = "SELECT TABLENAME FROM secretDB where USERNAME='$username' and PASSWORD='$password'";
$tblname1 = mysql_query($query);
$i=0;
while($row = mysql_fetch_array($tblname1)) {
$i=$i + 1;
$TABLENAME=$row["TABLENAME"];
$PRINCPAL=$row["PRINCIPAL"];
printf("%s", $row["TABLENAME"]);
}
(i dont want to print $PRINCIPAL here, what i want is store it in variable that i could pass to below (OPTION.PHP3)
OPTION.PHP3
$result = mysql_query("select DISTINCT COMPANY from dbase WHERE PRINCIPAL='THE VARIABLE IM TRYING TO BUILD");
PLEASE HELP ME!
ARMY
i have a simple query in where i want to store the result to a variable that i could use in other pages or wthin the frameset.
ex:
MAIN.PHP3
$query = "SELECT TABLENAME FROM secretDB where USERNAME='$username' and PASSWORD='$password'";
$tblname1 = mysql_query($query);
$i=0;
while($row = mysql_fetch_array($tblname1)) {
$i=$i + 1;
$TABLENAME=$row["TABLENAME"];
$PRINCPAL=$row["PRINCIPAL"];
printf("%s", $row["TABLENAME"]);
}
(i dont want to print $PRINCIPAL here, what i want is store it in variable that i could pass to below (OPTION.PHP3)
OPTION.PHP3
$result = mysql_query("select DISTINCT COMPANY from dbase WHERE PRINCIPAL='THE VARIABLE IM TRYING TO BUILD");
PLEASE HELP ME!
ARMY
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Frames seem to be causing a lot of problems for people here:
But if you really have to use frames look into using sessions to pass the information needed:
http://www.php.net/manual/en/ref.session.php
this will be especially useful if you want to be able to access the information in subsequent pages.
Mac
- http://www.devnetwork.net/forums/viewto ... ght=frames
- http://www.devnetwork.net/forums/viewto ... ght=frames
- http://www.devnetwork.net/forums/viewto ... ght=frames
But if you really have to use frames look into using sessions to pass the information needed:
http://www.php.net/manual/en/ref.session.php
this will be especially useful if you want to be able to access the information in subsequent pages.
Mac
-
armysierra
- Forum Newbie
- Posts: 5
- Joined: Fri Jun 21, 2002 4:20 am
-
armysierra
- Forum Newbie
- Posts: 5
- Joined: Fri Jun 21, 2002 4:20 am
still dont work!
here's my complete code:
-----------------------------
MAIN.PHP3
<?
if($username && $password)
{
include("./Conn.php3");
//$loc="Location: http://$SERVER_NAME$SCRIPT_NAME";
$query = "SELECT TABLENAME, PRINCIPAL FROM secretDB where USERNAME='$username' and PASSWORD='$password'";
$tblname1 = mysql_query($query);
$tblname2 = mysql_query($query);
$num = mysql_num_rows($tblname1)
or die ("You're not authorized to be here. If you feel you have received this
message in error, please contact the <a
href=\"mailto:software@idess.com\">webmaster</a>");
$num = mysql_num_rows($tblname2)
or die ("You're not authorized to be here. If you feel you have received this
message in error, please contact the <a
href=\"mailto:software@idess.com\">webmaster</a>");
}
else
{
?>
<html>
<head>
<script language="javascript"><!--
function checkform ( form )
{
if (form.username.value == "") {
alert( "Please enter valid username.." );
form.username.focus();
return false ;
}
if (form.password.value == "") {
alert( "Please enter valid password.." );
form.password.focus();
return false ;
}
return true ;
}
//--></script>
<link rel="stylesheet" href="http://www.idess.com/ca/style1.css">
<title>IDESS Login Form</title>
</head>
<body>
<form method="post" action="<?php echo($SCRIPT_NAME)?>" onsubmit="return checkform(this);">
<input type="hidden" name="principal" value="$PRINCIPAL">
<br>
<center><img src="idesslogo.gif" width="50" height="50" border="0"></center>
<br>
<center><strong>You have entered IDESS Secured Directory</strong></center>
<br>
<table border=0 cellspacing=0 cellpadding=0 width=320 align=center>
<tr><td colspan=2><center><img src="lock.gif" width="22" height="27" border="0"></center></td></tr>
<tr><td colspan=2> </td></tr>
<tr><td>
Username:
</td><td>
<input name="username" type="text" width=10>
</td></tr>
<tr><td>
Password:
</td><td>
<input name="password" type="password" width=10>
</td></tr>
<tr><td colspan=2> </td></tr>
<tr><td colspan=2 align="center">
<input name="submit" type="submit" value="Authorize">
</td></tr>
</table>
</form>
<?
die(); //This will prevent PHP from showing actual page. See above.
}
?>
<html>
<head>
<title>Page</title>
</head>
<frameset rows="117,54, *" framespacing=0 border=0 frameborder=0>
<frameset cols="90,245,*">
<frame name="header" src="header.htm" scrolling="no" noresize>
<frame name="topmenu" src="/ccess/<?php $i=0; while($row = mysql_fetch_array($tblname1)) { $i=$i + 1; $TBLENAME=$row["TABLENAME"]; $principal=$row["PRINCIPAL"]; printf("%s", $row["TABLENAME"]);} ?>/menu.php3" scrolling="no" noresize target="input">
<frame name="input" src="/ccess/<?php $ii=0; while($row = mysql_fetch_array($tblname2)) { $ii=$ii + 1; $TBLENAME=$row["TABLENAME"]; $principal=$row["PRINCIPAL"]; printf("%s" , $row["TABLENAME"]);} ?>/option1.php3" scrolling="no" noresize target="result">
</frameset>
<frame name="print" src="print.htm" scrolling="no" noresize>
<frame name="result" src="empty.htm" scrolling="auto" noresize>
</frameset><noframes></noframes>
</html>
----------------------------------------------------
the $principal variable must go here:
(OPTION.PHP3)
<html>
<head>
<head>
<link rel="stylesheet" href="http://access/style1.css">
<title>Search Category Options</title>
<base target="result">
</head><body>
<br>
<br>
<br>
<br>
<br>
<!--//option dropdown start here-->
<?
include(".././Conn.php3");
<!--//WHEN CLICK THE FORM SUBMIT, THE VARIABLE MUST GO HERE, -->
$result = mysql_query("select DISTINCT COMPANY from dbase WHERE PRINCIPAL='$principal'");
$num_cols = mysql_num_rows($result);
$counter = 0;
echo "<FORM METHOD = \"POST\" ACTION=\"result1.php3\";\">\n";
echo "<table border=0 cellpadding=0 cellspacing=0 align=left width=350>\n";
echo "<tr><td> </td><td align=left>Search for:</td></tr>\n";
echo "<tr><td width=\"100\" align=right>Company: </td><td align=left>\n";
echo "<select name=\"company\">\n";
if ($company == "") {
echo "<option selected> </option>\n" ;
};
while($counter < $num_cols):
$opt = @mysql_result($result,$counter, "COMPANY");
echo "<option value='$opt'>$opt</option>\n" ;
$counter = $counter + 1;
endwhile;
echo "</select>\n";
echo "<INPUT TYPE=\"submit\" VALUE=\"Search\"></td></tr>\n";
echo "</table>\n";
echo "</FORM>\n";
?>
<!--//option dropdown ends here -->
</body>
</html>
WILL YOU PLEASE CHECK MY CODE?
ARMY
here's my complete code:
-----------------------------
MAIN.PHP3
<?
if($username && $password)
{
include("./Conn.php3");
//$loc="Location: http://$SERVER_NAME$SCRIPT_NAME";
$query = "SELECT TABLENAME, PRINCIPAL FROM secretDB where USERNAME='$username' and PASSWORD='$password'";
$tblname1 = mysql_query($query);
$tblname2 = mysql_query($query);
$num = mysql_num_rows($tblname1)
or die ("You're not authorized to be here. If you feel you have received this
message in error, please contact the <a
href=\"mailto:software@idess.com\">webmaster</a>");
$num = mysql_num_rows($tblname2)
or die ("You're not authorized to be here. If you feel you have received this
message in error, please contact the <a
href=\"mailto:software@idess.com\">webmaster</a>");
}
else
{
?>
<html>
<head>
<script language="javascript"><!--
function checkform ( form )
{
if (form.username.value == "") {
alert( "Please enter valid username.." );
form.username.focus();
return false ;
}
if (form.password.value == "") {
alert( "Please enter valid password.." );
form.password.focus();
return false ;
}
return true ;
}
//--></script>
<link rel="stylesheet" href="http://www.idess.com/ca/style1.css">
<title>IDESS Login Form</title>
</head>
<body>
<form method="post" action="<?php echo($SCRIPT_NAME)?>" onsubmit="return checkform(this);">
<input type="hidden" name="principal" value="$PRINCIPAL">
<br>
<center><img src="idesslogo.gif" width="50" height="50" border="0"></center>
<br>
<center><strong>You have entered IDESS Secured Directory</strong></center>
<br>
<table border=0 cellspacing=0 cellpadding=0 width=320 align=center>
<tr><td colspan=2><center><img src="lock.gif" width="22" height="27" border="0"></center></td></tr>
<tr><td colspan=2> </td></tr>
<tr><td>
Username:
</td><td>
<input name="username" type="text" width=10>
</td></tr>
<tr><td>
Password:
</td><td>
<input name="password" type="password" width=10>
</td></tr>
<tr><td colspan=2> </td></tr>
<tr><td colspan=2 align="center">
<input name="submit" type="submit" value="Authorize">
</td></tr>
</table>
</form>
<?
die(); //This will prevent PHP from showing actual page. See above.
}
?>
<html>
<head>
<title>Page</title>
</head>
<frameset rows="117,54, *" framespacing=0 border=0 frameborder=0>
<frameset cols="90,245,*">
<frame name="header" src="header.htm" scrolling="no" noresize>
<frame name="topmenu" src="/ccess/<?php $i=0; while($row = mysql_fetch_array($tblname1)) { $i=$i + 1; $TBLENAME=$row["TABLENAME"]; $principal=$row["PRINCIPAL"]; printf("%s", $row["TABLENAME"]);} ?>/menu.php3" scrolling="no" noresize target="input">
<frame name="input" src="/ccess/<?php $ii=0; while($row = mysql_fetch_array($tblname2)) { $ii=$ii + 1; $TBLENAME=$row["TABLENAME"]; $principal=$row["PRINCIPAL"]; printf("%s" , $row["TABLENAME"]);} ?>/option1.php3" scrolling="no" noresize target="result">
</frameset>
<frame name="print" src="print.htm" scrolling="no" noresize>
<frame name="result" src="empty.htm" scrolling="auto" noresize>
</frameset><noframes></noframes>
</html>
----------------------------------------------------
the $principal variable must go here:
(OPTION.PHP3)
<html>
<head>
<head>
<link rel="stylesheet" href="http://access/style1.css">
<title>Search Category Options</title>
<base target="result">
</head><body>
<br>
<br>
<br>
<br>
<br>
<!--//option dropdown start here-->
<?
include(".././Conn.php3");
<!--//WHEN CLICK THE FORM SUBMIT, THE VARIABLE MUST GO HERE, -->
$result = mysql_query("select DISTINCT COMPANY from dbase WHERE PRINCIPAL='$principal'");
$num_cols = mysql_num_rows($result);
$counter = 0;
echo "<FORM METHOD = \"POST\" ACTION=\"result1.php3\";\">\n";
echo "<table border=0 cellpadding=0 cellspacing=0 align=left width=350>\n";
echo "<tr><td> </td><td align=left>Search for:</td></tr>\n";
echo "<tr><td width=\"100\" align=right>Company: </td><td align=left>\n";
echo "<select name=\"company\">\n";
if ($company == "") {
echo "<option selected> </option>\n" ;
};
while($counter < $num_cols):
$opt = @mysql_result($result,$counter, "COMPANY");
echo "<option value='$opt'>$opt</option>\n" ;
$counter = $counter + 1;
endwhile;
echo "</select>\n";
echo "<INPUT TYPE=\"submit\" VALUE=\"Search\"></td></tr>\n";
echo "</table>\n";
echo "</FORM>\n";
?>
<!--//option dropdown ends here -->
</body>
</html>
WILL YOU PLEASE CHECK MY CODE?
ARMY
-
armysierra
- Forum Newbie
- Posts: 5
- Joined: Fri Jun 21, 2002 4:20 am
- twigletmac
- Her Royal Site Adminness
- Posts: 5371
- Joined: Tue Apr 23, 2002 2:21 am
- Location: Essex, UK
Not entirely sure where mr gumby came from I went looking for him on some fan sites. I had to do some editing and resizing in photoshop to get him to look right though. I know it's copyright theft but I don't care, sorry jason (it's on your server). I suspect no one will ever know unless I tell everyone, DOH.