Jump to content

Two questions. One about submit buttons, and one about drop-down boxes


Frezzwar

Recommended Posts

Okay. I think this will be the last time I am asking for help with this project. But i may be wrong.

First. How do i make a drop-down box? Normally i try google. Then i try php.net. This time i found nothing. What to do?

The plan is that the "items" in the dropbox are the persons in my database. This player needs to be stored, and sent to another page.

 

Problem number 2.

When a player is registered, an admin needs to accept that player. My plan is to make a while function make a table to each person who needs to be accepted. He can then click a submit button and a value is changed in the database. Problem is, I can't make it save a variable of who needs to be edited, so no changes are made. Any suggestions? (I connect to the database in navbar.php)

<?php
include("navbar.php");
if ($admin<2) //altså er man en normal bruger
{
die ("Du har ikke rettigheder til at se denne side!");
}
else

if(isset($_POST[$row['username']]))
{
$username=$row['username'];

$queryacc = "UPDATE users SET rank='1' WHERE username='$username'";

}



$connect = mysql_connect("localhost","root","");
mysql_select_db("eksamen - phoenix");
$query = mysql_query("SELECT * FROM users WHERE rank='0'");

       
while($row = mysql_fetch_assoc($query))
{
	echo "<form action='admin.php' method='POST'>
		<table>											
			<tr>				
				<td>
				".$row['username']."
				</td>
				<td>
				".$row['email']."
				</td>
				<td>
				".$row['real_name']."
				</td>										
				<td>
				<input type=\"submit\" name=".$row['username']." value=\"Register\">
				</td>
		</table>
	</form>	";	
}
?>

Link to comment
Share on other sites

Look, don't want to be harsh or something, but just tell you the way it works. Everyone who's serious about learning web development, before ever touching a programming language, should learn HTML and CSS first. HTML, at least, is priority. Developing PHP applications without knowing what markup to print, is like cooking food without ingredients (stupid example, but gives the idea). So, first learn HTML and the important and not so important tags and attributes, which should take no more than 2-3 days of your time. After that, you'll be ready to go for your PHP career.

 

To answer your questions. Dropdowns in HTML are created with the select and option tags:

<select name="something">
     <option value="abc">ABC</option>
     <option value="def">DEF</option>
</select>

 

For the second question, I basically gave you the answer in this thread. Using checkboxes in each user row is the most simple way of administering data, as the admin can change a bunch of users with a few clicks. In contrast, buttons for every user will be a hell of a work if there are 200 users to change. Just keep in mind the fact that checkboxes (and also other input tags) can be treated as arrays and you're good to go. Also, in the case of checkboxes you don't need to print a form tag for every user; it just needs one form (you'll have to put it before the while).

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.