Jump to content

dodgeitorelse3

Members
  • Posts

    253
  • Joined

  • Last visited

  • Days Won

    4

Everything posted by dodgeitorelse3

  1. i forgot to say that simple_html_dom.php is included at the begining of the code above and that simple_html_dom.php resides in same folder as the html file and the php file
  2. Hi all, I have a html file on my server so it is a local file. I would like to get the value of every second <td> in each <tr> as I said it is a local html file and is written as <table border="1" style="font-size:90%; text-align:center; margin: 5px;"> <tr> <th>Song title</th> <th>Artist</th> <th>Decade</th> <th>Genre</th> <th>Single / Pack name</th> <th>Release date</th> <th>Family Friendly</th> <th>Additional <i>Rock Band 3</i> Features</th> </tr> <tr><td>"<a href="http://en.wikipedia.org/wiki/Fortunate_Son" title="Fortunate Son">Fortunate Son</a>"<sup id="cite_ref-cover_14-0" class="reference"><a href="#cite_note-cover-14"><span>[</span>a<span>]</span></a></sup></td> <td><a href="http://en.wikipedia.org/wiki/Creedence_Clearwater_Revival" title="Creedence Clearwater Revival">Creedence Clearwater Revival</a></td> <td>1969</td> <td>Southern Rock</td> <td><span style="display:none" class="sortkey">... !</span><span class="sorttext">Single</span></td> <td><span style="display:none" class="sortkey">2007-11-20 !</span><span class="sorttext">Nov. 20, 2007</span></td> <td style="background: #90ff90; color: black; vertical-align: middle; text-align: center;" class="table-yes">Yes</td> <td style="background:#ff9090; color:black; vertical-align: middle; text-align: center;" class="table-no">None</td> </tr> <tr><td>"<a href="http://en.wikipedia.org/wiki/Juke_Box_Hero" title="Juke Box Hero">Juke Box Hero</a>"<sup id="cite_ref-cover_14-1" class="reference"><a href="#cite_note-cover-14"><span>[</span>a<span>]</span></a></sup></td> <td><a href="http://en.wikipedia.org/wiki/Foreigner_(band)" title="Foreigner (band)">Foreigner</a></td> <td>1981</td> <td>Classic Rock</td> <td><span style="display:none" class="sortkey">... !</span><span class="sorttext">Single</span></td> <td><span style="display:none" class="sortkey">2007-11-20 !</span><span class="sorttext">Nov. 20, 2007</span></td> <td style="background: #90ff90; color: black; vertical-align: middle; text-align: center;" class="table-yes">Yes</td> <td style="background:#ff9090; color:black; vertical-align: middle; text-align: center;" class="table-no">None</td> </tr> <tr><td>"<a href="http://en.wikipedia.org/wiki/Get_It_On_(T._Rex_song)" title="Get It On (T. Rex song)">Bang a Gong</a>"<sup id="cite_ref-cover_14-2" class="reference"><a href="#cite_note-cover-14"><span>[</span>a<span>]</span></a></sup><sup id="cite_ref-scheduled_to_be_removed_august_15-0" class="reference"><a href="#cite_note-scheduled_to_be_removed_august-15"><span>[</span>b<span>]</span></a></sup></td> <td><a href="http://en.wikipedia.org/wiki/T._Rex_(band)" title="T. Rex (band)">T. Rex</a></td> <td>1971</td> <td>Glam</td> <td><span style="display:none" class="sortkey">... !</span><span class="sorttext">Single</span></td> <td><span style="display:none" class="sortkey">2007-11-20 !</span><span class="sorttext">Nov. 20, 2007</span></td> <td style="background:#ff9090; color:black; vertical-align: middle; text-align: center;" class="table-no">No</td> <td style="background:#ff9090; color:black; vertical-align: middle; text-align: center;" class="table-no">None</td> </tr> <tr><td>"<a href="http://en.wikipedia.org/wiki/My_Sharona" title="My Sharona">My Sharona</a>"<sup id="cite_ref-cover_14-3" class="reference"><a href="#cite_note-cover-14"><span>[</span>a<span>]</span></a></sup></td> <td><span style="display:none" class="sortkey">Knack !</span><span class="sorttext"><a href="http://en.wikipedia.org/wiki/The_Knack" title="The Knack">The Knack</a></span></td> <td>1979</td> <td>Pop-Rock</td> <td><span style="display:none" class="sortkey">... !</span><span class="sorttext">Single</span></td> <td><span style="display:none" class="sortkey">2007-11-20 !</span><span class="sorttext">Nov. 20, 2007</span></td> <td style="background:#ff9090; color:black; vertical-align: middle; text-align: center;" class="table-no">No</td> <td style="background: #FFB; color: black; vertical-align: middle; text-align: center;" class="partial table-partial">Pro Guitar/Bass</td> </tr> <tr><td>"<a href="http://en.wikipedia.org/wiki/Cherry_Bomb_(song)" title="Cherry Bomb (song)">Cherry Bomb</a>"<sup id="cite_ref-cover_14-4" class="reference"><a href="#cite_note-cover-14"><span>[</span>a<span>]</span></a></sup></td> <td><span style="display:none" class="sortkey">Runaways !</span><span class="sorttext"><a href="http://en.wikipedia.org/wiki/The_Runaways" title="The Runaways">The Runaways</a></span></td> <td>1976</td> <td>Punk</td> <td><span style="display:none" class="sortkey">... !</span><span class="sorttext">Single</span></td> <td><span style="display:none" class="sortkey">2007-11-20 !</span><span class="sorttext">Nov. 20, 2007</span></td> <td style="background:#ff9090; color:black; vertical-align: middle; text-align: center;" class="table-no">No</td> <td style="background:#ff9090; color:black; vertical-align: middle; text-align: center;" class="table-no">None</td> </tr> goes on for another 1100 <tr>'s ......................................... I tried <?php $url = "rb3_list.html"; $html = new simple_html_dom(); $html = file_get_html($url); foreach($html->find('table tr') as $row) { $cell = $row->find('td', 1); echo $cell; } ?> but all I get is a blank page.
  3. I searched everywhere and found nothing for an acceptable answer for me except to use javascript or jquery. After days of trying to sort it out I found a very simple solution that worked for me. I simply removed the iframe from the div and used the object such as <div class='showchevy'> {$server['s']['map']} <div style='float:left;' class='showchevy_1'> <object type='text/html' data='/maps/php/map_dload2.php?map={$server['s']['map']}' style='width:100%; height:100%' border='0'> </object> </div> </div> I hope this helps folks save a lot of research time.
  4. ok i lost the iframe and found a better way to load an external page into my div and yay it works, no java or jquery.
  5. what I see happening in IE10 is that when I have the mose over the text in <div class"showchevy it shows the hidden div and it's contents. If I put the tip of the mouse pointer to the very bottom edge of the text the hidden file will repeatedly hide and show. So this tells me that I need to somehow make the <iframe> the are that has the focus. As the code is now when I try to move mouse into the iframe it hides again because of moving cursor from text. Any suggestions?
  6. maybe this is clearer? <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <style type="text/css"> .voip tr td .showchevy_1{ display: none; } .voip tr td .showchevy:hover .showchevy_1{ position: relative; display : block; } </style> </head> <body STYLE="background-color:transparent"> <?php echo "<table class='voip' cellpadding='0' cellspacing='0' style='width:10%; margin:auto; text-align:center'> <tr> <td title='Server ip and port---' style='padding:0px; text-align:center'> <div class='showchevy'>In firefox I can click the link below but in IE10 I can't ..... <div class='showchevy_1'> <iframe id='svr_lnk' class='svr_lnk' scrolling='no' marginwidth='0' marginheight='0' frameborder='0' vspace='0' hspace='0' style='overflow:visible;' src='http://chevys-place.nl/gsreaders/lgsl/lgsl_files/svr_shortcuts/chevy_svr_1.html'> </iframe> </div> </div> </td> </tr> </table>"; ?> </body> </html>
  7. I have a webpage that has a hidden div that will show when hovered. When I hover it, I can see the hidden div which contains an iframe. My porblem is no matter what I try I can't get the mouse to move into the block showing the iframe where there is a link. Once I move off the div to go to the iframe it disappears again. Can any one help me sort this? it works fine in firefox. <div class='showchevy'> {$server['s']['map']} <div style='float:left;' class='showchevy_1'> <iframe id='mapdl' class='mapd' scrolling='no' marginwidth='0' marginheight='0' frameborder='0' vspace='0' hspace='0' style='overflow:visible; width:100%;' src='/maps/php/map_dload2.php?map={$server['s']['map']}'> </iframe> </div></div> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <meta http-equiv="refresh" content="165" > <style type="text/css"> .voip tr td .showchevy_1{ display: none; } .voip tr td .showchevy:hover .showchevy_1{ position: relative; display : block; }
  8. forgot to add the following counters Table comments: VIEW Field Type Null Default Comments filename varchar(255) No stats int(11) No maps_view Table comments: VIEW Field Type Null Default Comments id int(100) No 0 name varchar(200) No as for things I have tried so far ..... none I am asking for guidance for where to start, not for someone to write the code for me.
  9. I have 2 separate tables both hosted in different database on same host. The first table is in "aa" database and is called "maps" and has "id" and "name" for columns (there are several more columns that I am not using for this situation nor are they named same as any columns in table 2). This table contains the name of our maps that are available for downloads (the dload links are in a column in this db named "content"). the map names in the "name" column are for example KitchenWar. The second table is in "counts" database and is called "downloads" contains columns named "filename" and "stats" (these are the only 2 columns in this table). This database is for keeping count of the number of downloads from first table which is done via a file called downloads.php. The map names in the "filename" column are for example maps/KitchenWar.aao What I have is a webpage that holds a table that contains all the data from table "maps" and the last row of the table has a column labeled dl's which I want to hold the "stats" from table named "maps" that matches the "name" from "maps" table. My question is this ..... how do I go about trying to compare "name" column to "filename" column and then show the "stats" that match? exaples of db tables ... table "maps" id name --------------------------------------------------------- Auto increment KitchenWar table "downloads" filename stats --------------------------------------------------------- maps/KitchenWar.aao 64
  10. try mysql_query("SELECT * FROM species WHERE commonName='".$commonName."'") or die(mysql_error());
  11. Solved using preg_replace('/[^a-zA-Z0-9_ %\[\]\.\(\)%&-]/s', '', $map) Thanks for your help mac_gyver, just needed to be pointed in right direction.
  12. ahhh, looking at the view source it is showing <div style='float:left;' class='showchevy_1'> <iframe id='mapdl' scrolling='no' marginwidth='0' marginheight='0' frameborder='0' vspace='0' hspace='0' style='overflow:visible; width:100%;' src='/maps/php/map_dload2.php?map=Abbusata_Bridge_Coop​'> </iframe> </div> It must be getting the ​ from the game server itself during query. I assume I have to make a change in my database for the collation for this column. Any suggestions? I tried setting the trname column for this map to Abbusata_Bridge_Coop​ but still doesn't find it. the source code for the echo is <body bgcolor="darkslategrey"><br> Abbusata_Bridge_Coop​<font color='lightgreen' size=2><b><i><font color='white'>Abbusata_Bridge_Coop​</font></i></b> was not found.</font></body>
  13. I have a query such as : $map = mysql_real_escape_string ($_GET['map']); //echo $map; $result = mysql_query("select content, size, released, creator, modder, type from `maps` WHERE `trname` LIKE '$map%' ORDER BY trname ASC") or die('Error, query failed'); this works fine except for one map which is called Abbusata_Bridge_Coop. When $_GET['map'] is equal to Abbusata_Bridge_Coop I can echo $map and it displays as such but in the query it returns it cannot find it in database however when I change query to $result = mysql_query("select content, size, released, creator, modder, type from `maps` WHERE `trname` LIKE 'Abbusata_Bridge_Coop' ORDER BY trname ASC") it works. Can anyone shed some light on this issue for me? I should say that I use $map% in query because I need to show all maps that start with that name (some have added text at end of them).
  14. you are mostly wrong by not giving us any info as to why you think something is wrong ..... we have better things to do than sit and sift through your code trying to find something that may or may not be correct. If you want an answer then you should follow the posting guidelines.
  15. @ Jessica, I will try to figure out how to just update without selecting the rows. I have a new column in the database that holds the word "New" which shows on our downloads pagew to let the users know which maps arte the 10 newest. Please see http://chevys-place.nl/downloads.php What we have is a standalone cms and the owner of the site is even more of a noob than I so I am making him a control panel to edit all his files saving him from going to each file and manually editing it. Basically I am trying to automate as much as I can for him lol. Imagine a noob making it easier for a noob
  16. I have tried your suggestion and cannot get it to update more than the same 1 row I was getting when I originally posted. I also tried removing the i from your code at both mysqli sections to no avail.
  17. would I need to use a foreach instead of doing the update in the while statement?
  18. I have written some code to update last 10 newest maps in my database that are decided by the date in a column named released. I have written the code to show me step by step what is happening. However the only row that gets updated is the 10th one. I first show what rows are labeled New in db, then the code clears all those rows. It then shows me a list of the 10 rows to be updated and then shows the rows that have been updated. this is the code for this.... <html> <head> <title>Update 10 newest maps in database</title> </head> <body> <?php // show maps marked as new $conn = mysql_connect('localhost','xxx','xxx'); if(!$conn) die("Failed to connect to database!"); $status = mysql_select_db(americas_army, $conn); if(!$status) die("Failed to select database!"); // show maps marked as new $sql_current = "select content, released, Newest from maps WHERE Newest = 'New' ORDER BY released desc"; $result_current = mysql_query($sql_current); $num_rows = mysql_num_rows($result_current); $i=1; echo '<font size=3>These are the current maps marked as new in database</font>'; echo '<table>'; echo '<thead>'; echo '<tr>'; echo '<th bgcolor="transparent" align="left"><font color="Black">Status</font></th>'; echo '<th width="160" bgcolor="transparent" align="center"><font color="black">Released</font></th>'; echo '<th width="180" bgcolor="transparent" align="center"><font color="black">Content</font></th>'; echo '</tr>'; echo '</thead>'; while($rows_current=mysql_fetch_assoc($result_current)){ echo "<tr><td align='left'><font color='black'><blink>".$rows_current[Newest]."</blink></font></td><td align='left'><font color='black'><b>".$rows_current[released]."</b></font></td><td align='center'><font color='black'>".$rows_current[content]."</font></td></tr>"; } echo '</table>'; //clear New from Newest column //clear New from Newest column $sql_clear = "UPDATE maps ". "SET Newest = '' "; mysql_select_db('americas_army'); $retval = mysql_query( $sql_clear, $conn ); if(! $retval ) { die('<br />Could not enter New data in Newest column: ' . mysql_error()); } echo "<br />Cleared New data in Newest column successfully\n"; // show any fields with New left in Newest column $sql_cleared_results = "select content, released, Newest from maps WHERE Newest = 'New' ORDER BY released desc"; $result_cleared_results = mysql_query($sql_cleared_results); $num_rows = mysql_num_rows($result_cleared_results); $i=1; echo '<br /><br /><font size=3>These are the current maps marked as new that were not cleared to prepare for adding New to last 10 maps (should show none)</font>'; echo '<table>'; echo '<thead>'; echo '<tr>'; echo '<th bgcolor="transparent" align="left"><font color="Black">Status</font></th>'; echo '<th width="160" bgcolor="transparent" align="center"><font color="black">Released</font></th>'; echo '<th width="180" bgcolor="transparent" align="center"><font color="black">Content</font></th>'; echo '</tr>'; echo '</thead>'; while($rows_cleared_results=mysql_fetch_assoc($result_cleared_results)){ echo "<tr><td align='left'><font color='black'><blink>".$rows_cleared_results[Newest]."</blink></font></td><td align='left'><font color='black'><b>".$rows_cleared_results[released]."</b></font></td><td align='center'><font color='black'>".$rows_cleared_results[content]."</font></td></tr>"; } echo '</table>'; // show newest 10 maps to be marked as new $sql_to_be_marked_new = "select content, released, Newest from maps ORDER BY released desc limit 10"; $result_to_be_marked_new = mysql_query($sql_to_be_marked_new); $num_rows = mysql_num_rows($result_to_be_marked_new); $i=1; echo '<br /><br /><font size=3>These are the 10 maps to be marked as new in database</font>'; echo '<table>'; echo '<thead>'; echo '<tr>'; echo '<th bgcolor="transparent" align="left"><font color="Black">Status</font></th>'; echo '<th width="160" bgcolor="transparent" align="center"><font color="black">Released</font></th>'; echo '<th width="180" bgcolor="transparent" align="center"><font color="black">Content</font></th>'; echo '</tr>'; echo '</thead>'; while($rows_to_be_marked_new=mysql_fetch_assoc($result_to_be_marked_new)){ echo "<tr><td align='left'><font color='black'><blink>".$rows_to_be_marked_new[Newest]."</blink></font></td><td align='left'><font color='black'><b>".$rows_to_be_marked_new[released]."</b></font></td><td align='center'><font color='black'>".$rows_to_be_marked_new[content]."</font></td></tr>"; $sql_add_new = "UPDATE maps ". "SET Newest = 'New' ". "WHERE released = '".$rows_to_be_marked_new[released]."'" ; } echo '</table>'; $last_ten_results_to_be_marked_as_new[] = "$rows_to_be_marked_new[Newest]"; //Update New from 10 most recent form released column while($rows_to_be_marked_new=mysql_fetch_assoc($result_to_be_marked_new)){ $sql_add_new = "UPDATE maps ". "SET Newest = 'New' ". "WHERE released = '".$rows_to_be_marked_new[released]."'" ;} mysql_select_db('americas_army'); $retval = mysql_query( $sql_add_new, $conn ); if(! $retval ) { die('<br /><br />Could not add New data in Newest column: ' . mysql_error()); } echo "<br /><br />Added New data in Newest column successfully\n"; // get 10 newest maps by released column $sql_new_results = "select content, released, Newest from maps ORDER BY released desc limit 10"; $result_new_results = mysql_query($sql_new_results); $num_rows = mysql_num_rows($result_new_results); $i=1; echo '<br /><br /><font size=3>These are the newest 10 maps marked as new </font>'; echo '<table>'; echo '<thead>'; echo '<tr>'; echo '<th bgcolor="transparent" align="left"><font color="Black">Status</font></th>'; echo '<th width="160" bgcolor="transparent" align="center"><font color="black">Released</font></th>'; echo '<th width="180" bgcolor="transparent" align="center"><font color="black">Content</font></th>'; echo '</tr>'; echo '</thead>'; while($rows_new_results=mysql_fetch_assoc($result_new_results)){ echo "<tr><td align='left'><font color='black'><blink>".$rows_new_results[Newest]."</blink></font></td><td align='left'><font color='black'><b>".$rows_new_results[released]."</b></font></td><td align='center'><font color='black'>".$rows_new_results[content]."</font></td></tr>"; } echo '</table>'; mysql_close(); ?> This is the screen shot of what I see on page when code is executed. Any ideas why it only updates the one row? sorry had the code to update rows commented out, removed comment marks.
  19. ok, after fiddling around with this I used //loop through array using foreach foreach($lines as $line) { if (strstr($line,$key)){ //look for $key in each line fwrite($f,$new_tt); } fwrite($f,$line); //place $line back in file } and it works like a charm. davidAM thank you very much. @ denno020, I will still try what you suggested so I can learn a bit more so a thank you to you also.
  20. @ DavidAM, I tried your suggestion first by changing code to //loop through array using foreach foreach($lines as $line) { if (strstr($line,$key)){ //look for $key in each line fwrite($f,$new_tt); fwrite($f,$line); //place $line back in file } } which did put the new line before the key line but it did not put the first part of the file back in giving me this tooltips[5654]=["/mapimages/", "<br><br>Objectives:<br>A: <br>B: <br>C: <br>D: <br><br>Terrain: <br><br>Creator: <br><br>Modder: <br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] return tooltips //do not remove/change this line as my finished file. I assume I misunderstood what you said. @ denno020, I have to look at the preg_grep, the array_splice and the file_put_contents as all of this file writing stuff is new to me.
  21. Hi folks, I am stumped as to why I cannot write data to a specific pointer position in an existing file. The file I want to write to contains ... ****many other lines are here, removed to shorten for this post**** tooltips[304]=["/mapimages/tn_spider1.jpg", "Operation_BlackSpider120<br><br>Objectives:<br>A: Make contact with the Black Spider<br>B: Locate the case that has the laptop location<br>C: Locate and hack the laptop<br>D: Use access code and release the prissoners<br>E: Move out and locate the extractionpoint <br><br>Terrain: Snow and Hills<br><br>Creator: SF{Ops}PatFinder<br><br>Modder: <br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] tooltips[305]=["/mapimages/tn_296_nomap.jpg", "The_Observatory_PF<br><br>Objectives:<br>A: Infiltrate the Observatory Complex<br>B: Locate and secure experimental communications data<br>C: Disable the laser weapon system<br>D: Restore power to sattellite communication system<br>E: Restore main power grid<br>F: Radio for extraction<br>G: Locate extraction point<br><br>Terrain: In and outside buildings<br><br>Creator: -{KWK}-Kman<br><br>Modder: SF{Ops}PatFinder<br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] tooltips[306]=["/mapimages/tn_296_nomap.jpg", "The_Breach<br><br>Objectives:<br>A: <br>B: <br>C: <br>D: <br>E: <br>F: <br>G: <br><br>Terrain: <br><br>Creator: -{KWK}-Kman<br><br>Modder: <br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] tooltips[307]=["/mapimages/tn_radio1.jpg", "SFRadioTower<br><br>Objectives:<br>A: Disable the radiotower antenna generator<br>B: Rescue AID worker<br>C: Destroy the attack helicopter<br>D: Destroy the weapon cache<br><br>Terrain: <br><br>Creator: 151Alpha<br><br>Modder:<br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] tooltips[308]=["/mapimages/tn_agency.jpg", "The_Agency<br><br>Objectives:<br>A: Infiltrate the intelligence facility (7x)<br>B: Locate and question the analist<br>C: Secure the stolen intel<br>D: Access the mainframe to stop any intel transfer<br>E: Locate extraction point<br><br>Terrain: <br><br>Creator: -{KWK}-Kman<br><br>Modder:<br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] return tooltips //do not remove/change this line }(), tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips //***** NO NEED TO EDIT BEYOND HERE tipprefix: 'imgtip', //tooltip ID prefixes createtip:function($, tipid, tipinfo){ if ($('#'+tipid).length==0){ //if this tooltip doesn't exist yet return $('<div id="' + tipid + '" class="ddimgtooltip" />').html( '<div style="text-align:center"><img src="spacer.jpg" data-src="' + tipinfo[0] + '" /></div>' + ((tipinfo[1])? '<div style="text-align:left; margin-top:5px">'+tipinfo[1]+'</div>' : '') ) .css(tipinfo[2] || {}) .appendTo(document.body) } return null }, positiontooltip:function($, $tooltip, e){ var x=e.pageX+this.tooltipoffsets[0], y=e.pageY+this.tooltipoffsets[1] var tipw=$tooltip.outerWidth(), tiph=$tooltip.outerHeight(), x=(x+tipw>$(document).scrollLeft()+$(window).width())? x-tipw-(ddimgtooltip.tooltipoffsets[0]*2) : x y=(y+tiph>$(document).scrollTop()+$(window).height())? $(document).scrollTop()+$(window).height()-tiph-10 : y $tooltip.css({left:x, top:y}) }, showbox:function($, $tooltip, e){ var $tipimage=$tooltip.find('img:eq(0)') if (!$tipimage.attr('data-srcloaded')) $tipimage.attr({'src':$tipimage.attr('data-src'), 'data-srcloaded':1}) $tooltip.show() this.positiontooltip($, $tooltip, e) }, hidebox:function($, $tooltip){ $tooltip.hide() }, init:function(targetselector){ jQuery(document).ready(function($){ var tiparray=ddimgtooltip.tiparray var $targets=$(targetselector) if ($targets.length==0) return var tipids=[] $targets.each(function(){ var $target=$(this) $target.attr('rel').match(/\[(\d+)\]/) //match d of attribute rel="imgtip[d]" var tipsuffix=parseInt(RegExp.$1) //get d as integer var tipid=this._tipid=ddimgtooltip.tipprefix+tipsuffix //construct this tip's ID value and remember it var $tooltip=ddimgtooltip.createtip($, tipid, tiparray[tipsuffix]) $target.mouseenter(function(e){ var $tooltip=$("#"+this._tipid) ddimgtooltip.showbox($, $tooltip, e) }) $target.mouseleave(function(e){ var $tooltip=$("#"+this._tipid) ddimgtooltip.hidebox($, $tooltip) }) $target.mousemove(function(e){ var $tooltip=$("#"+this._tipid) ddimgtooltip.positiontooltip($, $tooltip, e) }) if ($tooltip){ //add mouseenter to this tooltip (only if event hasn't already been added) $tooltip.mouseenter(function(){ ddimgtooltip.hidebox($, $(this)) }) } }) }) //end dom ready } } //ddimgtooltip.init("targetElementSelector") ddimgtooltip.init("*[rel^=imgtip]") I want to write to this file at the space before the line containing "return tooltips" without the quotes. Note that line is 71 lines from the bottom. This is the code I use to write to the file .... <?php echo("Tooltip ID Number from db: " . $_POST['tooltip_number'] . "<br />\n"); echo("Thumbnail name for image: " . $_POST['tn_image'] . "<br />\n"); echo("Map Name: " . $_POST['map_name'] . "<br />\n"); echo("Objective A: " . $_POST['obj_a'] . "<br />\n"); echo("Objective B: " . $_POST['obj_b'] . "<br />\n"); echo("Objective C: " . $_POST['obj_c'] . "<br />\n"); echo("Objective D: " . $_POST['obj_d'] . "<br />\n"); echo("OTerrain: " . $_POST['terrain'] . "<br />\n"); echo("Creator: " . $_POST['creator'] . "<br />\n"); echo("Modder: " . $_POST['modder'] . "<br />\n"); echo("Mods: " . $_POST['mods'] . "<br />\n"); echo "<br /><br /><br />"; $new_tt = "\r\n\r\n tooltips[" . $_POST['tooltip_number'] . "]=[\"/mapimages/" . $_POST['tn_image'] . "\", \"" . $_POST['map_name'] . "<br><br>Objectives:<br>A: " . $_POST['obj_a'] . "<br>B: " . $_POST['obj_b'] . "<br>C: " . $_POST['obj_c'] . "<br>D: " . $_POST['obj_d'] . "<br><br>Terrain: " . $_POST['terrain'] . "<br><br>Creator: " . $_POST['creator'] . "<br><br>Modder: " . $_POST['modder'] . "<br><br>Mods: " . $_POST['mods'] . "\", {background:\"gray\", border:\"none\", font:\"bold 12px Arial\", color:\"black\"}]\r\n\r\n"; echo "$new_tt"; $key = 'return tooltips'; //copy file to prevent double entry $file = "test_fwrite_file.js"; $newfile = "test_fwrite_file.txt"; copy($file, $newfile) or exit("failed to copy $file"); //load file into $lines array $fc = fopen ($file, "r"); while (!feof ($fc)) { $buffer = fgets($fc, 4096); $lines[] = $buffer; } fclose ($fc); //open same file and use "w" to clear file $f=fopen($newfile,"w") or die("couldn't open $file"); /* uncomment to debug print_r($lines); print "<br>\n"; */ //loop through array using foreach foreach($lines as $line) { fwrite($f,$line); //place $line back in file if (strstr($line,$key)){ //look for $key in each line fwrite($f,$new_tt); } //place $line back in file } fclose($f); copy($newfile, $file) or exit("failed to copy $newfile"); ?> however when it writes to the file it places it after the $key such as tooltips[308]=["/mapimages/tn_agency.jpg", "The_Agency<br><br>Objectives:<br>A: Infiltrate the intelligence facility (7x)<br>B: Locate and question the analist<br>C: Secure the stolen intel<br>D: Access the mainframe to stop any intel transfer<br>E: Locate extraction point<br><br>Terrain: <br><br>Creator: -{KWK}-Kman<br><br>Modder:<br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] return tooltips //do not remove/change this line tooltips[5654]=["/mapimages/", "<br><br>Objectives:<br>A: <br>B: <br>C: <br>D: <br><br>Terrain: <br><br>Creator: <br><br>Modder: <br><br>Mods: ", {background:"gray", border:"none", font:"bold 12px Arial", color:"black"}] }(), tooltipoffsets: [20, -30], //additional x and y offset from mouse cursor for tooltips //***** NO NEED TO EDIT BEYOND HERE what do I need to do to place it at the right spot?
  22. I use http://www.dynamicdrive.com/dynamicindex4/imagetooltip.htm
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.