SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Want to specify several rows in a while loop

    PHP Code:
     $item;
    while(
    $row mysql_fetch_assoc($result)) {     
    if(
    $row['id']==9,10,15,24,35,46,) {      
      
    $item $row;        
    break;     
    }
    }
    if(
    is_null($item)) {     // no row could be matched

    else {   
    // row matched 
    echo 
    I want to specify several rows of a table but I don't know if the way I have script it above will work ok, to take the information out of the rows above...

    I need some help...

  2. #2
    SitePoint Wizard
    Join Date
    Nov 2005
    Posts
    1,191
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SELECT * FROM table WHERE id IN (9,10,15,24,35,46)

  3. #3
    SitePoint Wizard bronze trophy
    Join Date
    Jul 2006
    Location
    Augusta, Georgia, United States
    Posts
    4,147
    Mentioned
    16 Post(s)
    Tagged
    3 Thread(s)
    This isn't meant to be an insult but you need to read a book or two about PHP. There isn't one question which you have posted that isn't covered within the first hundred or so pages of a good PHP book. It would benefit you and your client to understand the basic constructs and syntax of PHP, MySQL and HTML before putting together a application.

    Someone who has studied the syntax of the language for a few days would know the syntax of the below code is incorrect.

    PHP Code:
    if($row['id']==9,10,15,24,35,46,) {

    Its not meant to be an insult, but it seems like your trying to build a house without knowing how to use the tools. Understanding the how to use the tools should come before building the house. Its the same in regards to web applications. You should have a decent understanding of the languages (tools) before building the application (house).

  4. #4
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sorry, about my poor and maybe upsetting occurrences, Sorry I haven't meant to do that. I thank you guys a lot for your help in special you Oddz, hash and other guys I have been reading but haven't covered or understood how to specify more than one row in a loop to only display the ones I want, the illustration I have seen have always showed how to specify one row in a loop no more than one . But now I can see it can be specify at the query.

    Sorry my purpose here is to build the application with your help and from me reading tutorials and books. Help me out guys and be patient, Right now I don't want to stop at this point, I want to continue and try to finish the whole application with some of your help either referring me to part of book and tutorials or dropping some of your direct help.

    I will appreciate any of your suggestion just like said either directing me to the right part in a book or tutorial according to the question I formulate or scripting some code, any thing will be appriciated, Sometimes I don't even know the term I should read or use to build a part of the application. (house)

    I have read some tutorials, but sometime I don't understand the term itself I just newbie and I guess I still on the learning curve.

  5. #5
    SitePoint Wizard co.ador's Avatar
    Join Date
    Apr 2009
    Posts
    1,054
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    a repeated post sorry...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •