toxictoad Posted May 2, 2008 Share Posted May 2, 2008 Hey all, I've been modifying a php script that I found and I'm trying to get it to show an image on the results page but I've hit a brick wall with it :-/ I've got the results to show the link to the image so hopefully with your help I'll be able to get the image showing instead There are several places that need to be changed to get a new field showing so I don't know where I need to edit to get a picture to show instead of the link so hopefully you do ;o) These are the areas I've edited to add the Image field and the field is referenced as [2][8] with the field title being [1][7] ---------------------------------------------------------------------------------------------------- switch ( strtolower($dvd_sort) ) { case "2": $dvd_sort_string = $dvd_field[2][2] . ", " . $dvd_field[2][1]; break; case "3": $dvd_sort_string = $dvd_field[2][3] . ", " . $dvd_field[2][1]; break; case "4": $dvd_sort_string = $dvd_field[2][4] . ", " . $dvd_field[2][1]; break; case "5": $dvd_sort_string = $dvd_field[2][5] . ", " . $dvd_field[2][1]; break; case "7": $dvd_sort_string = $dvd_field[2][7] . ", " . $dvd_field[2][1]; break; case "8": $dvd_sort_string = $dvd_field[2][8] . ", " . $dvd_field[2][1]; break; case "1a": $dvd_sort_string = $dvd_field[2][1] . " DESC"; break; case "2a": $dvd_sort_string = $dvd_field[2][2] . " DESC, " . $dvd_field[2][1]; break; case "3a": $dvd_sort_string = $dvd_field[2][3] . " DESC, " . $dvd_field[2][1]; break; case "4a": $dvd_sort_string = $dvd_field[2][4] . " DESC, " . $dvd_field[2][1]; break; case "5a": $dvd_sort_string = $dvd_field[2][5] . " DESC, " . $dvd_field[2][1]; break; case "7a": $dvd_sort_string = $dvd_field[2][7] . " DESC, " . $dvd_field[2][1]; break; case "8a": $dvd_sort_string = $dvd_field[2][8] . " DESC, " . $dvd_field[2][1]; break; ==================================================================== Added new ---------------------------------------------------------------------------------------------------- <td bgcolor="<? echo $dvd_header_color; ?>" valign="top" align="center"> <div class="search1"><font face="Arial" size="2" color="<? echo $dvd_header_text_color ?>"><a href="<? echo $dvd_header_string."&dvd_sort="; if ($dvd_sort == "8") { echo "8a"; } else { echo "8"; } echo "&dvd_search_results=".$dvd_search_results; ?>"><b><? echo $dvd_field[1][7]; ?></b></a></font></div> </td> =================================================================== Added the extra [2][8] ---------------------------------------------------------------------------------- $dvd_query_string = "SELECT " . $dvd_field[2][1] . ", " . $dvd_field[2][2] . ", " . $dvd_field[2][3] . ", " . $dvd_field[2][4] . ", " . $dvd_field[2][5] . ", " . $dvd_field[2][6] . ", " . $dvd_field[2][7] . ", " . $dvd_field[2][8] . " FROM " . $dvd_search_db . " " . $dvd_search_string . " ORDER by " . $dvd_sort_string . $dvd_limit_string; ====================================================================== Added the extra field -------------------------------------------------------------------------------------------- while ($dvd_row = @mysql_fetch_array($dvd_result)) { $dvd_field_1 = $dvd_row[ $dvd_field[2][1] ]; $dvd_field_2 = $dvd_row[ $dvd_field[2][2] ]; $dvd_field_3 = $dvd_row[ $dvd_field[2][3] ]; $dvd_field_4 = $dvd_row[ $dvd_field[2][4] ]; $dvd_field_5 = $dvd_row[ $dvd_field[2][5] ]; $dvd_field_6 = $dvd_row[ $dvd_field[2][6] ]; $dvd_field_7 = $dvd_row[ $dvd_field[2][7] ]; $dvd_field_8 = $dvd_row[ $dvd_field[2][8] ]; =================================================================== Added new field again ---------------------------------------------------------------------------------------- echo "<td><font size=\"2\" color=\"$dvd_text_color\">$dvd_field_1</font></td>\n<td align=\"center\"><font size=\"2\" color=\"$dvd_text_color\">$dvd_field_2</font></td><td align=\"center\" nowrap><font size=\"2\" color=\"$dvd_text_color\">$dvd_field_3</font></td>\n<td align=\"center\" nowrap><font size=\"2\" color=\"$dvd_text_color\">$dvd_field_4</font></td><td align=\"center\" nowrap><font size=\"2\" color=\"$dvd_text_color\">$dvd_field_5</font></td><td align=\"center\" nowrap><font size=\"2\" color=\"$dvd_text_color\">$dvd_field_7</font></td><td align=\"center\" nowrap><font size=\"2\" color=\"$dvd_text_color\">$dvd_field_8</font></td></tr>\n\n"; ====================================================================== Thanks in advance btw script in action @ http://phatjoints.com/films/filmdb/index3.php Link to comment https://forums.phpfreaks.com/topic/103910-showing-a-picuture-instead-of-a-link/ Share on other sites More sharing options...
cunoodle2 Posted May 2, 2008 Share Posted May 2, 2008 Instead of just echoing the URL of the image you need to execute the html code to display the image. Like this.. <img src="http://www.phatjoints.com/video/dvdcovers/evan_almighty.jpg"> Link to comment https://forums.phpfreaks.com/topic/103910-showing-a-picuture-instead-of-a-link/#findComment-531963 Share on other sites More sharing options...
toxictoad Posted May 2, 2008 Author Share Posted May 2, 2008 Thanks cunoodle2, can you explain how and where exactly I add this into the code? There's going to be a few hundred entries so I don't want to have to type out every image address Doesn't it have to go into a variable coz that's how everything else is retrieved? Link to comment https://forums.phpfreaks.com/topic/103910-showing-a-picuture-instead-of-a-link/#findComment-531975 Share on other sites More sharing options...
DarkWater Posted May 2, 2008 Share Posted May 2, 2008 Dude.... echo "<img src=\"/path/to/image/$row['image']\" />"; >_> Just put in the right stuff. *Sighs* Link to comment https://forums.phpfreaks.com/topic/103910-showing-a-picuture-instead-of-a-link/#findComment-531978 Share on other sites More sharing options...
moselkady Posted May 2, 2008 Share Posted May 2, 2008 In the last <td> cell replace this <td align=\"center\" nowrap><font size=\"2\" color=\"$dvd_text_color\">$dvd_field_8</font></td> with this: <td align=\"center\" nowrap><font size=\"2\" color=\"$dvd_text_color\"><img src=\"$dvd_field_8\"></font></td> Link to comment https://forums.phpfreaks.com/topic/103910-showing-a-picuture-instead-of-a-link/#findComment-531983 Share on other sites More sharing options...
toxictoad Posted May 2, 2008 Author Share Posted May 2, 2008 Thanks all That works great moselkady Just one other thing...how would I set the image size of the the images returned from the database? There's this config file so would I specify it there somehow? (sorry am really new to php, just trying to get my head around it) ----------------------------------------------------------------------- config3.php <? /***************************************************************************** * Edit password * *****************************************************************************/ $dvd_edit_password = "REMOVED FOR PHPFREAKS POST"; // Password required to edit the // database. (This is not the same // as the MySQL password) /***************************************************************************** * Database settings * *****************************************************************************/ $dvd_mysql_username = "REMOVED FOR PHPFREAKS POST"; // MySQL user name $dvd_mysql_password = "REMOVED FOR PHPFREAKS POST"; // MySQL password (leave empty // if no password is required.) $dvd_mysql_db = "REMOVED FOR PHPFREAKS POST"; // MySQL database name $dvd_mysql_table = "dvds"; // MySQL table name // "dvds" is the default table // created by the "table.sql" file $dvd_mysql_host = "localhost"; // MySQL server host name // ("localhost" should be fine on // most systems) /***************************************************************************** * File locations * *****************************************************************************/ $dvd_index_url = "index3.php"; // URL of the index.php file $dvd_edit_url = "edit.php"; // URL of the edit.php file $dvd_header_file = "header.php"; // Path and name of the header file $dvd_footer_file = "footer.php"; // Path and name of the footer file $dvd_styles_file = "styles.php"; // Path and name of the style sheet /***************************************************************************** * The following variables define the name of each column, as it will * * appear on the header * *****************************************************************************/ $dvd_field[1][1] = "Title"; // Column 1 $dvd_field[1][2] = "Genre"; // Column 2 $dvd_field[1][3] = "Year"; // Column 3 $dvd_field[1][4] = "Rating"; // Column 4 $dvd_field[1][5] = "Country"; // Column 5 $dvd_field[1][6] = "Director"; // Column 6 $dvd_field[1][7] = "Image"; // Column 7 /***************************************************************************** * The following variables define the column names to be retrieved from the * * MySQL table. * * * * NOTE: The sixth column (named "link" by default) is not displayed on * * the web page. It can be used to link directly to the Internet Movie * * Database, or to a URL of your choice. See the README file for more * * information. * *****************************************************************************/ $dvd_field[2][1] = "title"; // Name of MySQL table Column 1 $dvd_field[2][2] = "genre"; // Name of MySQL table Column 2 $dvd_field[2][3] = "year"; // Name of MySQL table Column 3 $dvd_field[2][4] = "rating"; // Name of MySQL table Column 4 $dvd_field[2][5] = "country"; // Name of MySQL table Column 5 $dvd_field[2][6] = "link"; // Name of MySQL table Column 6 $dvd_field[2][7] = "director"; // Name of MySQL table Column 7 $dvd_field[2][8] = "image"; // Name of MySQL table Column 8 /***************************************************************************** * IMDb link mode - See the README for more information. * *****************************************************************************/ $dvd_imdb_links = 1; // 1 = Direct links (using the IMDb record number) // 2 = Search links // 0 = No links /***************************************************************************** * Default maximum results per page. * * Valid settings are "50", "100", "200" or "all" * * "all" displays all results from the database on a single page. * *****************************************************************************/ $dvd_max_results_default = "all"; // Default Maximum results per page /***************************************************************************** * Colors and misc. settings * *****************************************************************************/ $dvd_search_text_color = "#FFFFFF"; // Search box text color $dvd_search_background_color = "#033A05"; // Search box background color $dvd_header_text_color = "#FFFFFF"; // Header/Footer text color $dvd_header_hover_color = "#12FF00"; // Header/Footer hover color $dvd_header_color = "#058009"; // Header/Footer background color $dvd_text_color = "#FFFFFF"; // DVD Results text color $dvd_text_hover_color = "#12FF00"; // DVD Results hover color $dvd_table_bgcolor = "#0CFF00"; // DVD Results table border color $dvd_row_color_1 = "#033A05"; // Row 1 background color $dvd_row_color_2 = "#058009"; // Row 2 background color $dvd_body_bgcolor = "#033A05"; // Body background color $dvd_body_text_color = "#FFFFFF"; // Body text color $dvd_body_link_color = "#FFFFFF"; // Body link color $dvd_body_vlink_color = "#FFFFFF"; // Body visited link color $dvd_body_alink_color = "#12FF00"; // Body activated link color $dvd_body_hover_color = "#12FF00"; // Body hover color $dvd_page_title = "phatjoints.com Film Database"; // Page title $dvd_go_button = "go.gif"; // URL of the "go" button used on // the page /***************************************************************************** * End of configuration file. * *****************************************************************************/ ?> Link to comment https://forums.phpfreaks.com/topic/103910-showing-a-picuture-instead-of-a-link/#findComment-532001 Share on other sites More sharing options...
moselkady Posted May 2, 2008 Share Posted May 2, 2008 I don't see any setting for image size in the config file. So, you add the desired size in the first code. For example you can set the image width to 300 pixels and height to 300: <td align=\"center\" nowrap><font size=\"2\" color=\"$dvd_text_color\"><img src=\"$dvd_field_8\" width=\"200\" height=\"200\"></font></td> Not sure if this is what you wanted though Link to comment https://forums.phpfreaks.com/topic/103910-showing-a-picuture-instead-of-a-link/#findComment-532018 Share on other sites More sharing options...
toxictoad Posted May 2, 2008 Author Share Posted May 2, 2008 ah I see it now (said the blind man) cool cool thanks a lot for your help. I've got a long way to go with this but it's coming together slowly... Thanks again! Link to comment https://forums.phpfreaks.com/topic/103910-showing-a-picuture-instead-of-a-link/#findComment-532057 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.