4
Contributors
12
Replies
13
Views
8 Years
Discussion Span
Last Post by isak
0

<a href="\inventory.php?id=" . $id . "\"><?php echo $row_rsAllListings['element_1_1']; ?></a> Why do you echo $row_rsAllListings['element_1_1'] but you don't echo $id? Check the link href value after the page is loaded. I'm sure you'll spot the problem.

0
<div class="content">
<table width="600">
<?php $counter = 0; // initialize counter outside loop 
do { echo '<tr';
if ($counter++ % 2) {echo 'class="hilite"';} 
echo '><td width="162"><img src="'.$row_rsAllListings['element_16'].'"></td>';
echo '<td width="426"><h2><a href="\inventory.php?id="'.$id.'">'.$row_rsAllListings['element_1_1'];
echo '</a> |  '.$row_rsAllListings['element_2'].'<br />';
echo $row_rsAllListings['element_3'].'</h2><br />';
echo $row_rsAllListings['element_4'].'<br />';
echo $row_rsAllListings['element_5'].'Beds / '.$row_rsAllListings['element_6']; 
echo $row_rsAllListings['element_7'].'Baths / '.$row_rsAllListings['element_8'].'sf per '.$row_rsAllListings['element_9'].'<br /></td></tr>'; } while ($row_rsAllListings = mysql_fetch_assoc($rsAllListings)); ?>
</table>
</div>

this code is from clicking 'suggestions' devPHP
original code

<div class="content">
  <table width="600">
  <?php $counter = 0; // initialize counter outside loop ?>
<?php do { ?>
<tr <?php if ($counter++ % 2) {echo 'class="hilite"';} ?>>
      <td width="162"><img src="<?php echo $row_rsAllListings['element_16']; ?>></td>
      <td width="426">
<h2><a href="\inventory.php?id=" . $id . "\"><?php echo $row_rsAllListings['element_1_1']; ?></a> | <?php echo $row_rsAllListings['element_2']; ?><br />
        <?php echo $row_rsAllListings['element_3']; ?></h2>
        <br />
        <?php echo $row_rsAllListings['element_4']; ?><br />
        <?php echo $row_rsAllListings['element_5']; ?> Beds / <?php echo $row_rsAllListings['element_6']; ?>-<?php echo $row_rsAllListings['element_7']; ?> Baths / <?php echo $row_rsAllListings['element_8']; ?>sf per <?php echo $row_rsAllListings['element_9']; ?><br />
      </td>
    </tr>
    <?php } while ($row_rsAllListings = mysql_fetch_assoc($rsAllListings)); ?>
  </table>
</div>
0

Okay, so now I have the correct id appearing at the top of the next page by editing the link to be:

<a href="\inventory.php?id=<?php echo $row_rsAllListings['id']; ?>"\><?php echo $row_rsAllListings['element_1_1']; ?></a>

But the record being displayed in that next page is always the first record in the database.

Progress for sure, but not there yet.

0

try

<tr <?php if ($counter++ % 2) { echo 'class="hilite"'; }
echo '><td width="162"><img src='.$row_rsAllListings['element_16'].'></td><td width="426"><h2><a href=/"/inventory.php?id='.$row_rsAllListings['element_1_1'].'</a> | '.$row_rsAllListings['element_2'].'<br />'; ?>

in the original code sample the php variable $id is not within a <?php ?> block, =>cant be accessed
not sure what editor you are using,
but
when I pasted your code into notepad++ $id in this link was hilighted red immediately, v.easy to find

I think you are missing a closing tag for the table row?

I have added the $id back into the code, but getting the same record on the next page regardless of the link I click.

0

inventory.php
there is no 'select * from database where id='.$id
there is no reference to '$id' in the file
the href calling the inventory script
inventory.php?id=$id
if you don't use it, you lose it, and id is getting lost

0

almostbob,

This is where I mention "novice" again. Can you explain more simply what and where this works? I would LOVE to use it.

0

your link to inventory.php has a parameter ?id=$id
assuming $id is the id link of the record in the database
that id is available in inventory.php as $id
somewhere in the inventory.php file there should be (could be, usually is) an sql query that selects the row defined by that id
something like

"select * from database where id=$id"

