By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,107 Members | 1,454 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,107 IT Pros & Developers. It's quick & easy.

Calling for data to be displayed using the URL

P: 2
Hi, I'm having a problem getting my code to pull the appropriate information when I call for it via URL. (example: http://..../.php?id=2). For some reason I can't get it to pull the information for ID #2 (or any ID over 1) and input that information into my dynamic page. No matter what ID i type, or even if I neglect to type in an ID to begin with, it displays the same information. What am I doing wrong? The entire code for my page is pasted below. If anyone could help I would be grateful. I know there's something simple i'm over looking, but I can't figure out what. I've used the $_GET command to attempt to pull the information from ID through my page, but it's still coming out as though the code is doing nothing. Even if it's simple it seems as though I don't know what needs to be manipulated in order to get it to work. Any help will be grateful!

Thanks,

Ph33red.


php:

<?php require_once('connect.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_StaffDirectory, $StaffDirectory);
$query_StaffDirectory = "SELECT * FROM staffdirectory";
$StaffDirectory = mysql_query($query_StaffDirectory, $StaffDirectory) or die(mysql_error());
$row_StaffDirectory = mysql_fetch_assoc($StaffDirectory);
$totalRows_StaffDirectory = mysql_num_rows($StaffDirectory);
$result = mysql_fetch_assoc($StaffDirectory);

if (isset($ID)) //this is looking at a specific ID
{
$query_StaffDirectory="SELECT * from staffdirectory where id='$ID'";
//$ID is the number after the ID= in your browser
$query_StaffDirectory=mysql_query($StaffDirectory) ;
$row_StaffDirectory=mysql_fetch-array($StaffDirectory);
print "$row_StaffDirectory[$Result]";
//prints the text or entries of the field with the set ID
}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Testing</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">


<link href="style.css" rel="stylesheet" type="text/css">
<script language=javascript src=activateSF123.js></script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<style type="text/css">
<!--
.staffleft {
height: 233px;
width: 350px;
border: 2px groove #FFFFFF;
float: left;
margin-top: 20px;
margin-right: 2px;
margin-bottom: 15px;
margin-left: 25px;
text-align: center;
white-space: normal;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: x-small;
font-style: normal;
line-height: normal;
font-weight: normal;
font-variant: normal;
text-transform: capitalize;
text-decoration: none;
color: #FFFFFF;
padding: 3px;
}
.newblock {
margin-top: 45px;
margin-right: 15px;
margin-bottom: 15px;
margin-left: 15px;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 5px;
padding-left: 0px;
text-align: center;
vertical-align: bottom;
}
.stafftable {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: x-small;
color: #FFFFFF;
margin: 0px;
padding: 2px;
}
.staffright {
padding: 3px;
float: right;
height: 233px;
width: 370px;
margin-top: 20px;
margin-right: 5px;
margin-bottom: 15px;
margin-left: 0px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: x-small;
color: #FFFFFF;
}
.staffcenter {
padding: 3px;
width: 600px;
margin-top: 15px;
margin-right: auto;
margin-bottom: 15px;
margin-left: auto;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: large;
font-style: normal;
line-height: normal;
font-weight: bold;
font-variant: normal;
color: #FFFFFF;
text-align: center;
white-space: normal;
text-transform: capitalize;
}
.stafftableheading {
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
</head>
<body>
<table height="77%" border="0" align="left" cellpadding="0" cellspacing="0" style="height:100% ">
<tr>
<td width="766" height="495" valign="top" style="height:100% ">
<table width="776" border="0" cellpadding="0" cellspacing="0" style="height:100% ">
<tr>
<td valign="top" width="1180" height="274" style="">
<div align="center" id="nav">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="766" height="227">
<param name="movie" value="flash/main.swf">
<param name="quality" value="high">
<param name="menu" value="false">
<param name="wmode" value="transparent">
<!--[if !IE]> <-->
<object data="flash/main.swf"
width="766" height="227" type="application/x-shockwave-flash">
<param name="quality" value="high">
<param name="menu" value="false">
<param name="wmode" value="transparent">
<param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer">
FAIL (the browser should render some flash content, not this).
</object>
<!--> <![endif]-->
</object>
<script type="text/javascript" src="fixit.js"></script>
<ul>
<li><a href="laser-custom-tube-cutting.html">Tube Laser Cutting</a></li>
<li><a href="flat-metal-laser-cutting.html">Flat Laser Cutting</a></li>
<li><a href="cnc-turning.html">CNC Turning</a></li>
<li><a href="metalfabrication.html">Metal Fabrication</a></li>
<li><a href="multimedia.html">Video Library</a></li>
<li><a href="about-us.html">About Us</a></li>
<li><a href="our-clients.html">Clients</a></li>
<li><a href="careers.html">Careers</a></li>
<li><a href="contact-us.html">Contact Us</a></li>
<li><a href="quote.html">Request A Quote</a></li>
</ul>
</div> </td>
</tr>
<tr>

<td valign="top" width="1180" style="" class="content">

<div class="staffcenter"><?php echo ucwords($row_StaffDirectory['Name']); ?> - <?php echo ucwords($row_StaffDirectory['Department_Title']); ?></div>
<div class="staffleft"><img src="<?php echo $row_StaffDirectory['Photo']; ?>" alt="Laser Dynamics Staff Directory" width="350" height="233"></div>
<div class="staffright">
<table width="95%" border="0" align="center" class="stafftable">
<tr>
<td width="46%"><span class="stafftableheading">Name:</span></td>
<td colspan="3"><?php echo ucwords($row_StaffDirectory['Name']); ?></td>
</tr>
<tr>
<td><span class="stafftableheading">Department/Title:</span></td>
<td colspan="3"><?php echo ucwords($row_StaffDirectory['Department_Title']); ?></td>
</tr>
<tr>
<td><span class="stafftableheading">E-mail Address:</span></td>
<td colspan="3"><?php echo $row_StaffDirectory['Email_Address']; ?></td>
</tr>
<tr>
<td><span class="stafftableheading">Phone Number/Extension:</span></td>
<td width="36%"><?php echo $row_StaffDirectory['Phone_Number']; ?></td>
<td width="10%"><div align="right"><span class="stafftableheading">Ext</span>.</div></td>
<td width="8%"><?php echo $row_StaffDirectory['Extension']; ?></td>
</tr>
</table>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div class="newblock">
<div align="center"></div>
</div> </td>
</tr>
<tr>
<td valign="top" width="1180" height="34" style="background-image:url(images/bottom.gif) " class="footer"><div style="margin:9 0 0 51px "><b><a href="terms.html">Terms of Use</a> |<a href="privacy.html"> Privacy Statement</a><a href="privacy.html"></a></b><img alt="" src="images/spacer.gif" width="314px" height="1px"> &copy; Testing</div></td>
</tr>
</table>
</td>
</tr>
</table>

</body>
</html>
<?php
echo $html_output;
mysql_free_result($StaffDirectory);
?>
Jul 31 '07 #1
Share this Question
Share on Google+
2 Replies


kovik
Expert 100+
P: 1,044
I've used the $_GET command to attempt to pull the information from ID through my page, but it's still coming out as though the code is doing nothing. Even if it's simple it seems as though I don't know what needs to be manipulated in order to get it to work.
Firstly, $_GET is not a command, it's an array.

Secondly, not once in your code do you use it.
Jul 31 '07 #2

P: 2
Firstly, $_GET is not a command, it's an array.

Secondly, not once in your code do you use it.
Sorry, I seemed to paste the wrong code and didn't notice it.

Here is my code. At the moment it seems to be configured properly, yet right now it's not pulling any of the fields no matter the ID I attempt to pull from.:

<?php require_once('Connections/StaffDirectory.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}
mysql_select_db($database_StaffDirectory, $StaffDirectory);
$query_StaffDirectory = "SELECT * FROM staffdirectory";
$StaffDirectory = mysql_query($query_StaffDirectory, $StaffDirectory) or die(mysql_error());
$row_StaffDirectory = mysql_fetch_assoc($StaffDirectory);
$totalRows_StaffDirectory = mysql_num_rows($StaffDirectory);
$result = mysql_fetch_assoc($StaffDirectory);
$ID = $_GET['id'] ;
$ID = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($ID) : mysql_escape_string($ID);

if (isset($ID)) //this is looking at a specific ID
{
$query_StaffDirectory="SELECT * from staffdirectory where id='$ID'";
//$ID is the number after the ID= in your browser
$query_StaffDirectory=mysql_query($StaffDirectory) ;
print "$row_StaffDirectory[$Result]";
//prints the text or entries of the field with the set ID
}
?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Staff Directory </title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">

<link href="style.css" rel="stylesheet" type="text/css">
<script language=javascript src=activateSF123.js></script>
<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>
<style type="text/css">
<!--
.staffleft {
height: 233px;
width: 350px;
border: 2px groove #FFFFFF;
float: left;
margin-top: 20px;
margin-right: 2px;
margin-bottom: 15px;
margin-left: 25px;
text-align: center;
white-space: normal;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: x-small;
font-style: normal;
line-height: normal;
font-weight: normal;
font-variant: normal;
text-transform: capitalize;
text-decoration: none;
color: #FFFFFF;
padding: 3px;
}
.newblock {
margin-top: 45px;
margin-right: 15px;
margin-bottom: 15px;
margin-left: 15px;
padding-top: 0px;
padding-right: 0px;
padding-bottom: 5px;
padding-left: 0px;
text-align: center;
vertical-align: bottom;
}
.stafftable {
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: x-small;
color: #FFFFFF;
margin: 0px;
padding: 2px;
}
.staffright {
padding: 3px;
float: right;
height: 233px;
width: 370px;
margin-top: 20px;
margin-right: 5px;
margin-bottom: 15px;
margin-left: 0px;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: x-small;
color: #FFFFFF;
}
.staffcenter {
padding: 3px;
width: 600px;
margin-top: 15px;
margin-right: auto;
margin-bottom: 15px;
margin-left: auto;
font-family: Verdana, Arial, Helvetica, sans-serif;
font-size: large;
font-style: normal;
line-height: normal;
font-weight: bold;
font-variant: normal;
color: #FFFFFF;
text-align: center;
white-space: normal;
text-transform: capitalize;
}
.stafftableheading {
color: #FFFFFF;
font-weight: bold;
}
-->
</style>
</head>
<body>
<table height="77%" border="0" align="left" cellpadding="0" cellspacing="0" style="height:100% ">
<tr>
<td width="766" height="495" valign="top" style="height:100% ">
<table width="776" border="0" cellpadding="0" cellspacing="0" style="height:100% ">
<tr>
<td valign="top" width="1180" height="274" style="">
<div align="center" id="nav">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="766" height="227">
<param name="movie" value="flash/main.swf">
<param name="quality" value="high">
<param name="menu" value="false">
<param name="wmode" value="transparent">
<!--[if !IE]> <-->
<object data="flash/main.swf"
width="766" height="227" type="application/x-shockwave-flash">
<param name="quality" value="high">
<param name="menu" value="false">
<param name="wmode" value="transparent">
<param name="pluginurl" value="http://www.macromedia.com/go/getflashplayer">
FAIL (the browser should render some flash content, not this).
</object>
<!--> <![endif]-->
</object>
<script type="text/javascript" src="fixit.js"></script>
<ul>
<li><a href="laser-custom-tube-cutting.html">Tube Laser Cutting</a></li>
<li><a href="flat-metal-laser-cutting.html">Flat Laser Cutting</a></li>
<li><a href="cnc-turning.html">CNC Turning</a></li>
<li><a href="metalfabrication.html">Metal Fabrication</a></li>
<li><a href="multimedia.html">Video Library</a></li>
<li><a href="about-us.html">About Us</a></li>
<li><a href="our-clients.html">Clients</a></li>
<li><a href="careers.html">Careers</a></li>
<li><a href="contact-us.html">Contact Us</a></li>
<li><a href="quote.html">Request A Quote</a></li>
</ul>
</div> </td>
</tr>
<tr>

<td valign="top" width="1180" style="" class="content">

<div class="staffcenter"><?php echo ucwords($_GET['Name']); ?> - <?php echo ucwords($_GET['Department_Title']); ?></div>
<div class="staffleft"><img src="<?php echo $_GET['Photo']; ?>" alt="Laser Dynamics Staff Directory" width="350" height="233"></div>
<div class="staffright">
<table width="95%" border="0" align="center" class="stafftable">
<tr>
<td width="46%"><span class="stafftableheading">Name:</span></td>
<td colspan="3"><?php echo ucwords($_GET['Name']); ?></td>
</tr>
<tr>
<td><span class="stafftableheading">Department/Title:</span></td>
<td colspan="3"><?php echo ucwords($_GET['Department_Title']); ?></td>
</tr>
<tr>
<td><span class="stafftableheading">E-mail Address:</span></td>
<td colspan="3"><?php echo $_GET['Email_Address']; ?></td>
</tr>
<tr>
<td><span class="stafftableheading">Phone Number/Extension:</span></td>
<td width="36%"><?php echo $_GET['Phone_Number']; ?></td>
<td width="10%"><div align="right"><span class="stafftableheading">Ext</span>.</div></td>
<td width="8%"><?php echo $_GET['Extension']; ?></td>
</tr>
</table>
</div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<p>&nbsp;</p>
<div class="newblock">
<div align="center"></div>
</div> </td>
</tr>
<tr>
<td valign="top" width="1180" height="34" style="background-image:url(images/bottom.gif) " class="footer"><div style="margin:9 0 0 51px "><b><a href="terms.html">Terms of Use</a> |<a href="privacy.html"> Privacy Statement</a><a href="privacy.html"></a></b><img alt="" src="images/spacer.gif" width="314px" height="1px"> &copy; Test</div></td>
</tr>
</table>
</td>
</tr>
</table>

</body>
</html>
<?php
echo $html_output;
mysql_free_result($StaffDirectory);
?>
Jul 31 '07 #3

Post your reply

Sign in to post your reply or Sign up for a free account.