Jump to content

Recommended Posts

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.  It connects and downloads the information for ID #1 if I remove $_GET and replace it w/ $row_StaffDirectory, but this is where it only pulls information for ID #1 and no other, no matter which ID I call it from in the URL.  Any ideas?

 

Thanks,

 

The Code:

 

<?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 $_GET['Name']; ?> - <?php echo $_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 $_GET['Name']; ?></td>

                  </tr>

                  <tr>

                    <td><span class="stafftableheading">Department/Title:</span></td>

                    <td colspan="3"><?php echo $_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> </p>

      <p> </p>

      <p> </p>

      <p> </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">  © Test</div></td>

  </tr>

</table>

    </td>

  </tr>

</table>

 

</body>

</html>

<?php

echo $html_output;

mysql_free_result($StaffDirectory);

?>

Try this, put it near the top of the page:

if (isset($_GET['id'])) { //Page first accessed
	$id =  $_GET['id']; 
} else {  
	if (isset($_POST['id'])) {  //form has been submit
	$id =  $_POST['id'];
}
}

 

And this part at the bottom, where you get the name, department title, etc., aren't you grabbing that from the database? switch it from <? echo $_GET['name']; ?> to <? echo $row['name']; ?>

 

I tried everything that you said, for some reason it continues to pull information from the table that is not signifcant to the ID in the url.  It pulls the data for #1 when I try any other ID.. The hardest part is, I don't get any errors, so I have nothing to paste as a failed result.  Any other ideas?  I've tried everything I know.  Thanks for your help!

 

Kyle

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.