I could not find such query in the file
I could find many queries, but none that selected on the basis of $id
it may be as simple as finding the variable used in inventory.php to select and
change that named variable to $id /* or */
change the parameter name passed by the link to that used in inventory.php /* or */
add a sql select with the right format
the sql in the files is convoluted, almost as if written to hide its intent

0

I edited the inventory.php file to include the $id. I just put it at the beginning of the street address however I really would rather it not appear in the inventory page when viewed. I have attached the new inventory.php file.

So while it *works* it is still only pulling the first record in the database.

The sql written in the file is written by Dreamweaver.

BTW... nice clean code that you wrote. Thanks.

Attachments
<?php require_once('Connections/rsGunn.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;
	//  $id = $_REQUEST["id"];
  }
  return $theValue;
}
}

mysql_select_db($database_rsGunn, $rsGunn);
$query_rsInventory1 = "SELECT ap_form_1.element_1_1, ap_form_1.element_1_2, ap_form_1.element_1_3, ap_form_1.element_1_4, ap_form_1.element_1_5, ap_form_1.element_1_6, ap_form_1.element_2, ap_form_1.element_3, ap_form_1.element_16, ap_form_1.element_4, ap_form_1.element_5, ap_form_1.element_57, ap_form_1.element_6, ap_form_1.element_7, ap_form_1.element_8, ap_form_1.element_9, ap_form_1.id FROM ap_form_1";
$rsInventory1 = mysql_query($query_rsInventory1, $rsGunn) or die(mysql_error());
$row_rsInventory1 = mysql_fetch_assoc($rsInventory1);
$totalRows_rsInventory1 = mysql_num_rows($rsInventory1);

mysql_select_db($database_rsGunn, $rsGunn);
$query_rsInventory2 = "SELECT ap_form_1.element_11, ap_form_1.element_40, ap_form_1.element_12, ap_form_1.element_32, ap_form_1.element_33, ap_form_1.element_34, ap_form_1.element_35, ap_form_1.element_8, ap_form_1.element_9, ap_form_1.element_62, ap_form_1.element_67, ap_form_1.element_66, ap_form_1.element_29, ap_form_1.element_30, ap_form_1.element_31, ap_form_1.id FROM ap_form_1";
$rsInventory2 = mysql_query($query_rsInventory2, $rsGunn) or die(mysql_error());
$row_rsInventory2 = mysql_fetch_assoc($rsInventory2);
$totalRows_rsInventory2 = mysql_num_rows($rsInventory2);

mysql_select_db($database_rsGunn, $rsGunn);
$query_rsAllInventory = "SELECT A.*, B.option as element_67_value FROM ap_form_1 as A  left join ap_element_options as B on A.element_67=B.option_id and B.element_id=67 and B.form_id = 1";
$rsAllInventory = mysql_query($query_rsAllInventory, $rsGunn) or die(mysql_error());
$row_rsAllInventory = mysql_fetch_assoc($rsAllInventory);
$totalRows_rsAllInventory = mysql_num_rows($rsAllInventory);
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Untitled Document</title>
<style type="text/css" media="screen">
<!--
@import url("p7tp/p7tp_12.css");
-->
</style>
<script type="text/javascript" src="p7tp/p7tpscripts.js"></script>
</head>

