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?
?>

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.