Jump to content

Sesquipedalian

Members
  • Posts

    90
  • Joined

  • Last visited

    Never

Everything posted by Sesquipedalian

  1. I'd say it's just a matter of opinion. There's not even that much of a difference in how you'd retrieve the information if the array changed over time... First Array: <?php foreach($products as $product) { echo "Item : " . $product['item'] . "<br />" ."Price : " . $product['price'] . "<br />" ."Shipping : " . $product['shipping']; } ?> Second Array: <?php foreach($products as $item=>product) { echo "Item : " . $item . "<br />" ."Price : " . $product['price'] . "<br />" ."Shipping : " . $product['shipping']; } ?> Looking above, I think I'd more likely use the first array that you posted, just because the code for the foreach looks better and more uniform to me.
  2. I agree with Cardale. If somehow you can't do that, however, you could use Regex and check if the URL has something like ../something.php.
  3. I would use session variables. When they log in you can assign something like $_SESSION['auth'] = 1; And then you could have special code that checks whether or not $_SESSION['auth'] == 1 and make it display different prices accordingly. I'm not exactly sure on the Flash aspect, however.
  4. Does $ids actually have a value? Maybe make sure that it's actually passing a variable. Also - you might want to tidy up your code a bit. You have an extra > at the end of your code, and you forgot to use a semicolon ; to end the echo.
  5. You were close; I corrected your code: <?php if ( lp_tags('id_number') > 0 ): ?> <link rel="stylesheet" type="text/css" media="screen" href="style1.css" /> <?php else: ?> <link rel="stylesheet" type="text/css" href="style2.css" /> <?php endif; ?> You placed a semicolin instead of a colin after the first if, and you needed a colin after the else also.
  6. You call alert('bla22') in the callback function, so that doesn't get triggered until your file is loaded with $.post. It just keeps going on with the code and then executes the callback function when the file is actually loaded. Why does it matter, though?
  7. Your code was written kind of odd, but this is what I think you're asking for: <?php $i=0; foreach($tp as $val) { $SQLQuery[$i] = $val; $i++; } ?> Am I missing a part of what you're looking for?
  8. Why not use a session variable? http://www.php.net/manual/en/book.session.php
  9. Hello all, I wrote a jQuery / HTML code that seems to work great in Chrome and Firefox, but it doesn't do anything in IE. I use jQuery's animate function to move absolutely positioned ul's and il's. Any idea why it isn't working? jQuery $(document).ready(function() { $("div.links").hover(function() {}, function() { $("li.mainLink").each(function() { $(this).stop().animate({ opacity: 1, }, 100); }); }); $("li.mainLink").hover(function() { $(this).data("hover", "yes"); $(this).css({opacity: 1,}); $("li.mainLink").each(function() { if($(this).data("hover") != "yes") { $(this).animate({ opacity: .4, }, 100); } }); }, function() { $(this).data("hover", "no"); $(this).animate({ opacity: .4, }, 50); }); var leftNum; leftNum = 0; var num; num = -1; $("li.mainLink").each(function() { num++; leftNum = (126*num)+30; $(this).stop().animate({ left: leftNum, },1000); }); }); HTML <div class="bodyWrapper"> <div class="banner"></div> <div class="links"> <ul class="linkWrapper"> <li class="mainLink"><span>Main Link</span></li> <li class="mainLink"><span>Main Link</span></li> <li class="mainLink"><span>Main Link</span></li> <li class="mainLink"><span>Main Link</span></li> <li class="mainLink"><span>Main Link</span></li> <li class="mainLink"><span>Main Link</span></li> <li class="mainLink"><span>Main Link</span></li> </ul> </div> <div class="mainWrapper"> </div> <div class="bottomShadow"></div> <div class="leftShadow"></div> <div class="rightShadow"></div> <div class="bottomLeft"></div> <div class="bottomRight"></div> </div> CSS (if needed) <style type="text/css" > .bodyWrapper { width:947px; text-align:left; margin:0 auto; height:400px; position:relative; } body { text-align:center; background:url("bg.jpg"); font-family:"Helvetica Neue"; } .banner { background:url("banner.jpg"); width:100%; height:113px; position:absolute; top:0; } .leftShadow { background:url("leftShadow.jpg"); height:100%; width:29px; position:absolute; top:0; left:0; } .rightShadow { background:url("rightShadow.jpg"); height:100%; width:29px; position:absolute; top:0; right:0; } .bottomShadow { background:url("bottomShadow.jpg"); height:20px; width:100%; position:absolute; bottom:0; } .bottomLeft { background:url("bottomLeft.jpg"); height:73px; width:84px; position:absolute; bottom:-22; left:-13; } .bottomRight { background:url("bottomRight.jpg"); height:54px; width:59px; position:absolute; bottom:-15; right:-5; } .links { background:url("linksBg.jpg"); height:34px; width:100%; position:absolute; top:113px; } .mainWrapper { height:100%; width:100%; background-color:white; } li.mainLink{ background:url("linkNormal.jpg"); height:30px; width:131px; text-align:center; position:absolute; top:2px; cursor:pointer; } li.mainLink > span { position:relative; top:16%; font-size:13px; color:#76413d; } ul { list-style-type:none; } </style> Thanks for your help, - Sesq
  10. Why does this only work on firefox? Internet explorer seems to have errors with it: function list(what, how) { if (how == 'out') { what = document.getElementById(what); for (a in what.getElementsByClassName('sub')) { if (a >= 0) { what.getElementsByClassName('sub')[a].setAttribute('style', 'display:block;'); } } } else if (how == 'in') { what = document.getElementById(what); for (a in what.getElementsByClassName('sub')) { if (a >= 0) { what.getElementsByClassName('sub')[a].setAttribute('style', 'display:none;'); } } } } Thanks for your help, - Adam
  11. You could also get fancy and use AJAX if for some reason you don't want to have the page reload when you submit your data.
  12. If you dont know something like || or manipulating GET variables you should probably take a look at a beginner PHP tutorial -- it'll make the things you're trying to do much easier.
  13. Can you post all of your code? It'd probably make it easier to be able to understand whats going wrong.
  14. Something similar should also suffice: <? $sql="select image from inputinfo where id='$id'"; $rez=mysql_query($sql,$dblnk); if ($rez) { $row=mysql_fetch_array($rez); echo "<img src='admin/{$row['image']}' />"; } ?>
  15. Hey everyone, If this doesn't go here, let me know... I'm trying to create a package for VB.NET for the JS eval function, and in doing so I'm writing my code in JS (obviously)... What I was wondering is, do you know how to compile a .js file into a .dll file? I know how I could do it on the .NET command prompt, but I have no idea how to get there. I have not been able to find any info on this on the net... Thanks for your help - Adam
  16. Yeah, but whats the point of doing that? <? if (...) { echo '<div><script>...</script></div>'; } else { echo '<div><script>...</script></div>'; } ?>
  17. Why don't you just use sessions in the login? You should be doing that anyways... When they login set a variable $_SESSION['username'] and make it there username, so that when the page loads you automatically know their username. Sessions are more secure overall -- if you have a login it would benefit you to use them.
  18. Something is wrong with your site, I tested out your code and it worked perfectly for me.
  19. Hi, I set up my computer so that I could host my own public internet server that is accessed at an IP address rather than domain name.. if I get traffic will my ISP provider charge me for it? Thanks.
  20. Just set the cookie with javascript with setcookie(); and then check if it exists like this: <? if (isset($_COOKIE['javascript'])) { //JS is enabled } else { //JS is not enabled.. redirect. } ?> I'm gonna assume you know how to set a cookie with JS since you *did* code the website using JS. Otherwise you can just look it up or something.
  21. I understand the fundamentals of JSON, but I was wondering what's the real point of using JSON anyways? I can't find anything on Google that explains the point. Thanks a lot, - Adam
  22. Is there a way to find the factors of a number with PHP? Like if you are given the number 6 it comes back with 1, 2, 3, 6. The only way I can think of is by just checking to see if the number can be divided by numbers 1-100 without a remainder (using modulus), and if there is no remainder, the number is a factor. This seems somewhat tedious though. Is there an easier way?
  23. That actually was at the top of the rest of the code (since this was just an excert). I found out what the problem was by just switching a few things around. Thanks anyways though.
  24. For some reason it won't display what the error is with my code.. This is just an exert of some code, but I know that there is an error somewhere in here that is messing up my other code, I just can't find it. What do you think?: <? $assignments = 'assignments.txt'; $archive = 'archive.txt'; chmod($archive, '0777'); chmod($assignments, '0777'); if ($handle['assignments'] = fopen($assignments, 'r')) { if ($read = fread($handle['assignments'], filesize($assignments))) { if ($handle['archive'] = fopen($archive, 'a')) { $string = $_POST['subject'].'|'.$_POST['assignment'].'|'.$_POST['date']; $read = explode("\n", $read); for ($i=0;$read[$i]!==NULL;$i++) { if ($read[$i] !== $string) { $newread .= $read[$i]; if ($read[$i+1]!==NULL) { $newread .= "\n"; } } else { $archivedstring = $read[$i]; } } fclose($handle['assignments']); if (fwrite(fopen($assignments, 'w'), $newread)) { if (fwrite($handle['archive'], $archivedstring)) { echo '<script>self.close();</script>'; } else { echo 'Cannot write to archive.txt'; } } else { echo 'Cannot write to assignments.txt'; } } else { echo 'Cannot open '.$archive.' for writing.'; } } else { echo 'Cannot read '.$assignments; } } else { echo 'Cannot open '.$assignments.' for reading'; } ?>
  25. Sorry, one more question.. is it possible to connect to MySQL with AJAX only? When I search google all of the results for MySQL with AJAX need PHP implementation. Would using PHP in this case still make there be a need to refresh? Thanks, - Adam
×
×
  • 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.