Jago6060 Posted October 1, 2007 Share Posted October 1, 2007 I'm trying to have my script pull images and tooltips for them from a table. I have succeded in that aspect. But for some reason it only displays everything up until the first space in the text string. For example, the tooltip for one image is "golf tourney 07", but when I mouseover the image it only displays "golf". Any ideas? Quote Link to comment https://forums.phpfreaks.com/topic/71383-solved-display-image-tooltips-using-php/ Share on other sites More sharing options...
BlueSkyIS Posted October 1, 2007 Share Posted October 1, 2007 without seeing code, i can only guess: you may need to url_encode() the string to get the spaces over properly. post code and it may be easier to guess... Quote Link to comment https://forums.phpfreaks.com/topic/71383-solved-display-image-tooltips-using-php/#findComment-359221 Share on other sites More sharing options...
jaymc Posted October 1, 2007 Share Posted October 1, 2007 title="the data here" I assume you dont have quotes If you dont, it will kill itself when it hits a space Its nothing to do with php, php os just your engine Quote Link to comment https://forums.phpfreaks.com/topic/71383-solved-display-image-tooltips-using-php/#findComment-359222 Share on other sites More sharing options...
d.shankar Posted October 1, 2007 Share Posted October 1, 2007 Else try this golf%20tourney%2007 Quote Link to comment https://forums.phpfreaks.com/topic/71383-solved-display-image-tooltips-using-php/#findComment-359226 Share on other sites More sharing options...
BlueSkyIS Posted October 1, 2007 Share Posted October 1, 2007 you're probably going to run into problems with single- and double-quotes, colons, semi-colons, question marks, etc., etc. if you use any of those. use url_encode() and all HTML special chars will be replaced, not just spaces. Quote Link to comment https://forums.phpfreaks.com/topic/71383-solved-display-image-tooltips-using-php/#findComment-359228 Share on other sites More sharing options...
Jago6060 Posted October 1, 2007 Author Share Posted October 1, 2007 here is the script that grabs the caption from a form and inserts it into the table <? $feature = "feature_images"; $images = "crc_images"; $cap = "$_POST[cap]"; if (!isset($_SESSION[user])){ header ('Location: index.php'); } session_start(); include 'connect.php'; // Where the file is going to be placed $target_path = "./uploads/images/"; /* Add the original filename to our target path. Result is "/uploads/images/filename.extension" */ $target_path = $target_path . basename( $_FILES['uploadedfile']['name']); $_FILES['uploadedfile']['tmp_name']; if(move_uploaded_file($_FILES['uploadedfile']['tmp_name'], $target_path)) { echo "The file ". basename( $_FILES['uploadedfile']['name']). " has been uploaded"; @mysql_select_db($database) or die( "Unable to select database"); $sql = "INSERT INTO $feature (img_dir,cap)values('$target_path','$cap')"; $sql2 = "INSERT INTO $images (img_dir)values('$target_path')"; $result=mysql_query($sql); $result2=mysql_query($sql2); mysql_close(); header ('Location: logout.php'); }else{ echo "There was an error uploading the file, please try again!"; echo "<a href=upload_feature_form.php>Back</a>"; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/71383-solved-display-image-tooltips-using-php/#findComment-359268 Share on other sites More sharing options...
BlueSkyIS Posted October 1, 2007 Share Posted October 1, 2007 the data is probably saved properly. i think you're probably losing the stuff at the browser due to the spaces we keep talking about. Quote Link to comment https://forums.phpfreaks.com/topic/71383-solved-display-image-tooltips-using-php/#findComment-359271 Share on other sites More sharing options...
Jago6060 Posted October 1, 2007 Author Share Posted October 1, 2007 yeah, when I check the table in phpmyadmin, the caption shows completely. I'm not sure how to get the complete caption from the table to the browser though. Quote Link to comment https://forums.phpfreaks.com/topic/71383-solved-display-image-tooltips-using-php/#findComment-359272 Share on other sites More sharing options...
BlueSkyIS Posted October 1, 2007 Share Posted October 1, 2007 THAT's the code we need to see. Quote Link to comment https://forums.phpfreaks.com/topic/71383-solved-display-image-tooltips-using-php/#findComment-359276 Share on other sites More sharing options...
Jago6060 Posted October 1, 2007 Author Share Posted October 1, 2007 my bad, heres the display code <? include 'connect.php'; $tdcount = 0; @mysql_select_db($database) or die( "Unable to select database"); $sql = "SELECT * FROM feature_images"; $result=mysql_query($sql); $num=mysql_numrows($result); mysql_close(); echo "<table border=8 bordercolor=#000060 align=center cellspacing=10 cellpadding=10>"; echo "<tr><td colspan=3><center>Cairo Rotary Annual Golf Tournament</center></td></tr>"; echo "<tr>"; $i=0; while ($i < $num) { $d1=mysql_result($result,$i,"img_id"); $d2=mysql_result($result,$i,"img_dir"); $d3=mysql_result($result,$i,"cap"); $img_dim = getimagesize($d2); $width = ($img_dim[0]); $height = ($img_dim[1]); $count = 0; do {$count++; $width = ($img_dim[0]/$count); $height = ($img_dim[1]/$count); } while (($width > 100) && ($height > 100)); echo "<td><center><img src=$d2 border=0 width=$width height=$height alt=$d3></center></td>"; $tdcount++; $i++; if ($tdcount == 3){ echo "</tr>"; $tdcount = 0; } } echo "</table>"; ?> Quote Link to comment https://forums.phpfreaks.com/topic/71383-solved-display-image-tooltips-using-php/#findComment-359282 Share on other sites More sharing options...
BlueSkyIS Posted October 1, 2007 Share Posted October 1, 2007 ALWAYS quote your HTML tag attributes. echo "<td><center><img src='$d2' border='0' width='$width' height='$height' alt='$d3'></center></td>"; ... and if you want your tootips to display in non-IE browsers, add the title='$d3' attribute. Quote Link to comment https://forums.phpfreaks.com/topic/71383-solved-display-image-tooltips-using-php/#findComment-359287 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.