jaykappy Posted August 15, 2008 Share Posted August 15, 2008 Hello - I am using the code below...but am needing to modify it to return specific fields in the table. Very new to this and hoping to get a little help I would imagine that the code in red below is the part that needs to be modified to return: Field 1 Value Field 2 Value Field 3 Value etc etc Anyone out there that can give me a hand? Thanks in advance $sql_str2 = "SELECT * FROM DISPLAY_VALUES WHERE PID = '".$p_num."'"; $photo_rs2 = $conn->execute($sql_str2); echo "<div class='redbg'> <b><big>TESTING:</big></b></div>"; echo "<br>"; If ($photo_rs2->EOF) { echo "No values exist for this parcel!"; } else { $p_name2 = $photo_rs2->Fields("Filename")->Value; $p_hype2 = "javascript:window.open('file://S:/GeoImag/Assessing/Sketches/".$p_name2."','photowindow','width=450,height=350')"; writelinewhype($p_name2,"Image",$p_hype2); $photo_rs2->MoveNext(); } echo "</table>"; $photo_rs3->Close(); $photo_rs3 = null; } Link to comment https://forums.phpfreaks.com/topic/119845-query-sql-database-and-return-specific-fields/ Share on other sites More sharing options...
adam84 Posted August 15, 2008 Share Posted August 15, 2008 I dont know if you are on the right track or what. But this method should work $sql= "SELECT * FROM DISPLAY_VALUES WHERE PID = '".$p_num."'"; $results = mysql_query( $sql ); echo "<div class='redbg'> <b><big>TESTING:</big></b></div>"; echo "<br>"; if( mysql_num_rows( $results ) < 1) echo "No values exist for this parcel!"; else{ while( $row = mysql_fetch_array( $results ) ){ //do whatever you are trying to achieve } echo "</table>"; } Link to comment https://forums.phpfreaks.com/topic/119845-query-sql-database-and-return-specific-fields/#findComment-617419 Share on other sites More sharing options...
budimir Posted August 15, 2008 Share Posted August 15, 2008 Also, a very good thing to do for all your queries would be to put a simple line which can help you a lot when you need to troubleshoot your queries, so try to do it like this: $results = mysql_query( $sql,$db_conn ) or die (mysql_error()); It will save you a lot of time in future... Link to comment https://forums.phpfreaks.com/topic/119845-query-sql-database-and-return-specific-fields/#findComment-617525 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.