Post Reply 
 
Thread Rating:
  • 0 Votes - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Qtip - how to insert tag <?php ?> in "alt"
7th March, 03:22
Post: #1
Qtip - how to insert tag <?php ?> in "alt"
good afternoon,
I'm newbie here ..
I use qtip for my map, but I want the text that's appear in my tooltip is taken from database ..

alt="<b>Luwu timur</b><br>Kabupaten Luwu Timur adalah salah satu Daerah Tingkat II di Provinsi Sulawesi Selatan. Kabupaten ini berasal dari pemekaran Kabupaten Luwu Utara yang disahkan dengan UU Nomor 7 Tahun 2003 pada tanggal 25 Ferbruari 2003. Malili adalah ibu kota dari kabupaten Luwu Timur yang terletak di ujung utara Teluk Bone. Kabupaten ini memiliki luas wilayah 6.944,98 km²."
--> I want to take the text from database because the text is to long and isn't real time if some information is updated ..

I tried this one --> alt="<b>Luwu timur</b><br><?php echo str_replace("\n","<br>",$q['detail']); ?>" but nothing happens ..

Anyone can help me please??
I'll appreciate that ..thx b4^^

Here's the script :

<script type="text/javascript" src="jquery.qtip-1.0.0-rc3.min.js"></script>
<script type="text/javascript" src="qtip.js"></script>

<?php
include("connect.php");
$nama=$_GET['nama'];
$q=mysql_fetch_array(mysql_query("SELECT * FROM kabupaten WHERE nama='$nama'"));
?>

<div align="center"> <font color="green" size="+1">*Klik kota/kabupaten pada peta untuk melihat informasi tanaman pangan</font></div>
<table border="1" width="1000" align="center">
<tr valign="top">
<td align="center"><img class="castmap" src="image/sulsel2.jpg" usemap="#sulsel" />
<map name="sulsel">
<area class="{fillColor:'00ff00'}" shape="poly" alt="<b>Luwu timur</b><br>Kabupaten Luwu Timur adalah salah satu Daerah Tingkat II di Provinsi Sulawesi Selatan. Kabupaten ini berasal dari pemekaran Kabupaten Luwu Utara yang disahkan dengan UU Nomor 7 Tahun 2003 pada tanggal 25 Ferbruari 2003. Malili adalah ibu kota dari kabupaten Luwu Timur yang terletak di ujung utara Teluk Bone. Kabupaten ini memiliki luas wilayah 6.944,98 km²." coords="430,65,466,75,504,93,528,97,562,116,568,125,583,124,609,136,620,150,630,170,619,​169,612,185,603,197,603,201,581,210,567,225,553,229,541,229,527,244,522,241,512,​231,509,221,500,224,496,215,492,203,487,197,489,187,485,181,478,184,467,193,463,​191,476,179,486,169,477,165,471,156,466,164,460,159,453,158,448,160,444,153,436,​157,427,148,422,151,416,149,408,155,401,143,393,128,366,80,382,53,404,67,420,72"
href="index.php?hal=kabupaten&nama=Luwu Timur" />
<area class="{fillColor:'00ff00'}" shape="poly" alt="<b>Luwu Utara</b><br>Kabupaten Luwu Utara adalah salah satu kabupaten yang berada di Propinsi Sulawesi Selatan. Kabupaten ini memiliki penduduk 267,779 jiwa, dimana 136,246 jiwa laki-laki dan 131,533 jiwa wanita."
coords="339,2,346,4,352,8,357,14,359,22,365,31,370,37,377,46,383,54,376,65,370,73,369,79​,367,81,371,89,378,100,385,112,390,120,397,131,400,142,408,153,400,154,395,160,3​92,161,385,160,383,163,376,164,377,169,372,172,368,176,365,180,359,185,353,189,3​46,193,342,195,331,202,327,205,327,196,327,183,317,181,306,176,301,176,291,173,2​80,167,273,169,262,159,248,160,237,167,228,159,217,148,207,143,201,138,202,129,2​06,122,198,114,201,107,203,105,200,95,194,90,187,86,182,84,179,82,179,78,184,69,​184,61,187,53,207,38,213,41,217,35,226,32,231,33,237,35,246,27,253,25,258,17,265​,14,272,16,283,15,282,24,289,26,296,28,309,27,319,27,331,35"
href="index.php?hal=kabupaten&nama=Luwu Utara"/>
</map>
</td>
</tr>
</table>
Find all posts by this user
Quote this message in a reply
7th March, 05:17
Post: #2
RE: Qtip - how to insert tag <?php ?> in "alt"
Looks like you're missing a whole lot of details in the information you provided. Anyone that can help is going to need a bit more to help you figure out. Right now, the code you've provided really doesn't do much. I don't see any qTip initialization or any clue as to how you're populating the tooltip content.

In a nutshell, you're going to need to do at least a couple of things depending on how you want to implement it:
  • If you want it to pull the name each time you hover over the tooltip trigger, you'll need to create a web service/page whose sole purpose is to fetch the name. You'll call this page via qTip's AJAX functionality and qTip will populate the tooltip with the output from the page.
  • If you only need the tips updated on page load, then you can place the text that you want in a variety of places (hidden div, rel attribute, title attribute etc) and populate that content when you initialize your qTips.
  • Also, you *really* should sanitize your input from the querystring!! Doing "$nama=$_GET['nama'];" and then immediately putting $nama in your SQL query is a guaranteed way to suffer from a SQL injection attack. You should never, ever, ever do that Smile
  • You should make sure that the column "detail" is in the result set of your query. You're using the wildcard (SELECT *), so it's not clear.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)