
SchweppesAle
Members-
Posts
328 -
Joined
-
Last visited
Everything posted by SchweppesAle
-
[SOLVED] adding text before/after all images in the page
SchweppesAle replied to SchweppesAle's topic in Javascript Help
sorry about that. I pulled out too much before i posted the code. myImages is an array of every image within the set element. So the images themselves have already been placed within the html document. I'm having trouble with adding the additional tags before and after each image. <script language="javascript" type="text/javascript"> <!-- function resize_images() { var myDiv = document.getElementById('center'); var myImages = myDiv.getElementsByTagName("img"); for (i = 0; i < myImages.length; i++) { /* while ( !myImages[i].complete ) { }*/ myImages[i].style.display = "inline"; if ( myImages[i].width > 450 && (myImages[i].className != 'noresize')) { var tempHeight = myImages[i].height; var tempWidth = myImages[i].width; myImages[i].onclick=function() { var picture = window.open(this.src, 'popupwindow' , 'width ='+tempWidth+', height = '+tempHeight+', scrollbars = no, resizable'); picture.focus(); return false; }; myImages[i].style.border = '2px solid #ffffff'; myImages[i].onmouseover = function(){ this.style.border = '2px solid red'; return false; }; myImages[i].onmouseout = function(){ this.style.border = '2px solid #ffffff'; return false; }; var scaleheight = 450/(myImages[i].width) *(myImages[i].height); myImages[i].width = 450; myImages[i].height = scaleheight; myImages[i].style.cursor='pointer';/* document.write("<br/>"); document.write("click to enlarge");*/ } myImages[i].style.visibility = "visible"; } } //--> </script> -
[SOLVED] adding text before/after all images in the page
SchweppesAle replied to SchweppesAle's topic in Javascript Help
I'd like to modify the following code so that each image of width > 450 is wrapped by a link tag document.write('<a href = "myImages[i].src" rel = "lightbox">'); then at the end of that image document.write('</a>'); The only problem is, I'm not exactly sure how to append these tags before and after each image. <script language="javascript" type="text/javascript"> <!-- function resize_images() { for (i = 0; i < myImages.length; i++) { myImages[i].style.display = "inline"; if ( myImages[i].width > 450 && (myImages[i].className != 'noresize')) { var tempHeight = myImages[i].height; var tempWidth = myImages[i].width; myImages[i].onclick=function() { var picture = window.open(this.src, 'popupwindow' , 'width ='+tempWidth+', height = '+tempHeight+', scrollbars = no, resizable'); picture.focus(); return false; }; myImages[i].style.border = '2px solid #ffffff'; myImages[i].onmouseover = function(){ this.style.border = '2px solid red'; return false; }; myImages[i].onmouseout = function(){ this.style.border = '2px solid #ffffff'; return false; }; var scaleheight = 450/(myImages[i].width) *(myImages[i].height); myImages[i].width = 450; myImages[i].height = scaleheight; myImages[i].style.cursor='pointer';/* document.write("<br/>"); document.write("click to enlarge");*/ } myImages[i].style.visibility = "visible"; } } //--> </script> -
was that a joke or are you serious
-
another thing that I've noticed is that the script will actually lock up Internet Explorer if there's a broken image on the page.
-
Not really, although that would be pretty cool. I'm really just trying to make all the images appear(resized) as they're downloaded to the user's browser. Unfortunately, the script won't set their display to inline until "all" the images are downloaded. Or at least, that's the impression I'm getting. So rather than each image appearing one by one as the page is loaded, they all appear at the same time and only if the page has finished loading all other objects. If one of our banners are taking a long time to appear because google's servers are down, the images flat out just won't show up
-
it works by taking all images which I've set to display none; displays them inline, scales them down to a set size(if they're too large), then it sets their visibility property to visible. The only problem with this is that all images display simulatinously "after" the page is done loading. Is there a better way of doing this? The script is shown in my last post.
-
Hi, I have this script which pulls all images from the page, then resizes and sets their display back to inline. Unfortunately, rather than waiting for each image to load; it seems to be waiting for all of them before executing the rest of the script. I've also noticed that having a broken image on the page will cause IE to slow to a crawl. Any ideas? #center img{ display:none; visibility:hidden; } #Latest img{ visibility:hidden; display:none; } #Latest2 img{ margin-right:5px; visibility:hidden; display:none; } </style> <script language="javascript" type="text/javascript"> function checkImageSize() { if (document.getElementById('Latest2') != null) { resize_FrontAuthor(); } if (document.getElementById('Latest') != null) { resize_ListAuthors(); } resize_images(); } </script> <script language="javascript" type="text/javascript"> <!-- function resize_images() { var myDiv = document.getElementById('center'); var myImages = myDiv.getElementsByTagName("img"); for (i = 0; i < myImages.length; i++) { while ( !myImages[i].complete ) { } myImages[i].style.display = "inline"; var tempHeight = myImages[i].height; var tempWidth = myImages[i].width; if ( myImages[i].width > 300 && (myImages[i].className != 'noresize')) { var scaleheight = 300/(myImages[i].width) *(myImages[i].height); myImages[i].width = 300; myImages[i].height = scaleheight; myImages[i].style.cursor='pointer'; } myImages[i].style.visibility = "visible"; } } //--> </script> <noscript> <style type="text/css"> #center img{ visibility:visible; display:inline; max-width: 400px; width: expression(this.width > 400 ? 400: true); } </style> </noscript> <script language="javascript" type="text/javascript"> <!-- function resize_ListAuthors() { var myDiv = document.getElementById('Latest'); var myImages = myDiv.getElementsByTagName("img"); for (i = 0; i < myImages.length; i++) { while ( !myImages[i].complete ) { } myImages[i].style.display = "inline"; var tempHeight = myImages[i].height; var tempWidth = myImages[i].width; if ( myImages[i].width > 100 && (myImages[i].className != 'noresize')) { var scaleheight = 100/(myImages[i].width) *(myImages[i].height); myImages[i].width = 100; myImages[i].height = scaleheight; myImages[i].style.cursor='pointer'; } myImages[i].style.visibility = "visible"; } } //--> </script> <noscript> <style type="text/css"> #Latest img { visibility:visible; display:inline; max-width: 100px; width: expression(this.width > 400 ? 400: true); padding-right:15px; } </style> </noscript> <script language="javascript" type="text/javascript"> <!-- function resize_FrontAuthor() { var myDiv = document.getElementById('Latest2'); var myImages = myDiv.getElementsByTagName("img"); for (i = 0; i < myImages.length; i++) { while ( !myImages[i].complete ) { } myImages[i].style.display = "inline"; var tempHeight = myImages[i].height; var tempWidth = myImages[i].width; if ( myImages[i].width > 75 && (myImages[i].className != 'noresize')) { var scaleheight = 75/(myImages[i].width) *(myImages[i].height); myImages[i].width = 75; myImages[i].height = scaleheight; myImages[i].style.cursor='pointer'; } myImages[i].style.visibility = "visible"; } } //--> </script> <noscript> <style type="text/css"> #Latest2 img { visibility:visible; display:inline; max-width: 75px; width: expression(this.width > 400 ? 400: true); padding-right:15px; } </style> </noscript>
-
[SOLVED] php question regarding while statement
SchweppesAle replied to SchweppesAle's topic in PHP Coding Help
that was actually really helpful. I think I get it now, thanks. -
[SOLVED] php question regarding while statement
SchweppesAle replied to SchweppesAle's topic in PHP Coding Help
alright, I guess that makes sense. Maybe I'm just not use to declaring variables within the while statement ??? Anyway, thanks for clearing that up. -
hi, this is probably a really simple question. Up until now I've just been using the following method in order to loop through a mysql query. mysql_select_db("account6_jo152"); $result = mysql_query("SELECT * FROM blahblah WHERE yadayada = '0'"); while($row = mysql_fetch_array($result)) { /*manipulate some column like so for each entry*/ $row['somecolumn']; } I understand that the mysql_fetch_array() method is storing the query within an array named $row; what confuses me is how this statement is incrementing after each iteration. Shouldn't while statements simply continue to loop the same thing over and over again until the condition no longer holds true? How is it cycling through each element in the array?
-
hi, I was wondering if it's possible to take all the input values then store them within array which I can pass onto a script which will handle it. The reason I'm doing this is because I have a script which will generate a different number of "checkbox" input types depending on how large the database has grown and I'm not sure how to pull these values since you need to declare the name of each input. ex: $_GET["name"] I figured that if I could store them all within a single array then there wouldn't be a problem. Is there a better way of doing this? edit: just wanted you guys to get an idea of what I'm working with <?php global $mainframe; $db =&JFactory::getDBO(); $query = "SELECT * FROM #__AuthorList"; $db->setQuery( $query, 0, $count ); $rows = $db->loadObjectList(); $number = 0; echo "<form method='get' action='script name'>"; echo "<table border = 1 width = 500><tr><td>"; echo "<center><b>Primary List</b></center>"; echo "</td></tr>"; foreach($rows as $row) { if (($row -> stage) == 0 && (($row -> AuthorName) != LeaveBlank) && (($row -> AuthorName) != null)) { echo "<tr><td>"; echo $row ->AuthorName; echo "</td><td>"; echo "<input type='checkbox' name='".$row->AuthorID."' value='".$row->AuthorID."'>"; echo "</tr></td>"; } } echo "</table>"; echo "<p/>"; echo "<table border = 1 width = 500><tr><td>"; echo "<center><b>Secondary List</b></center>"; echo "</td></tr>"; foreach($rows as $row) { if (($row -> stage) == -1 && (($row -> AuthorName) != LeaveBlank2) && (($row -> AuthorName) != null)) { echo "<tr><td>"; echo $row ->AuthorName; echo "</td><td>"; echo "<input type='checkbox' name='".$row->AuthorID."' value='".$row->AuthorID."'>"; echo "</tr></td>"; } } echo "</table>"; echo "<p/>"; echo "<input type='hidden' name='number' value='".$number."'>" echo "<INPUT type='submit' value='Switch Current List'>"; echo "</form>"; ?>
-
not so graceful code - cycles mysql list incorrectly
SchweppesAle replied to SchweppesAle's topic in PHP Coding Help
i really don't see why this wouldn't work. Is it the mysql_query? :-\ -
hi, I'm having trouble cycling this list of users. there are four columns; AuthorID, AuthorName, position, stage. It's intended to pull the last authorName and ID based on position then slip it into the first position and move the rest down. Instead it pulls the second to last and places it at the top. What makes it strange is the following output which displays both the array containing current list of names/ids vs the updated one which appears to be correct. I think the problem might be in how I'm updating these values to the database, I could be wrong though //output before Jeremy Gooding72Hugh Duffy73Brian Hamilton81Amy Vetter74Scott Koegler75Randolph P. Johnston78Brent F. Goodfellow, CPA.CITP79John Tripi62Greg LaFollette64Nonprofit Technology News67Kurt Martin6563John Higgins76Kathy Yakal68Steven Ladd69Barry MacQuarrie70Geni Whitehouse82 //output after Geni Whitehouse82Jeremy Gooding72Hugh Duffy73Brian Hamilton81Amy Vetter74Scott Koegler75Randolph P. Johnston78Brent F. Goodfellow, CPA.CITP79John Tripi62Greg LaFollette64Nonprofit Technology News67Kurt Martin6563John Higgins76Kathy Yakal68Steven Ladd69Barry MacQuarrie70 After execution it will instead place Steven in the front though; here's a look at the admittedly sloppy code though. <?php $loop = 1; while ($loop == 1) { global $mainframe; $db =&JFactory::getDBO(); $query = "SELECT * FROM #__AuthorList WHERE stage = '0' ORDER BY position"; $db->setQuery( $query, 0, $count ); $rows = $db->loadObjectList(); $counter = 0; /*grabs all primary authors and stores within array*/ foreach($rows as $row) { $primary[$counter][0] = $row ->AuthorName; /*echo $primary[$counter][0];*/ $primary[$counter][1] = $row ->AuthorID; /*echo $primary[$counter][1];*/ $counter++; } echo "<hr/>"; $query = "SELECT * FROM #__AuthorList WHERE stage = '-1' ORDER BY position"; $db->setQuery( $query, 0, $count ); $rows = $db->loadObjectList(); $counter2 = 0; /*grabs all secondary authors and stores within array*/ foreach($rows as $row) { $secondary[$counter2][0] = $row ->AuthorName; /*echo $secondary[$counter2][0];*/ $secondary[$counter2][1] = $row ->AuthorID; /*echo $secondary[$counter2][1];*/ $counter2++; } echo "<hr/>"; $secondarytemp[0][0] = $secondary[$counter2 - 1][0]; $secondarytemp[0][1] = $secondary[$counter2 - 1][1]; for ($x = 0; $x < $counter2; $x++) { $y = $x + 1; $secondarytemp[$y][0] = $secondary[$x][0]; echo $secondarytemp[$y][0]; $secondarytemp[$y][1] = $secondary[$x][1]; echo $secondarytemp[$y][1]; } echo "<hr/>"; /*now to update the actual database*/ global $mainframe; $db =&JFactory::getDBO(); $query = "SELECT * FROM #__AuthorList"; $db->setQuery( $query, 0, $count ); $rows = $db->loadObjectList(); for ($x = 0; $x < $counter2; $x++) { $OriginalName = $secondary[$x][0]; $OriginalID = $secondary[$x][1]; $NewName = $secondarytemp[$x][0]; $NewID = $secondarytemp[$x][1]; echo $NewName; echo $NewID; mysql_query("UPDATE jos_AuthorList SET AuthorName='temp' WHERE AuthorName='$OriginalName'") or die(mysql_error()); mysql_query("UPDATE jos_AuthorList SET AuthorName='temp2' WHERE AuthorName='$NewName'") or die(mysql_error()); mysql_query("UPDATE jos_AuthorList SET AuthorName='$NewName' WHERE AuthorName='temp'") or die(mysql_error()); mysql_query("UPDATE jos_AuthorList SET AuthorName='$OriginalName' WHERE AuthorName='temp2'") or die(mysql_error()); mysql_query("UPDATE jos_AuthorList SET AuthorID='99999' WHERE AuthorID='$OriginalID'") or die(mysql_error()); mysql_query("UPDATE jos_AuthorList SET AuthorID='98989' WHERE AuthorID='$NewID'") or die(mysql_error()); mysql_query("UPDATE jos_AuthorList SET AuthorID='$NewID' WHERE AuthorID='99999'") or die(mysql_error()); mysql_query("UPDATE jos_AuthorList SET AuthorID='$OriginalID' WHERE AuthorID='98989'") or die(mysql_error()); } $loop++; } ?>
-
[SOLVED] Conditions within MYSQL Query
SchweppesAle replied to SchweppesAle's topic in PHP Coding Help
thanks a lot guys. It was the state column $query = "SELECT * FROM #__content WHERE (catid = '$cat1' AND state != 0)"; -
[SOLVED] Conditions within MYSQL Query
SchweppesAle replied to SchweppesAle's topic in PHP Coding Help
hmmm...that was simple enough. It looks like it worked, but I think I mistook what the publish_down column was intended for(scheduling when to unpublish). Does anyone know how Joomla 1.5 differentiates between published/unpublished articles? -
Hi, just having a little trouble with nested MySQL conditions the following will query all entries within a set category defined by the ID $query = "SELECT * FROM #__content WHERE (catid = '$cat1')"; which is great, however since this is a joomla database I wanted to make the application I'm designing won't pull content which has been unpublished so I tried expanding my condition to the following. $query = "SELECT * FROM #__content WHERE (catid = '$cat1' & publish_down < publish_up)"; Unfortunately, this seems to pull in all published content from every category. What would be the appropriate way of doing this?
-
I'm not trying to use the same value, I'm really just trying to think of a way to cycle the AuthorName and AuthorID of each entry within the table. I used used php to load all entries into an array; cycled them then placed the output into another Array. The only problem I'm having now is how would I go about replacing the column entries within the actual database. Ex: Last column goes to the top; they all move down. Sort of like LIFO except Out just means you're placed back at the top of the list.
-
hi, I'm trying to use the Mysql UPDATE function but I'm having trouble "switching" specific column entries for these two rows. The table has the following columns -> AuthorName, AuthorID, position. Both position and AuthorID serve as indexes. I'd like to leave the position column alone and change the other two however I receive an error since the AuthorID must always be unique and I was trying to switch them with the following statement: mysql_query("UPDATE jos_AuthorList SET AuthorName='$NewName' WHERE AuthorName='$OriginalName'") or die(mysql_error()); mysql_query("UPDATE jos_AuthorList SET AuthorID='$NewID' WHERE AuthorID='$OriginalID'") or die(mysql_error()); Here's the actual code, you'll see that I was actually trying to cycle all entries in the table by using the two arrays tempArray(old entries) and tempArray2(new entries). <?php global $mainframe; $db =&JFactory::getDBO(); $query = "SELECT * FROM #__AuthorList"; $db->setQuery( $query, 0, $count ); $rows = $db->loadObjectList(); $counter = 0; foreach($rows as $row) { $tempArray[$counter][0] = $row ->AuthorName; /*echo $tempArray[$counter][0];*/ $tempArray[$counter][1] = $row ->AuthorID; /*echo $tempArray[$counter][1];*/ $counter++; } echo "<hr/>"; for ($x = 0; $x <= $counter; $x++) { $y = $x + 1; $tempArray2[$y][0] = $tempArray[$x][0]; /*echo $tempArray2[$y][0];*/ $tempArray2[$y][1] = $tempArray[$x][1]; /*echo $tempArray2[$y][1];*/ } $tempArray2[0][0] = $tempArray[$counter - 1][0]; $tempArray2[0][1] = $tempArray[$counter - 1][1]; /*echo "<hr/>";*/ for ($x = 0; $x < $counter; $x++) { $OriginalName = $tempArray[$x][0]; $OriginalID = $tempArray[$x][1]; echo "<b>"; echo $OriginalName; echo $OriginalID; echo "</b>"; echo "<hr/>"; $NewName = $tempArray2[$x][0]; $NewID = $tempArray2[$x][1]; echo $NewName; echo $NewID; echo "<hr/>"; /* mysql_query("UPDATE jos_AuthorList SET AuthorName='temp' WHERE AuthorName='$OriginalName'") or die(mysql_error()); mysql_query("UPDATE jos_AuthorList SET AuthorName='$NewName' WHERE AuthorName='temp'") or die(mysql_error()); mysql_query("UPDATE jos_AuthorList SET AuthorID='99999' WHERE AuthorID='$OriginalID'") or die(mysql_error()); mysql_query("UPDATE jos_AuthorList SET AuthorName='$NewID' WHERE AuthorName='99999'") or die(mysql_error());*/ } ?> thanks in advance, I was also wondering if there's a way to execute this code automatically at a specific time during the day.
-
kind of experimenting with the two methods, for some reason I still can't pull data I need from each entry. global $mainframe; $db =&JFactory::getDBO(); $query = "SELECT * ". "FROM #__AuthorList, #__magazine_users ". "WHERE #__AuthorList.AuthorID = #__magazine_users.userid"; /* $query = "SELECT * FROM #__AuthorList AS a INNER JOIN #__magazine_users AS u ON a.AuthorID = u.userid";*/ $db->setQuery( $query, 0, $count ); $rows = $db->loadObjectList(); foreach($rows as $row) { echo "<table border = 1 width = 500>"; echo "<tr><td>"; echo "work"; echo "<br/>"; $name = $row->name; echo $name; echo "</td></tr></table>"; } output: Document Management System Review (2009-03-16 14:00:50) Welcome to The Progressive Accountant (2009-03-04 04:17:19) Podcast intro sample (2009-03-11 14:12:37) List Authors (2009-03-09 19:46:48) Login (2009-03-09 19:43:13) Help Your Clients Optimize Their Inventory: Phitch 9.0 (2009-03-12 01:00:00) Project Insight: Web 2.0, Web-Based Project Management (2009-03-10 01:00:00) AICPA Establishes 'Economic Crisis' Blog (2009-03-09 02:16:49) Fortune Names Intuit, 'Most Admired,' Again (2009-03-09 02:13:10) All Things QuickBooks (2009-03-09 01:00:00) NASBA Announces Ed 'The Rainmaker' Robinson, CPA, to Keynote National CPE Expo (2009-03-09 02:09:04) Contributing Authors: (in tables) work work work work work work work work work update: tried the following method as well; still no good. $row = mysql_fetch_array($query); while($row = mysql_fetch_array($query)){ echo ($row['name']); }
-
hi, I'm trying to select all columns *. However I'm also trying to cycle through each entry after we combine the two tables (for rows where AuthorID is the same as userid). After which I'd like to cycle through each of these rows and output the name for entry. Only problem is the following statement won't output the names as it loops. foreach($rows as $row) { echo "<table border = 1 width = 500>"; echo "<tr><td>"; echo "work"; $name = $row->name; echo $name; echo "</td></tr></table>"; }
-
thanks, one question though; how would I go about pulling the name column from Authorlist whenever the ON(conditional?) holds true. Here's what I'm using so far: global $mainframe; $db =&JFactory::getDBO();/* $query = "SELECT * ". "FROM #__AuthorList, #__magazine_users". "WHERE #__AuthorList.AuthorID = #__magazine_users.userid";*/ $query = "SELECT * FROM #__AuthorList AS a INNER JOIN #__magazine_users AS u ON a.AuthorID = u.userid"; $db->setQuery( $query, 0, $count ); $rows = $db->loadObjectList(); foreach($rows as $row) { echo "<table border = 1 width = 500>"; echo "<tr><td>"; echo "work"; echo "<br/>"; $name = $row->name; echo $name; echo "</td></tr></table>"; } it will output the work statement, I don't think I'm pulling each column entry out correctly though.