<body onload="P7_initTP(12,1)">
<div id="p7TP1" class="p7TPpanel">
  <div class="p7TPheader">
    <h3>property detail</h3>
  </div>
  <div class="p7TPwrapper">
    <div class="p7TP_tabs">
      <div id="p7tpb1_1" class="down"><a class="down" href="javascript:;">overview</a></div>
      <div id="p7tpb1_2"><a href="javascript:;">details</a></div>
      <div id="p7tpb1_3"><a href="javascript:;">photos</a></div>
      <br class="p7TPclear" />
    </div>
    <div class="p7TPcontent">
      <div id="p7tpc1_1">
        <h4>overview</h4>
        <p>&nbsp;</p>
        <table width="600" align="center">
          <tr>
            <td><?php echo $row_rsInventory1['id']; ?> | <?php echo $row_rsInventory1['element_1_1']; ?> <?php echo $row_rsInventory1['element_2']; ?></td>
            <td><?php echo $row_rsInventory1['element_3']; ?></td>
          </tr>
          <tr>
            <td colspan="2"><div align="center"><?php echo $row_rsInventory1['element_16']; ?></div></td>
          </tr>
          <tr>
            <td colspan="2"><?php echo $row_rsInventory1['element_4']; ?><br />
              <?php echo $row_rsInventory1['element_5']; ?> / <?php echo $row_rsInventory1['element_6']; ?> - <?php echo $row_rsInventory1['element_7']; ?> / <?php echo $row_rsInventory1['element_8']; ?> per <?php echo $row_rsInventory1['element_9']; ?><br /></td>
          </tr>
          <tr><td colspan="2">To schedule an appointment, contact Sandra by phone at 713.224.2777</td></tr>
        </table>
        <p>&nbsp;</p>
      </div>
      <div id="p7tpc1_2">
        <h4>details...</h4>
        <table width="600" align="center">
  <tr>
    <td>Living Room: <?php echo $row_rsInventory2['element_11']; ?></td>
    <td>Kitchen: <?php echo $row_rsInventory2['element_40']; ?></td>
  </tr>
  <tr>
    <td>Dining Room: <?php echo $row_rsInventory2['element_12']; ?></td>
    <td>Master Bedroom: <?php echo $row_rsInventory2['element_32']; ?></td>
  </tr>
  <tr>
    <td>2nd Bedroom: <?php echo $row_rsInventory2['element_33']; ?></td>
    <td>3rd Bedroom: <?php echo $row_rsInventory2['element_34']; ?></td>
  </tr>
  <tr>
    <td><?php echo $row_rsInventory2['element_8']; ?> sf/<?php echo $row_rsInventory2['element_9']; ?></td>
    <td>Lot: <?php echo $row_rsInventory2['element_62']; ?> /<?php echo $row_rsAllInventory['element_67_value']; ?></td>
  </tr>
  <tr>
    <td colspan="2"><p><?php echo $row_rsInventory2['element_66']; ?></p>
      <p><?php echo $row_rsInventory2['element_29']; ?></p>
      <p><?php echo $row_rsInventory2['element_30']; ?></p>
      <p><?php echo $row_rsInventory2['element_31']; ?></p></td>
  </tr>
  <tr>
    <td colspan="2">To schedule an appointment, contact Sandra by phone at 713.224.2777</td>
  </tr>
</table>
      </div>
      <div id="p7tpc1_3">
        <h4>photos...</h4>
        <p>Lorem ipsum dolor sit amed sed diam nonummy nibh euismod tincidunt ut. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, eu feugiat nulla at vero eros et accumsan et odio  qui blandit praesent luptatum augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, contuer adiping elit, sed diam nonummy nibh euismod.</p>
      </div>
    </div>
  </div>
  <!--[if lte IE 6]>
<style type="text/css">.p7TPpanel div,.p7TPpanel a{height:1%;}.p7TP_tabs a{white-space:nowrap;}</style>
<![endif]-->
</div>

</body>
</html>
<?php
mysql_free_result($rsInventory1);

mysql_free_result($rsInventory2);

mysql_free_result($rsAllInventory);
?>
0

without debugging the code, don't have the db structure, don't know what table refers to what, you have to end up with something like

mysql_select_db($database_rsGunn, $rsGunn);
$query_rsInventory1 = "SELECT ap_form_1.element_1_1, ap_form_1.element_1_2, ap_form_1.element_1_3, ap_form_1.element_1_4, ap_form_1.element_1_5, ap_form_1.element_1_6, ap_form_1.element_2, ap_form_1.element_3, ap_form_1.element_16, ap_form_1.element_4, ap_form_1.element_5, ap_form_1.element_57, ap_form_1.element_6, ap_form_1.element_7, ap_form_1.element_8, ap_form_1.element_9, ap_form_1.id FROM ap_form_1 where id=".$id;
$rsInventory1 = mysql_query($query_rsInventory1, $rsGunn) or die(mysql_error());

horrible data structure ap_form.element_57, not at all intuitive

0

The "horrible" structure... I am using a program called Machform to create the form that enters the info into the database. This program gives the horrible names you are noting. And yes, they are hard to work with, especially since my form has 65 fields.

I added the WHERE as you had it (WHERE id=".$id;), but I got this error: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

When I change it to WHERE ap_form_1.id, I do not get the error message, but I still only get the first record from the database.

0

$id is the record number as assigned by the database. There are currently 2 records in the database -- 1 and 2. When you click on either record, it displays the first one and it shows the record number to the left of the street address. So not blank.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.