I'm using a templated PHP script where the (video) Upload Form info (title, description, etc.) is displayed (after the upload) on a page below the video. I added a basic image-uploader to the Form, and some code that, via the Form, adds the 'user_id' to the beginning of the file name, for example, people.png uploaded (by user 9) becomes the new file name: 9people.png, which gets uploaded into the /upload/ folder, and stores that new file name into a db table called 'videos', into a column named 'thumbnail'. I'm looking for guidance with making a successful hyperlink(to the image) appear where the Upload Form info is displayed. This is the (results)php page that corresponds with the html page (inner_results.htm): <?php include_once ('classes/config.php'); include_once ('classes/sessions.php'); include_once ('classes/functions.inc.php'); $page_title = $site_name; $submitted = $_POST['submitted']; $which_one = mysql_real_escape_string($_GET['load']); $limit = 20; $keyword = $_SESSION['searched']; // this is per each template from config.inc.php advanced config settings $page_display_small_width = $config['general_medium_thumb_width']; // 80 $member_credits = get_member_credits($user_id); if ($user_id != "") { $inner_template1 = "themes/$user_theme/templates/inner_results.htm"; }else{ $show_login = 1; $inner_template1 = "themes/$user_theme/templates/inner_signup_form.htm"; } // FUNCTIONS function getUsername($id) { $sql1 = "SELECT * FROM member_profile WHERE $query1 = mysql_query($sql1) or DIE(mysql_error()); $result = mysql_fetch_array($query1); return $result['user_name']; } function getVidTitle($id) { $sql1 = "SELECT * FROM videos WHERE indexer = $id"; $query1 = mysql_query($sql1) or DIE(mysql_error()); $result = mysql_fetch_array($query1); return $result['title']; } ?> PHP: Can you make a suggestion as to what I might add to results.php (and inner_results.php) in order to display a successful hyperlink to the image that was uploaded with the video? Any help will be appreciated.
Since you are using functions for a bunch of other stuff ill just make my example follow that function getVidLink($id) { $sql1 = "SELECT * FROM videos WHERE indexer = $id"; $query1 = mysql_query($sql1) or DIE(mysql_error()); $result = mysql_fetch_array($query1); return 'http://yoururl.com/upload/'.$result['thumbnail']; } PHP: Then you could use it like this which will link to the thumbnail. $link = getVidLink($id); echo '<a href="'.$link'">Go to thumbnail</a>'; PHP:
Thanks for your reply/suggestion. I put the first part in the results.php, but I don't know where to put: $link = getVidLink($id); echo '<a href="'.$link'">Go to thumbnail</a>'; PHP: in the html? If so, how please? I tried without success. Much thanks again.
You would want to use that in a php file. You will need to run php in whatever file you want to echo the link in. Why not send the user to the results.php page and echo the link on that page?
Thanks again for your reply. I added: <?php $link = getVidLink($id); echo '<a href="http://--.com/uploads/'.$link'">Go to thumbnail</a>'; ?> PHP: into the html page without success. What am I doing incorrectly? Regarding "Why not send the user to the results.php page and echo the link on that page", because I'm working with a templated script that works successfully except for this part. If I add what you're suggesting, I'd bet I have more issues. So, if someone could simply help me with adding the php correctly into the html, I look forward to seeing if your current suggestion is the solution. Much thanks again.
Without knowing what script or templating system you are using, I doubt anyone will know how to do that.
Well, can someone just tell how to code this correctly for an html page? It doesn't appear correct <?php $link = getVidLink($id); echo '<a href="http://--.com/uploads/'.$link'">Go to thumbnail</a>';?> PHP:
This should work. You need to escape the quotes so PHP can parse it correctly. <?php $link = getVidLink($id); echo "<a href=\"http://--.com/uploads/".$link"\">Go to thumbnail</a>";?> PHP:
Or just write it like it should be written: <?php $link = getVidLink($id); echo '<a href="http://--.com/uploads/'.$link.'">Go to thumbnail</a>'; ?> PHP: Note: for this to work, you need to have a set value for $id - ie, if this is based on an input from a form of some sort, either via $_POST or $_GET, you need to assign $id before using it - for instance like this: <?php $id = $_POST['id']; $link = getVidLink($id); echo '<a href="http://--.com/uploads/'.$link.'">Go to thumbnail</a>'; ?> PHP: If it's assigned elsewhere, it should be fine, however. That being said - this won't work if it's input into a standard .html-file - .html-files are normally not sent through the PHP-parser, and embedded PHP-code won't work properly, unless the file ends with .php, or all .html-files are being read by the PHP-parser (which is very bad practice).
Thanks for your replies. I added <?php $id = $_POST['id']; $link = getVidLink($id); echo '<a href="http://--.com/uploads/'.$link.'">Go to thumbnail</a>'; ?> PHP: to the html page and all I see on the page is this part of that line of code: Go to thumbnail'; ?> PHP: So, I don't know why that is. I'm assuming this is not "a standard html file" (inner_results.htm) because it is a templated php script where that page corresponds with results.php (shown above) which interacts with inner_results.htm via this line of code: $inner_template1 = "themes/$user_theme/templates/inner_results.htm"; PHP: as you can see. And yes this is "based on an input from a form". Any additional help will be greatly appreciated.
Well - you'll probably have to find out how (if any) they parse PHP-variables in the HTML-file. If they don't, you're a bit screwed. (Although it sounds like this is a horrible project to begin with). A .htm-file is just a plain .html-file - for some reason they've chosen to name it with the old, 3-letter extension. The reason you only see those things are because the PHP isn't being parsed, so probably there is some other way to parse values inside the HTML-file (since it's part of a template, I'm assuming there is a way to parse variables inside the HTML-file)