|
-
Mar 11th, 2009, 10:01 AM
#1
Thread Starter
Junior Member
[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
-
Mar 11th, 2009, 10:05 AM
#2
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.
-
Mar 11th, 2009, 10:07 AM
#3
Thread Starter
Junior Member
Re: is this right ?
so like this
Code:
<br /> <?php echo $zeile['id']; ?>><?php echo $zeile['member_name'];
?><br />
??
-
Mar 11th, 2009, 10:10 AM
#4
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.
-
Mar 11th, 2009, 10:14 AM
#5
Thread Starter
Junior Member
-
Mar 11th, 2009, 10:16 AM
#6
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.
-
Mar 11th, 2009, 10:20 AM
#7
Thread Starter
Junior Member
Re: is this right ?
i know what the code dose just i get confused very ez
-
Mar 11th, 2009, 10:25 AM
#8
Thread Starter
Junior Member
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";
-
Mar 11th, 2009, 10:30 AM
#9
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
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.
-
Mar 11th, 2009, 10:33 AM
#10
Thread Starter
Junior Member
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 =]
-
Mar 11th, 2009, 10:37 AM
#11
Thread Starter
Junior Member
Re: is this right ?
iv tryed the funchtion print but nothing come up
-
Mar 11th, 2009, 10:50 AM
#12
Thread Starter
Junior Member
Re: is this right ?
well i cant do it but thanks for the info
-
Mar 11th, 2009, 10:56 AM
#13
Re: is this right ?
Can't do what? What you're looking to do is a simple task.
-
Mar 11th, 2009, 11:09 AM
#14
Thread Starter
Junior Member
Re: is this right ?
with i cant do i only been doing this 2 weeks
-
Mar 11th, 2009, 12:10 PM
#15
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
-
Mar 11th, 2009, 12:14 PM
#16
Thread Starter
Junior Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|