titangf Posted April 10, 2006 Share Posted April 10, 2006 [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]<?phpmysql_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 databaseif (!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] Quote Link to comment Share on other sites More sharing options...
titangf Posted April 10, 2006 Author Share Posted April 10, 2006 *bump* Quote Link to comment Share on other sites More sharing options...
Barand Posted April 11, 2006 Share Posted April 11, 2006 Start by changing[code]$query_property = sprintf("SELECT * FROM property WHERE P_ID = '$HTTP_GET_VARS['P_ID']'", $colname_property);[/code]to[code]$query_property = sprintf("SELECT * FROM property WHERE P_ID = '%s' ", $colname_property);[/code] Quote Link to comment Share on other sites More sharing options...
titangf Posted April 11, 2006 Author Share Posted April 11, 2006 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. Quote Link to comment Share on other sites More sharing options...
titangf Posted April 12, 2006 Author Share Posted April 12, 2006 Should this post be in the regular PHP Help? ... I think i'm in a more advanced problem and thus the few responses... Quote Link to comment Share on other sites More sharing options...
titangf Posted April 12, 2006 Author Share Posted April 12, 2006 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. Quote Link to comment Share on other sites More sharing options...
titangf Posted April 13, 2006 Author Share Posted April 13, 2006 *bump* Quote Link to comment Share on other sites More sharing options...
titangf Posted April 14, 2006 Author Share Posted April 14, 2006 I would like to thank Barand for his help ... I was able to stumble apon the answer... Thanks Barland, I appreciate that you helped. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.