Jump to content

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


titangf

Recommended Posts

[i]Hello one and all.[/i] 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.
[code]
<?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]

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

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.

[i]Thanks in advance for [b]any help[/b] anyone can provide.[/i]
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.
Link to comment
Share on other sites

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.