Results 1 to 16 of 16

Thread: [RESOLVED] is this right ?

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    28

    Resolved [RESOLVED] is this right ?

    what im trying todo is make a page were registered menber can see who has registerd, iv tested this code it works prefect but i want it as normal text not in a dropdown menu can anyone show mw how to pur it into normal text like

    user 1
    user2
    user3
    ect

    Code:
    <?php
    $dbhost = "localhost";
    $dbname = "db";
    $dbuser = "user";
    $dbpass = "pass";
    
     mysql_connect($dbhost,$dbuser,$dbpass);
     mysql_select_db($dbname);
    
    
    
    
    $sql="select * from forummembers";
    $result=mysql_query($sql);
    echo "<select name=\"select\">\n";
    while($zeile = mysql_fetch_array($result)){
    ?>
    <option value="<?php echo $zeile['id']; ?>"><?php echo $zeile['member_name'];
    ?></option>
    <?php
    }
    ?>
    </select>
    thanks

  2. #2
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: is this right ?

    This line

    Code:
    <option value="<?php echo $zeile['id']; ?>"><?php echo $zeile['member_name'];
    ?></option>
    Is making the option menu. If you remove the <option> tag and add a <br /> to the end, it will list it as plain text down the page.

    You could also add <tr> and <td> tags to format it in a table.

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    28

    Re: is this right ?

    so like this

    Code:
       
    
      <br /> <?php echo $zeile['id']; ?>><?php echo $zeile&#91;'member_name'];
       
     ?><br />
    ??

  4. #4
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: is this right ?

    Have you tested it?

    That code would

    #1 Have an extra > in it when being display
    and
    #2 Would print a break rule, then the value of 'id' and then the value of 'member_name' (with > in between)and another break rule.

  5. #5

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    28

    Re: is this right ?

    no still the same =[

  6. #6
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: is this right ?

    You will also need to remove the <select> tags from around the while.

    I suggest you look up what a select tag is in HTML.

    http://www.w3schools.com/TAGS/tag_Select.asp

    What you need to do is either print each out with a <br /> at the end, or add them to an HTML table http://www.w3schools.com/html/html_tables.asp

    I would also recommend actually learning what your code is doing rather than just copying and pasting it.

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    28

    Re: is this right ?

    i know what the code dose just i get confused very ez

  8. #8

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    28

    Re: is this right ?

    hmm like this ?

    Code:
    <?php
    $dbhost = "localhost";
    $dbname = "";
    $dbuser = "";
    $dbpass = "";
    
     mysql_connect($dbhost,$dbuser,$dbpass);
     mysql_select_db($dbname);
    
    
    
    $sql="select * from forummembers";
    $result=mysql_query($sql);
    echo "<select name=\"select\">\n";
    while($zeile = mysql_fetch_array($result)){
    ?>
    
    <table border="1">
    <tr>
    <th>id</th>
    <th>name</th>
    </tr>
    <tr>
    <td><?php echo $zeile['id']; ?>
    <td>row 1, cell 2</td>
    </tr>
    <tr>
    <td><?php echo $zeile['member_name']; ?>
    <td>row 2, cell 2</td>
    </tr>
    </table>
    
    <?php
    }
    ?>
    now i habve to edit this bit of the code yes ?
    Code:
    echo "<select name=\"select\">\n";

  9. #9
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: is this right ?

    Anything between theses 2 lines will repeat for the # of records you have.
    Code:
    while($zeile = mysql_fetch_array($result)){
    ?>
    and
    Code:
    <?php
    }
    ?>
    So #1, you still need to remove your select and
    #2 You will be printing out a table over and over again, not to mention you're missing tags after your php output.

    Please attempt running your code, when seeing the output you should be able to troubleshoot what you're doing easier. I am here to help guide you, not walk you through this step by step.

  10. #10

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    28

    Re: is this right ?

    i have test its in text but the tables are beying repeated after every member that registers but i think i can do this now =]

  11. #11

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    28

    Re: is this right ?

    iv tryed the funchtion print but nothing come up

  12. #12

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    28

    Re: is this right ?

    well i cant do it but thanks for the info

  13. #13
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: is this right ?

    Can't do what? What you're looking to do is a simple task.

  14. #14

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    28

    Re: is this right ?

    with i cant do i only been doing this 2 weeks

  15. #15
    PowerPoster kfcSmitty's Avatar
    Join Date
    May 2005
    Posts
    2,248

    Re: is this right ?

    If you follow the links I've given you, you should be able to figure out what you're doing.

    Here is also a php/mysql tutorial that may give you some hints as well:

    http://www.w3schools.com/php/php_mysql_intro.asp

  16. #16

    Thread Starter
    Junior Member
    Join Date
    Jan 2009
    Posts
    28

    Re: is this right ?

    i did it thank you
    Last edited by sttc2; Mar 11th, 2009 at 12:19 PM.

Posting Permissions

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



Click Here to Expand Forum to Full Width