Jump to content

jimfog

Members
  • Posts

    1,803
  • Joined

  • Last visited

Everything posted by jimfog

  1. jimfog

    passwords as...

    One final thought.I wonder if it is better to use the username as the primary key(instead of AUTO INCREMENT INT)-this because, looking the tables in the database, it will be easier to associate a particular action with a user(by looking at the username-as a foreign key) instead of using INT. If for example a user has made a purchase and an INT is associated with that user in the "purchases" table, than in order to learn who that is i have to look in the "users" table. In the other case(username as primary key) it might be not necessary the above. Maybe the DB can be maintained easier that way.
  2. jimfog

    code explanation

    I think it was dsonesuk sometime ago(I am almost sure he was him).
  3. jimfog

    code explanation

    The code that follows outputs the date as css class in a td element: id=dateid_'.$year.str_pad(date('m', $month),2,'0', STR_PAD_LEFT).str_pad($datecount, 2, '0', STR_PAD_LEFT). This a segment, enough though to draw a conclusion-I believe, hopefully. And here is what is output in the browser: <td class="weekdaysid=dateid_20120601">1</td> The PHP code above outputs the ...id=dateid_20120601 and it is here that my q comes and is related with the str_pad function According to the PHP manual if the pad length is equal to the input string then no padding takes place.So, in the code we have a pad length of 2 and the input string is always 2 characters since date('m') outputs the month as 2 digits. So is there a reason for having a pad length of 2 here?
  4. jimfog

    2 tables or not?

    You are saying that if I do not intend having both basketball players and football players in the same page, then I should opt for 2 table. Yes in order to distinguish them though I might as well have a query using a WHERE clause-and so sticking with the one table scheme. As I see it the only reason I should use 2 tables is the reason that niche mentions-smaller tables lead to fewer bottlenecks. Do you agree with that? That seems sound reasoning to me.
  5. jimfog

    2 tables or not?

    Suppose I am making a site where there is database of basketball and football players. Would you make 1 table for both basketball/football players or 2 tables for each? Explain your choice. Supposedly we made 1 table that holds the details of both basketball and football players. Is there a way I could distinguish the type of players in the table. That for example player X is a basketball player and Y a football player. Of course such a distinction would not be necessary if we made 2 tables-it would be needed only in the case where we have 1 table.
  6. jimfog

    passwords as...

    What about MyISAM. Are primary keys indexed automatically in the MyISAM storage engine?
  7. Yes now it works,thanks.
  8. I have a form and I want to put it in the center of the page. Usually when I want to center an element I use margin:0px auto; Now, with the form though, it does not work. I am going to depict the code and to inform also that the form is enclosed in another wrap div tag which serves as the main wrapper of the page. Here it is: #wrap{ width:100%; margin-left:auto; margin-right:auto; position: relative; font-size: 0.875em; overflow:hidden;}#form {margin:0px auto;} The HTML: <div id="wrap"> <form id="form" action="" method="post"> Username/e-mail:<input name="Username" type="text" size="35" /><br />Password:<input name="password" type="password" size="35" /><br /><input name="submit" type="button" value="submit" /> </form> </div>
  9. jimfog

    passwords as...

    Since we mentioned also the concept of INDEX I want to make the following question. When we make a column primary key, does that mean that it will be indexed also-by default?Can we choose to have a primary key and NOT be indexed?
  10. jimfog

    passwords as...

    Exactly right-things must be done manually.
  11. jimfog

    passwords as...

    so, concluding it seems that auto-number int is the proper "candidate " for primary key.
  12. jimfog

    passwords as...

    Ok I got your point, I am not surprised to hear all these. Then we come down to the question what should I use as a primary key, the e-mail(for example,as you mention) OR create a separate column of the INT type ans set it to AUTO INCREMENT
  13. jimfog

    passwords as...

    Since every table must have a primary key column and since each value in it must be unique, can passwords be used a primary keys? What problems may arise by adopting passwords as primary keys-if any?
  14. jimfog

    newbie question

    I want to built a table in the db where the user details will be stored, my question has to do with the username column. What type it should be? What I have come to understand it is that it should be of the varchar type. Am I correct? If yes, I would appreciate if someone could explain to me why it should be varchar and not char for example
  15. jimfog

    array notation used

    I think I got it, the info provided at the php site is very good. It seems, that whenever multiple files are uploaded, a series of arrays are initialized. The part that confused me was that the above procedure is done automatically-except of course naming the file inputs using array notation.
  16. jimfog

    array notation used

    Just to be certain when you are saying "meta data array", do you mean an array within an array-i.e multidimensional array?
  17. jimfog

    array notation used

    Have to study it carefully,it is not sth I can look up in just 5 min.
  18. jimfog

    array notation used

    Well, here is the part that I have difficulty understanding-in the line:$_FILES['fileupload']['name'][$index] Does the above denote 3 arrays? And if yes how did we end up in having 3 arrays?
  19. jimfog

    array notation used

    Recently I came across with a php script where the user is given the option of uploading files to the server.The code went like this: <input type="file" name='fileupload[0]'... What is the reason for the name attribute having an array notation as seen above-why someone would want to do it like this.
  20. jimfog

    td element borders

    It seems I found the solution to the problem-it is css related: td{ border-style: none;}
  21. jimfog

    td element borders

    As the title says I have a code where I loop through the days of the week but the td element borders that contain the days are not echoedin the browser: echo '<table width="100" border="1"> <tr class="weekdays">'; for($startwweek;$startwweek<=$endwweek;$startwweek->modify('+1 day')->format('d')){echo '<td>'.$startwweek->format('d ').'</td>';} echo '</tr> </table>'; Here is the image to understand what I am talking about:https://skydrive.live.com/redir?resid=BE27434B2AAC8130!235 The funny thing is that when i run the code in Dweaver it works,in Netbeans it does not, the only assumption I can make is that in Netbeans-as it is there where I make my app and there is much more code there(the rest)-something "jams" with the borders of thetd elements. What could be possible wrong? I wonder if sth in the css file is causing that, some rule maybe.
  22. jimfog

    OOP code sample

    Yes I got your drift.Do you think I should now use clone in the code you gave me?It works as you said. But I am just wondering if there is any reason at all to use clone-or just leave it the way it is?
  23. jimfog

    OOP code sample

    Ok, this is the code(which I think you gave me) which is related with the calendar app(made in another post): $now = new DateTime($newdate);$today=$now;//get start and end date of specific date value $newdate$startDate = $today->modify("tomorrow")->modify("last Monday")->format('Y m d');$endDate = $today->modify("yesterday")->modify("next Sunday")->format('Y m d'); Why don't you use clone here? Why?The assumption Ι make is that it is not needed probably.
  24. jimfog

    OOP code sample

    Here is some code: $now = new DateTime; echo 'startdate='.$startDate = $now->modify("tomorrow")->modify("last Monday")->format('Y n d').'<br>'; echo 'enddate='.$endDate = $now->modify("yesterday")->modify("+7 days")->format('Y n d').'<br>'; and here is the output: startdate=2012 5 21enddate=2012 5 27 So far nothing strange. Now the strange part-if I erase startDate and just keep the code that corresponds to the endDate-the output I get is this: enddate=2012 5 29.Why the above? Are startDate and endDate "tied somehow" together? I have not fully understand yet OOP concepts.
  25. So, to access static methods/properties we use double colons, instead of arrows. Is that correct? Is this the case were we use double colons?
×
×
  • Create New...