Jump to content

Maknib

Members
  • Posts

    43
  • Joined

  • Last visited

    Never

Posts posted by Maknib

  1. Hi guys,

     

    i am taking the Javascript course from Learnable.com (sitepoint). we have come up to Objects in Javascript.. he has stated something like:

     

    var MyObject = 
    {
       init:  function(){
          //do stuff
        },
        something:  function(){
          //do something else
        }
    };
    
    MyObject.init();
    

     

    he has said that i need to put myObject.init(); on the bottom as the object hasn't been created yet if i try to call it from the top..

     

    i'm gathering that this is similar to..

     

    public class MyObject{
    
       public void init(){
          //do stuff
       }
    
    
       public void something(){
         //do something else
       }
    
    }
    

    i'm wondering, because i'm starting to get used to working with classes and a Main class... can i have all my objects declared in another JS file, and use an include or an import in another "main" js file? purely for neatness? as i would like to have all funtions / objects in one file and the workings of the script in another.

     

     

    is this possible in Javascript?

     

    hope this makes sense

     

    thanks

  2. hi guys hoping you can help..

     

    i have a container with 2 divs inside of it. ithe right div inside stretches 100% but the left div will not.

     

    a screenshot can be seen here: http://imageshack.us/f/88/sitegr.png/

     

    I have tried all i can think of with min heights and 100% heights but i can't get that left have nav to stretch all the way... Any help please!??

     

     

    i have added red and blue to show the divs..

    Blue: #main-gallery

    red: #gallery-images

    dark-grey: #pages

     

    The CSS

    #main-gallery{
       background: blue;
       height: 100%;  
       padding-bottom: 50px;
       border-top: 1px solid #222222;
    }
    
    #pages{
        float: left;
       width: 120px;
       border-right: 1px solid #222222;
       text-align: left;
       padding-left: 10px;
       padding-top: 10px;
       font-family: arial;
       color: #fff;
       font-size: 14px;
       background: #2D2D2D;
    }
    
    #gallery-images{
       background: red;
       float: right;
       width: 700px;
       padding-top: 10px;
       margin-left: 10px;
    }
    

     

    HTML

    		<div id="main-gallery">
                <div id='pages'>
                   <ul>
                	  <?php
                	  while ($row = mysql_fetch_array($result)){ ?>
                	  <li><a href="gallery.php?view=<?php echo $row['page']; ?>">+ <?php echo $row['page']; ?></a></li>	
                	  <?php	
                	  } ?>
                   </ul>
                </div>
                <div id="gallery-images">
                	<div id="image-list">
                      <?php	
                      while ($row = mysql_fetch_array($images)){ ?>
                   	<a href="images/pictures/<?php echo $row['image_name']; ?>" rel="lightbox" Title="
                         Title: <?php echo $row['title']; ?> <br /> 
                         width: <?php echo $row['width']; ?><br/> 
                      	height: <?php echo $row['height']; ?>" alt="">
                      	<img src = "images/pictures/<?php echo $row['image_name']; ?>" />
                      </a>
                      <?php } ?>  
                   </div>
                </div>
                <div class='clear'></div>
             </div><!-- end main -->
    

  3. you cant include php code in a css file. You could use the php in a html document and create inline styling:

     

    <style type="text/css">
    body
    {
    background-color: <?php echo $color; ?>;
    }
    </style>
    

     

    thanks, i was thinking of that but i thought inline was frowned upon a bit.

  4. is itpossible to have php in an external css file?

     

    so my user could change the background color?

     

    something like..

     

    body{
      background: <?php $color; ?>
    }

     

     

    if it is would the .css file need to be a .css or .php

     

    cheers

     

  5. in my assignmetn we are using php to make a simple shopping cart, we are not allowed to use a database for this but instead storing into files.

     

    the part i have come up to is:

     

    Shopping Cart Page: A logged in user should be able to

    create their shopping cart-

     

    o  Be able to SEARCH any product and add it to their shopping cart. 

    o  They should be able to buy more than one product. 

    o  They should be able to buy products from different categories.

    o  They should be able to remove products from shopping cart, before

    proceeding ahead with the payment options page

     

     

    Would this all be done with Sessions? and once submitted then all the session variables are saved to file?

     

    i can't get my head around this one

     

    thanks

  6. It sure is, if you've inserted it into a MySQL db already. Did you go ahead and do that?

     

    SELECT member, COUNT(member) AS num FROM table GROUP BY(member) ORDER BY member ASC

     

    i haven't done that yet i need to get someone with admin rights to install WAMP for me.

     

    Ok im getting WAMP..

     

    so this sql query will count each member and then tell me how many occurences of that member number there are?

     

    so if the data is

     

    123

    123

    123

    123

    154

    154

    154

     

    it will return something like... 123 = 4, 154 = 3 ?  or just

     

    4

    3

    ??

  7. It sure is, if you've inserted it into a MySQL db already. Did you go ahead and do that?

     

    SELECT member, COUNT(member) AS num FROM table GROUP BY(member) ORDER BY member ASC

     

    i haven't done that yet i need to get someone with admin rights to install WAMP for me.

  8. ok i just used a Unique filter in excel and got myself from 8037 rows to 3800

     

    now it looks like this, so all i need to do is be able to count how many times each member number appears... is that easy and doable?

     

     

    000088 2007

    000088 2008

    000088 2009

    000115 2009

    000115 2010

    000350 2011

    000482 2004

    000482 2005

    000482 2006

    000482 2007

    000495 2010

    000821 2010

    001789 2009

    001911 2006

    001911 2009

    001911 2011

     

  9. Wow, thats gotta be rough.

     

    I would look into, I don't know how about performing specific excel tasks, but I am pretty sure you can just grab the data with PHP, do the math in php, and put back the data in a excel format.

     

    http://phpexcel.codeplex.com/

     

    Thanks i was hoping for something like saving it as a .csv importing into a database and them some sort of query and loop .

     

    can't figure the formula.. something so it would make an array maybe with Array['memberNumber] => year

     

    and then looping through and counting like.. there's 4 occurances of member 12345 and only 2 unique years so the answer is 2.

     

    but i'm probably dreaming and will have to manually count. :(

  10. Hi guys,

     

    wondering if you can help me. i've been given a task at work in Excel and it is going to take me a long time in excel so i'm wondering if there's a PHP script i can create for this...

     

    basically the data i have looks like below

     

    on the left is the member numbers and on the right is the year they claimed...

    i need to find how many years each member has claimed.. so if member 12345 has years 2005 2007 2008 they have claimed 3 years. but if they have 2005 2005 2005 2007 2007 2008 2008 they still have 3 years..

     

    can this be done simple some how? there is about 8000+ cells i need to go through manually counting.

     

     

     

    014134 2009

    014134 2009

    014134 2009

    014330 2010

    014572 2006

    014573 2008

    014604 2010

    014604 2010

    014667 2004

    014667 2005

    014667 2006

    014667 2006

    014667 2006

    014667 2006

    014667 2007

    014667 2007

     

  11. Erm.. Okay but what's the point of grouping objects when you can simply not ? It's getting so complicated I don't get the point of classes O.o

     

    Classes are blueprints.

     

    say an architect makes a blueprint for a house and wants to create 50 of them houses.. he is not going to 50 separate blueprints for the same house.

     

    say you're making a game, you make a player that can jump swim walk run and attack. 2 months later you make another game with a player that does the exact same thing. are you going to want to rewrite the code or simple use a class that already exists.

     

    so your player class has methods call jump swim walk attack...etc.

     

    all you would need to do is something like (this is not php code..)

     

    New player = New PlayerClass();

     

    now to get him to jump you would do..

     

    player.jump();

     

    or..

     

    if(player touches water){

      player.swim();

    }

     

    and so on

     

    not sure with PHP but something like Actionscript or Java if you want to round 23.34 down you would type Math.floor(23.34);

    Math is a abstract class and floor is the method of the class... if there were no classes you would have to create the code to do this every time you needed it.

     

     

    if you are starting out do not dive straight into classes and oop until you have a strong feel and understanding of the code... im still learning myself so most of this is probably wrong :)

     

  12. so what exactly does $row['username'] do and mean? is there a replacement code I could enter and test?

    thanks

     

    While a row of data exists, put that row in $row as an associative array. If you're expecting just one row, no need to use a loop which im guessing that there wont be more than 1 person with the same username.

     

     

    try changing this

    $numrows= mysql_num_rows($query);
    if ($numrows!=0)
    {
    while($row = mysql_fetch_assoc($query))
    {
    
    $dbusername = $row['username'];
    $dbpassword = $row['password'];
    }

     

     

    to this

     

     

    $numrows= mysql_num_rows($query);
    if ($numrows!=0)
    {
    $row = mysql_fetch_assoc($query);
    print_r($row);
    {
    
    }

     

     

  13. don't quote me here but maybe something like this.

     

    for ($i=0; $i<$number_of_rows; $i++)
    {
        $my_no = mt_rand(1, 100);
        if ($count % 3 == 0) {
           $color = "red";
        }elseif ($count % 2 == 0) {
            $color = "blue";
    }
        echo "<td style='background:" . $color . " ;'>$my_no</td>";
    }

  14. I would say I am not a big fan of it. And say why I don't use it.

    For designing (css html) it creates the ugliest code there is. That's why we don't use wysiwyg editors and instead use tools like firebug to test it.

    As far as coding php. I have no idea how well it is (in suggesting, and debugging). I always use netbeans and we even have a whole sticky for: what editor do you use? Most use something different than dreamweaver. But if they want you to use it, well I can't imagine it will be hard.

     

    Keep in mind in the end it's your brain that creates the code not the computer or some piece of software, how cool expensive it might be. So if you have better experience with other IDE's i would say you rather use that. If they don't take you because you don't like it. Get a bottle of champagne and celebrate that you made a right choice not working for them.

     

    6 pick of beer i think.. and yes i used it once back when it was still macromedia dreamweaver and i got turned off from the <BODY><HEAD><TR><BR> caps tags

     

    but cheers i think i'll tell them that yeah i want to use notepad++ or something

  15. Hi guys,

     

    i have been coding html and css and some php for a i little while now and thought i would try to find a group to work with and get experience, i have a meeting tomorrow.

     

    one question on the phone that was asked was do i know dreamweaver...

     

    i do all my sites in either  notepad++, phpDesigner or other various IDE/Texteditors

     

    having never used dreamweaver would this be Hard for me to transition into?

     

    could i say yes i can use dreamweaver or is there more to it i should learn that i wouldn't know from actually hard coding?

  16. Hi guys,

     

    i hope this is in the right section.

    i have been designing small basic sites for customers and now one would like to sell things online.

     

    using paypal will i need a SSL for this or do i am still a student of PHP and would not like to turn an customer away if i can help it.

     

    does anyone know a good beginner site on how to get started with a simple paypal site.. probably won't need a fully functional shopping cart. just something basicc.

     

    Cheers

×
×
  • 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.