Jump to content


Photo

I'm so Close I can feel it...


  • Please log in to reply
7 replies to this topic

#1 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 10 April 2006 - 08:02 PM

Hello one and all. I've been trying my hardest to get this database driven pages to work with eachother. Basically I'm going from the main page of listings to a page where their will be more detailed information about the subject they have selected.


The details page... I am able to Get the variable from the Url and post it into the field that I want. But I'm having trouble figuring out how to utilize the P_ID number to drill down to the results of that particular row of information.
<?php
mysql_select_db(XxXxXx);
$query_ME_test = "SELECT P_ID, P_type, P_address, P_city, P_zip, P_price, P_lotsize, P_desc, P_thumbnail, P_new, P_bedroom, P_bathroom, P_totalsqft, P_pdf, P_blueprints, P_pict_gallery1, P_pict_gallery2, P_pict_gallery3, P_pict_gallery4, P_pict_gallery5, P_pict_gallery6, P_pict_gallery7, P_pict_gallery8 FROM property";
// I know this looks like a lot of variables to be pulling from one table, but eventually I will be utilizing all of them, so I would like to keep this code intact if possible

//testing connection to see if it can see the database
if (!mysql_select_db(ME_test)) {
 die('Could not select database');
}
echo 'Connection successful!';
$property = mysql_query($query_ME_test) or die(mysql_error());

//drilldown to details
$colname_property = "1";
if (isset($HTTP_GET_VARS['P_ID'])) {
  $colname_property = (get_magic_quotes_gpc()) ? $HTTP_GET_VARS['P_ID'] : addslashes($HTTP_GET_VARS['P_ID']);
}
mysql_select_db(ME_test);
$query_property = sprintf("SELECT * FROM property WHERE P_ID = '$HTTP_GET_VARS['P_ID']'", $colname_property);
$property = mysql_query($query_ME_test) or die(mysql_error());

?>

//skip down to where it is recalled

  <tr class="td">
    <td><?php echo $HTTP_GET_VARS['P_ID']; ?></td>
    <td><?php echo $query_property['P_address']; ?></td>
    <td><?php echo $query_property['P_type']; ?></td>
    <td>$ <?php echo number_format($query_property['P_price'],0); ?></td>
  </tr>

[/code]
I guess my questions are two fold....

1) How can I fix this coding...

2) I would like to know why $query_property doesn't work the way I have coded it... the logic behind the coding seemed to work in my head, but I guess that PHP would like to (and does) disagree with me. Hopefully, I will be able to understand it better in time.

Thanks in advance for any help anyone can provide.
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#2 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 10 April 2006 - 09:00 PM

*bump*
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#3 Barand

Barand
  • Moderators
  • Sen . ( ile || sei )
  • 18,017 posts

Posted 11 April 2006 - 06:52 AM

Start by changing

$query_property = sprintf("SELECT * FROM property WHERE P_ID = '$HTTP_GET_VARS['P_ID']'", $colname_property);

to
$query_property = sprintf("SELECT * FROM property WHERE P_ID = '%s' ", $colname_property);

If you are still using mysql_ functions, STOP! Use mysqli_ or PDO. The longer you leave it the more you will have to rewrite.

Donations gratefully received






moon.png

|baaGrid| easy data tables - and more
|baaChart| easy line, column and pie charts

#4 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 11 April 2006 - 03:42 PM

I did actually try this on a previous attempt, but the results I recieved were that it printed "S" in the two fields that retrieved text and the price still remains to be zero.

I've updated it so you can see what happens. So where able to get something into the textbox areas, just not the information that it should be displaying.
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#5 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 12 April 2006 - 04:35 PM

Should this post be in the regular PHP Help? ... I think i'm in a more advanced problem and thus the few responses...
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#6 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 12 April 2006 - 06:03 PM

Just had a thought... instead of sorting after the fact would it be simplier just to pass all variables that i'm trying to display in a string to be retrieved by other pages? I mean that's what i'm already doing with the identifier for each row and I already have that working.

Just food for thought, but I would like to be able to sort through my results using the single identifier instead of passing all the database information in the url.
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#7 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 13 April 2006 - 05:37 PM

*bump*
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]

#8 titangf

titangf
  • Members
  • PipPipPip
  • Advanced Member
  • 58 posts
  • LocationColorado, USA

Posted 14 April 2006 - 05:13 PM

I would like to thank Barand for his help ... I was able to stumble apon the answer...

Thanks Barland, I appreciate that you helped.
[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--][a href="http://www.csszengarden.com/" target="_blank"]css zen garden - beautiful design with the programmer in mind[/a][!--colorc--][/span][!--/colorc--]

[!--coloro:#3366FF--][span style="color:#3366FF"][!--/coloro--]Time is the invention of man to gauge what his achievements have been before he fades to dust.[!--colorc--][/span][!--/colorc--]




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users