Jump to content

Simple Question I Think


rwachowiak

Recommended Posts

Thanks for the input...

 

 

what im really looking for is this:

 

I have a query that pulls a number from a database...

 

the number will change based on the WHERE clause...

 

and with each different number, i need an output that adds a form input, 1 for each number...

 

so if the variable = 5, there needs to be 5 inputs in the form, if the variable is 3, then 3 inputs in the form... and so on.

 

so would i have something like:

 

<form>
<?php
$var = $Training_Slots;
foreach(range(1,$var) as $num) {
    echo "<input id=\"Slot$num\"><br />";
}

my code is way off, but you get the idea?
?>

Link to comment
Share on other sites

yup got it! thanks guys!

 

<form id="myForm" method="post">
<?
$username="??";
$password="??";
$database="??";

$id = $_GET['id'];

mysql_connect('hostname',$username,$password);
@mysql_select_db($database) or die( "Unable to select database");
$query="SELECT * FROM Players WHERE Mugshot='$id'";

$result=mysql_query($query);

$var = $Training_Slots;
foreach(range(1,$var) as $num) {
    echo "Training Slot $num: <select name=\"Slot$num\" id=\"Slot$num\">
    <option value=\"\">Choose Training</option>
    <option value=\"5\">5 SKT</option>
    <option value=\"7\">7 SKT</option>
    <option value=\"9\">9 SKT</option>       
  </select><br>
";
}

?>
<input type="Submit">
</form>

 

edit: removed hostname from mysql_connect

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.