Populating an Input field.
Populating an Input field.
I believe it was your tutorial where you were sending data across and ending up in a text field.If so do you have the link.
It would be useful for a project I would like to start and complete.
Making a Braket system when they sign up it assigns their name from database to a text field on a differant page.
I am just not sure on the approach.
It would be useful for a project I would like to start and complete.
Making a Braket system when they sign up it assigns their name from database to a text field on a differant page.
I am just not sure on the approach.
One of my Favorites
Re: Jacek
I'd be happy to look for it if you explain what on Earth you mean by thatGenSwat wrote:I believe it was your tutorial where you were sending data across and ending up in a text field.
Re: Jacek
jacek wrote:I'd be happy to look for it if you explain what on Earth you mean by thatGenSwat wrote:I believe it was your tutorial where you were sending data across and ending up in a text field.
Maybe I should of stated You Submit/POST data from a testfield and send it to a textbox? Dun know?
But the answer is below
1.<input type="text" value="<?php echo $variable; ?>" />Thank You EcazS
One of my Favorites
Re: Jacek
Ah, I know what you mean now, I don’t ever remember doing that though.GenSwat wrote:Maybe I should of stated You Submit/POST data from a testfield and send it to a textbox? Dun know?
I guess it doesn't matter if you have the answer.
Also I renamed this topic, can you make sure you give descriptive titles
Re: Populating an Input field.
Sorry, I will try harder to come up with the correct names, yes populating an input field.
I will be using this method and have it send to another page and insert the usersname into each one by userid.
I am hoping this would be the easiest way.
and the usernames would be submitted to database then inserted in the input fields on next page
I will be using this method and have it send to another page and insert the usersname into each one by userid.
I am hoping this would be the easiest way.
and the usernames would be submitted to database then inserted in the input fields on next page
One of my Favorites
Re: Populating an Input field.
well this is what you want to do then .
you can just do like the example
you can just do like the example
<input type="text" name="something" value="<?php echo $_POST['something']; ?>" />
Re: Populating an Input field.
Now I could querry the unique id's of each username into each input field through a mysql db.
$query = "SELECT * FROM id where id=1";. $result = mysql_query($query);. $row = mysql_fetch_assoc($result);. $contents = $row['content'];
One of my Favorites
Re: Populating an Input field.
I'm not really sure what your question is there, but you could do that yes.
Re: Populating an Input field.
OK maybe I if I break down the pages and process.
signup.php // place where users sigun up for the event and names submited to db
dbconn.php//database connect info
bracket.php // inputfields that will be filled with username based off number of signups. This will be the page also that users can come to and find out who the face in the tournament.
I will have to add an admin.php so as the winner advances db can update and move player to next slot "inputfield"
not sure on this,maybe a winner button next to name that would submit the winner and update and advance player to next round.
signup.php // place where users sigun up for the event and names submited to db
dbconn.php//database connect info
bracket.php // inputfields that will be filled with username based off number of signups. This will be the page also that users can come to and find out who the face in the tournament.
I will have to add an admin.php so as the winner advances db can update and move player to next slot "inputfield"
not sure on this,maybe a winner button next to name that would submit the winner and update and advance player to next round.
One of my Favorites
Re: Populating an Input field.
sorry, I am still a noob so hard to talk in terms, ok I am not sure on how to write the exact query, to get the usernames to insert into the Input fields on the other page, so that a user can visit and they can see the results. so as they sign up the page will constantly be updated.(filling of each input field"
Well let me work on the script some more and submit something maybe it will make sense then.
Well let me work on the script some more and submit something maybe it will make sense then.
One of my Favorites
Re: Populating an Input field.
well if you do
$result = mysql_query("SELECT `name` FROM `users`"); while ($row = mysql_fetch_assoc($result)){ echo "<input type=\"text\" name=\"names[]\" value=\"{$row['name']}\" />" }It will output a input box for all of the users in the users table. Is that what you are trying to do ?
Re: Populating an Input field.
yes but the input box would contain the username and there is a pattern for the input boxes as in the image in the above post
and the names have to stay in first column so as they win the advance to the next column
and the names have to stay in first column so as they win the advance to the next column
One of my Favorites
Re: Populating an Input field.
jacek wrote:well if you do
$result = mysql_query("SELECT `name` FROM `users`"); while ($row = mysql_fetch_assoc($result)){ echo "<input type=\"text\" name=\"names[]\" value=\"{$row['name']}\" />" }It will output a input box for all of the users in the users table. Is that what you are trying to do ?
Ok I used this
<?php include('dbconnect.php'); $query = "SELECT `name` FROM `users`"; $result = mysql_query("$query"); while ($row = mysql_fetch_assoc($result)){ echo $row['name'] . "<br />"; } ?>Results were
John Doe
Jane Doe
Mr Bill
how would I just echo one of there names?
One of my Favorites
Re: Populating an Input field.
You would use LIMIT 1 at the end of the query to make sure only one is displayed. If you want to have control over which one to display as well, you would do something like
SELECT `name` FROM `users` WHERE `name` = 'A username' LIMIT 1
Please check out my CodeCanyon items.
Re: Populating an Input field.
That works in limiting the first user in the table, but how do I assign each user in the table a variable, so I can call on them as followed.Tino wrote:You would use LIMIT 1 at the end of the query to make sure only one is displayed. If you want to have control over which one to display as well, you would do something like
SELECT `name` FROM `users` WHERE `name` = 'A username' LIMIT 1
echo player1
echo player 2
up to as many users needed.
and so on...
I played with diffrant scenerios and was able to get the num_rows to assgin
row[1] = the first name
row[2] = last name
but I can figure out just the column of users to be
user[1]= Player 1's name
user[2] = Player2 's name
thanks for the help
One of my Favorites
Re: Populating an Input field.
OK maybe I can make sense, look at this code below
Now that willl echo the players name with id == 11. Now the question is how would I assign each id to a unique variable.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" href="default.css" /> <title>Untitled Document</title> </head> <body> <div id="container"> <?php include( 'dbconnect.php' ); $result= mysql_query("SELECT * FROM `users` ORDER BY ID"); echo "<table border='0'> <tr> <th>UserName</th> </tr>"; while($row = mysql_fetch_array( $result ) ) { echo "</table>"; if($row['id'] == 11){ echo $row['name']; } } ?>
Now that willl echo the players name with id == 11. Now the question is how would I assign each id to a unique variable.
$player1 //would be id1 in database $player2 //would be id2 in database and so on and so onThe reason for this ,I would to be able to echo a differant player/user in a seperate table in a specific format on a webpage
One of my Favorites
Re: Populating an Input field.
You would put them all into an array.
while($row = mysql_fetch_array( $result ) ) { $players[$row['id']] = $row; }
Re: Populating an Input field.
Now using that how would I replace Player name with a each user from databasejacek wrote:You would put them all into an array.
while($row = mysql_fetch_array( $result ) ) { $players[$row['id']] = $row; }
example of Bracket
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html lang='en'> <head> <meta http-equiv='Content-Type' content='text/html; charset=ISO-8859-1'> <title>MY Tournament</title> <!-- link rel='stylesheet' href='style.css' type='text/css' --> <style type="text/css"> <!-- table { border-collapse: collapse; border: none; font: small arial, helvetica, sans-serif; } td { vertical-align: middle; width: 10em; margin: 0; padding: 0; } td p { border-bottom: solid 1px black; margin: 0; padding: 5px 5px 2px 5px; } --> </style> </head> <body> <table summary="Tournament Bracket"> <tr> <td><p>1. Player name</p></td> <td rowspan="2"><p>Player name</p></td> <td rowspan="4"><p>Player name</p></td> <td rowspan="8"><p>Player name</p></td> <td rowspan="16"><p>Player name</p></td> </tr> <tr> <td><p>16. Player name</p></td> </tr> <tr> <td><p>8. Player name</p></td> <td rowspan="2"><p>Player name</p></td> </tr> <tr> <td><p>9. Player name</p></td> </tr> <tr> <td><p>5. Player name</p></td> <td rowspan="2"><p>Player name</p></td> <td rowspan="4"><p>Player name</p></td> </tr> <tr> <td><p>12. Player name</p></td> </tr> <tr> <td><p>4. Player name</p></td> <td rowspan="2"><p>Player name</p></td> </tr> <tr> <td><p>13. Player name</p></td> </tr> <tr> <td><p>6. Player name</p></td> <td rowspan="2"><p>Player name</p></td> <td rowspan="4"><p>Player name</p></td> <td rowspan="8"><p>Player name</p></td> </tr> <tr> <td><p>11. Player name</p></td> </tr> <tr> <td><p>3. Player name</p></td> <td rowspan="2"><p>Player name</p></td> </tr> <tr> <td><p>14. Player name</p></td> </tr> <tr> <td><p>7. Player name</p></td> <td rowspan="2"><p>Player name</p></td> <td rowspan="4"><p>Player name</p></td> </tr> <tr> <td><p>10. Player name</p></td> </tr> <tr> <td><p>2. Player name</p></td> <td rowspan="2"><p>Player name</p></td> </tr> <tr> <td><p>15. Player name</p></td> </tr> </table> </body> </html>
One of my Favorites
Re: Populating an Input field.
I got it I kept checking php sites and php.org and figured
Just curious is there a way to make the [2] be random number 1-20, so the Tournament Bracket would have differnat names ,in differant orders ,every time we had a tournament?
$players[1][1];would echo player name 1 and [2][1] player 2 and so on Thank you all so much.
Just curious is there a way to make the [2] be random number 1-20, so the Tournament Bracket would have differnat names ,in differant orders ,every time we had a tournament?
One of my Favorites