Jump to content
Larry Ullman's Book Forums

bahaa

Members
  • Posts

    147
  • Joined

  • Last visited

Posts posted by bahaa

  1. I think the SELECT statement is based on SQL, not the MySQL extension, but anyway, here are some examples:

     

    SELECT * FROM users WHERE id=3;
    
    SELECT car_model, car_color FROM cars WHERE type='Porsche';
    
    SELECT field-names-separated-by-commas FROM table-name WHERE field-name=value ORDER BY field-name ASC/DESC LIMIT x, y;

     

    Also, you can add JOIN statements into the mix, etc., but for basic SELECT statements, the above should suffice.

    I think I read in the book that we can write select statement mysqli extension so we don't use the mysqli_real_escape_string to escape values.

    Not sure if I am write :)

  2. Semantically I suppose it really should use <fieldset> rather than <div> tags as (depending on your HTML declaration) won't validate. A fieldset works the same as a div except it's designed to group elements within a form.

     

    Also if I were you I'd just customise the Wordpress admin pages rather than trying to re-create them.

    Thanks for the advice.

     

    I did not customize the admin pages because I am doing this for learning purposes. I like to create things from scratch so I know how things work.

    I am going to school in next Sep majoring in Computer programming analyst, so learning such things would make it easier for me in my study.

  3. To be honest, I think you need to take a step back and rethink your form to begin with. I don't see any reason why you'd want to separate one form into two distinct-looking divs. I think it would only serve to confuse the user.

     

    With that said, if you really wanted to do want you want to do, you'd create one form, and then put separate divs within that form. For example:

     

    <form>
    
     <div>
    
       // Input items here.
    
     </div>
    
     <div>
    
       // Check boxes here.
    
     </div>
    
    </form>

     

    That is syntactically correct and would work in HTML, but semantically speaking, it's a mess, and I would not encourage it.

     

    Anyway, that's hopefully the answer you're looking for, but again, if you feel the need to do this, I'd rethink your design first and foremost.

    Thank you.

    I will try it.

    I am just trying to make a CMS that look and work exactly as the word press CMS.

    if you have an account with them, check the admin area and see what I am trying to achive.

  4. category (id, name)

    1 / Category 1

    2 / Sub 2

    3 / Category 3

     

    three (id, parent*)

    1 / 0

    2 / 1

    3 / 0

     

    Result:

    Category 1

    ---> Sub 2

    Category 3

    -------------------

    Underlined: Primary key

    Asterix: Foreign key

    I did not quite understand this.

    How about this

    First table

    Category

    Cat_id Parent_id Item

     

    Subcategory

    ID Sub_id Item

     

    the sub_id in subcategory is the parent id in category

  5. Hello,

    I will be developing news web site to practice what I have studied in the book.

    As far as I know I have to consider the following features in the CMS:

    1- Adding categories.

    2- Users and every thing associated with that such as: editing, activation and permission.

    3- News: adding, editing, deleting.

    4- comments.

    5 logs.

    6- Site config.

     

    Any other features I should take care of?

  6. I would firstly ask are you sure you want to delete all the info. Would you prefer to make the user inactive, therefore keeping their details incase they come back? I'm not saying your wrong at all, just confirming your sure you want to delete all the user and comment details

    Would you please tell me how to do it in both cases?

    I am not working on a project. I only create tables and perform tasks on the form learning purposes.

  7. I tries this and it worked.

    is it good enough ?

     

    $q = " select username, password, login_count, wait_login from users where username = '$username' and password = '$password' limit 1 ";

    $r = mysql_query($q, $con);

    confirm_query($r);

    if(mysql_num_rows($r) == 1){

    $row = mysql_fetch_array($r);

    $wait_login = $row['wait_login'];

    if($wait_login > time()){

    echo " you are locked out for 15 minutes";

    }else {

    echo "You are logged in!";

    $q = " UPDATE users set login_count = 0 where username = '$username' ";

    $r = mysql_query($q, $con);

    confirm_query($r);

    }

    } else {

    echo "Incorrect password!";

    $q = " UPDATE users set login_count = login_count +1 where username = '$username' ";

    $r = mysql_query($q, $con);

    confirm_query($r);

    $q = " SELECT login_count, wait_login from users where username = '$username' ";

    $r = mysql_query($q, $con);

    confirm_query($r);

    $row = mysql_fetch_array($r);

    $login_count = $row['login_count'];

    $login_wait =$row['wait_login'];

    if($login_count>5){

    echo " You are locked out for 15 Minute!";}

    elseif($login_wait<=time()){

    $q = " UPDATE users set wait_login ='$lockout' where username = '$username' ";

    $r = mysql_query($q, $con);

    confirm_query($r);

    }

    }

     

  8. Add a wrong_logins column to whatever users table. For each wrong login, increase this by 1. Add a wait_logins column of type TIMESTAMP. When wrong_logins gets to 5, update this column to NOW() plus 15 minutes. When the user properly logs in, set wrong_logins to 0 and wait_logins to NULL. Add a check to the login process that wait_logins must be NULL.

     

    That's the basic idea.

    Thanks Larry.

    I will try it and let you know>

  9. Oh, you meant you wanted to jump to an anchor on a page? I see. Well, if that's the case, then you probably need to completely restructure your URL. I thought you were clicking on a subject link, and then loading all the details of that subject onto a separate page.

     

    Actually, bahaa, I'm confused now. If you get it working, then great, but if you have the time, could you please explain exactly what you want. Thanks.

    Yes, I wantt to jump to a named anchor on the page

  10. It sounds to me like bahaa is looking for how to add a named anchor to an URL containing a query string. The named anchor needs to go last. Something like:

    echo '<a href="display_subjects.php?id=' . $row['id'] . '#namedAnchor">' . $row['subject_title'] . '</a>\n';

    Yes, this is what I want.

    I will try it, and let you know.

    Thanks for your helps guys.

  11. Depending on how far you want to take it, doing that might be difficult. If you'll notice, the URL is not composed of the standard script-name.php?name=value&name=value syntax.

     

    I can't recall exactly (hoping for Larry to step in), but I believe he covers how to do this at the beginning of the second example site in his e-commerce book. Basically, you need to use an .htaccess file, etc. to convert the format of the URL.

     

    I think it would be best to start out with the standard format used for the GET method, and once you have that working, then add this additional later on. In the end, the functionality is the same. The only difference is that the URL becomes slightly more "readable" for humans.

    doing it with this "script-name.php?name=value&name=value syntax" fine .

×
×
  • Create New...