Jump to content

Recommended Posts

I have a website for a sports team tournament and I want individual players to be able to enter their personal information for college coaches to see.  However I don't want them entering all their friends info to, so I am trying to take the page I currently have for UPDATING the info and making it into a a page for INSERT and UPDATE.

 

The actually SQL to dump the info into the database I can do so unless it is relelvent I am not going to post it.

 

My problem is that, if they have info added in the database I want those values to show up in the fields, which I have set up and working.  However, if they don't have info in the DB then a blank screen shows up and they can't see the form.

 

What do I have to do to the code so if they have info it shows up in the fields but if they don't have info then blank fields show up?

 

Here is the code.

 

<?php
$db_name="****";
$connection=mysql_connect("localhost","****","****") or die("I Couldn't connect");
$db=mysql_select_db($db_name,$connection) or die("I Couldn't select your database");
$table="player"; // Table name
$sql="select user, first, last, birth, address, city, state, zip, email, grade, team, coach, height, weight, gpa, sat, phone, other from $table WHERE user='$user'";
$result=mysql_query($sql,$connection) or die(mysql_error());
while($row=mysql_fetch_array($result)) {
?>
<form method="post" action="../player/insertupdate.php"> 
<input type="hidden" name="user" value="<?php echo $user; ?>">
  <p>First Name
    <input type="text" name="first" maxlength="20" value="<?php echo $row['first']; ?>">
Last Name
    <input type="text" name="last" maxlength="20" value="<?php echo $row['last']; ?>">
  </p>
  <p>Birth Date
    <input type="text" name="birth" maxlength="20" value="<?php echo $row['birth']; ?>">
  
  Address 
    <input type="text" name="address" maxlength="50" value="<?php echo $row['address']; ?>">
  </p>
  <p>
    City
    <input type="text" name="city" maxlength="20" value="<?php echo $row['city']; ?>">
    State 
    <select name="state" value="<?php echo $row['state']; ?>">
      #
<option value="">None</option>
#
<option value="AL">Alabama</option>
#
<option value="AK">Alaska</option>
#
<option value="AZ">Arizona</option>
#
<option value="AR">Arkansas</option>
#
<option value="CA">California</option>
#
<option value="CO">Colorado</option>
#
<option value="CT">Connecticut</option>
#
<option value="DC">District of Columbia</option>
#
<option value="DE">Delaware</option>
#
<option value="FL">Florida</option>
#
<option value="GA">Georgia</option>
#
<option value="HI">Hawaii</option>
#
<option value="ID">Idaho</option>
#
<option value="IL">Illinois</option>
#
<option value="IN">Indiana</option>
#
<option value="IA">Iowa</option>
#
<option value="KS">Kansas</option>
#
<option value="KY">Kentucky</option>
#
<option value="LA">Louisiana</option>
#
<option value="ME">Maine</option>
#
<option value="MD">Maryland</option>
#
<option value="MA">Massachusetts</option>
#
<option value="MI">Michigan</option>
#
<option value="MN">Minnesota</option>
#
<option value="MS">Mississippi</option>
#
<option value="MO">Missouri</option>
#
<option value="MT">Montana</option>
#
<option value="NE">Nebraska</option>
#
<option value="NV">Nevada</option>
#
<option value="NH">New Hampshire</option>
#
<option value="NJ">New Jersey</option>
#
<option value="NM">New Mexico</option>
#
<option value="NY">New York</option>
#
<option value="NC">North Carolina</option>
#
<option value="ND">North Dakota</option>
#
<option value="OH">Ohio</option>
#
<option value="OK">Oklahoma</option>
#
<option value="OR">Oregon</option>
#
<option value="PA">Pennsylvania</option>
#
<option value="PR">Puerto Rico</option>
#
<option value="RI">Rhode Island</option>
#
<option value="SC">South Carolina</option>
#
<option value="SD">South Dakota</option>
#
<option value="TN">Tennessee</option>
#
<option value="TX">Texas</option>
#
<option value="UT">Utah</option>
#
<option value="VT">Vermont</option>
#
<option value="VA">Virginia</option>
#
<option value="WA">Washington</option>
#
<option value="WV">West Virginia</option>
#
<option value="WI">Wisconsin</option>
#
<option value="WY">Wyoming</option>
#

    </select> 
    Zipcode 
    <input type="text" name="zip" maxlength="5" value="<?php echo $row['zip']; ?>">
  </p>
  <p>Phone ex.(555) 555-5555 <input type="text" name="phone" maxlength="20" value="<?php echo $row['phone']; ?>">
Email <input type="text" name="email" maxlength="50" value="<?php echo $row['email']; ?>"> </p>
  
  <p>Grade <input type="text" name="grade" maxlength="10" value="<?php echo $row['grade']; ?>">
  School <input type="text" name="team" maxlength="20" value="<?php echo $row['team']; ?>">
  </p>
  <p>Coach <input type="text" name="coach" maxlength="20" value="<?php echo $row['coach']; ?>">
  Height <input type="text" name="height" maxlength="10" value="<?php echo $row['height']; ?>">
  Weight <input type="text" name="weight" maxlength="10" value="<?php echo $row['weight']; ?>">
  </p>
   <p>Grade Point Average (GPA) <input type="text" name="gpa" maxlength="10" value="<?php echo $row['gpa']; ?>">
  SAT Score <input type="text" name="sat" maxlength="5" value="<?php echo $row['sat']; ?>">
  </p>
  <p>
  Notable Academic and Athletic Achievments: (2500 Character Maximum) </p>
  
  
  <textarea name="other" rows="10" cols="50"><?php echo $row['other']; ?> </textarea>
  <p><input type="submit" value="Submit"></p>  <?php } ?>
</form>

 

Im not a good php person just learning and wouldnt know how to code this but couldnt you do somthing like, if $varible is inputed echo $varible else echo, no data inputted. Could be wrong but thats what i think, if i read your problem right

you have to take a field that is manditory ... like their name (if your not entering that) and check to make sure its not null then proceed for my example im assuming they have to enter their own first name:

this would go directly after you start your while loop

 

if($row['first'] != ""){
?>
** Your Form with info in it **
<?
}else{
?>
** Your blank form **
<?
}
?>

Here it is with n3ightjay's suggestion.

 

<?php

$db_name="***";
$connection=mysql_connect("localhost","***","***") or die("I Couldn't connect");
$db=mysql_select_db($db_name,$connection) or die("I Couldn't select your database");
$table="player"; // Table name
$sql="select user, first, last, birth, address, city, state, zip, email, grade, team, coach, height, weight, gpa, sat, phone, other from $table WHERE user='$user'";
$result=mysql_query($sql,$connection) or die(mysql_error());
while($row=mysql_fetch_array($result)) {
if($row['user'] != ""){
?> 
<form method="post" action="../player/insertupdate.php"> 
<input type="hidden" name="user" value="<?php echo $user; ?>">
  <p>First Name
    <input type="text" name="first" maxlength="20" value="<?php echo $row['first']; ?>">
   Last Name
    <input type="text" name="last" maxlength="20" value="<?php echo $row['last']; ?>">
  </p>
  <p>Birth Date
    <input type="text" name="birth" maxlength="20" value="<?php echo $row['birth']; ?>">
  
  Address 
    <input type="text" name="address" maxlength="50" value="<?php echo $row['address']; ?>">
  </p>
  <p>
    City
    <input type="text" name="city" maxlength="20" value="<?php echo $row['city']; ?>">
    State 
    <select name="state" value="<?php echo $row['state']; ?>">
      #
<option value="">None</option>
#
<option value="AL">Alabama</option>
#
<option value="AK">Alaska</option>
#
<option value="AZ">Arizona</option>
#
<option value="AR">Arkansas</option>
#
<option value="CA">California</option>
#
<option value="CO">Colorado</option>
#
<option value="CT">Connecticut</option>
#
<option value="DC">District of Columbia</option>
#
<option value="DE">Delaware</option>
#
<option value="FL">Florida</option>
#
<option value="GA">Georgia</option>
#
<option value="HI">Hawaii</option>
#
<option value="ID">Idaho</option>
#
<option value="IL">Illinois</option>
#
<option value="IN">Indiana</option>
#
<option value="IA">Iowa</option>
#
<option value="KS">Kansas</option>
#
<option value="KY">Kentucky</option>
#
<option value="LA">Louisiana</option>
#
<option value="ME">Maine</option>
#
<option value="MD">Maryland</option>
#
<option value="MA">Massachusetts</option>
#
<option value="MI">Michigan</option>
#
<option value="MN">Minnesota</option>
#
<option value="MS">Mississippi</option>
#
<option value="MO">Missouri</option>
#
<option value="MT">Montana</option>
#
<option value="NE">Nebraska</option>
#
<option value="NV">Nevada</option>
#
<option value="NH">New Hampshire</option>
#
<option value="NJ">New Jersey</option>
#
<option value="NM">New Mexico</option>
#
<option value="NY">New York</option>
#
<option value="NC">North Carolina</option>
#
<option value="ND">North Dakota</option>
#
<option value="OH">Ohio</option>
#
<option value="OK">Oklahoma</option>
#
<option value="OR">Oregon</option>
#
<option value="PA">Pennsylvania</option>
#
<option value="PR">Puerto Rico</option>
#
<option value="RI">Rhode Island</option>
#
<option value="SC">South Carolina</option>
#
<option value="SD">South Dakota</option>
#
<option value="TN">Tennessee</option>
#
<option value="TX">Texas</option>
#
<option value="UT">Utah</option>
#
<option value="VT">Vermont</option>
#
<option value="VA">Virginia</option>
#
<option value="WA">Washington</option>
#
<option value="WV">West Virginia</option>
#
<option value="WI">Wisconsin</option>
#
<option value="WY">Wyoming</option>
#

    </select> 
    Zipcode 
    <input type="text" name="zip" maxlength="5" value="<?php echo $row['zip']; ?>">
  </p>
  <p>Phone ex.(555) 555-5555 <input type="text" name="phone" maxlength="20" value="<?php echo $row['phone']; ?>">
Email <input type="text" name="email" maxlength="50" value="<?php echo $row['email']; ?>"> </p>
  
  <p>Grade <input type="text" name="grade" maxlength="10" value="<?php echo $row['grade']; ?>">
  School <input type="text" name="team" maxlength="20" value="<?php echo $row['team']; ?>">
  </p>
  <p>Coach <input type="text" name="coach" maxlength="20" value="<?php echo $row['coach']; ?>">
  Height <input type="text" name="height" maxlength="10" value="<?php echo $row['height']; ?>">
  Weight <input type="text" name="weight" maxlength="10" value="<?php echo $row['weight']; ?>">
  </p>
   <p>Grade Point Average (GPA) <input type="text" name="gpa" maxlength="10" value="<?php echo $row['gpa']; ?>">
  SAT Score <input type="text" name="sat" maxlength="5" value="<?php echo $row['sat']; ?>">
  </p>
  <p>
  Notable Academic and Athletic Achievments: (2500 Character Maximum) </p>
  
  
  <textarea name="other" rows="10" cols="50"><?php echo $row['other']; ?> </textarea>
  <p><input type="submit" value="Submit"></p>  <?php } ?>
</form>
<?php
}else{
?>
<form method="post" action="../player/insertplayer.php"> 
  <p>First Name
    <input type="text" name="first" maxlength="20">
   Last Name
    <input type="text" name="last" maxlength="20">
  </p>
  <p>Birth Date
    <input type="text" name="birth" maxlength="20">
  
  Address 
    <input type="text" name="address" maxlength="50">
  </p>
  <p>
    City
    <input type="text" name="city" maxlength="20">
    State 
    <select name="state">
      #
<option value="">None</option>
#
<option value="AL">Alabama</option>
#
<option value="AK">Alaska</option>
#
<option value="AZ">Arizona</option>
#
<option value="AR">Arkansas</option>
#
<option value="CA">California</option>
#
<option value="CO">Colorado</option>
#
<option value="CT">Connecticut</option>
#
<option value="DC">District of Columbia</option>
#
<option value="DE">Delaware</option>
#
<option value="FL">Florida</option>
#
<option value="GA">Georgia</option>
#
<option value="HI">Hawaii</option>
#
<option value="ID">Idaho</option>
#
<option value="IL">Illinois</option>
#
<option value="IN">Indiana</option>
#
<option value="IA">Iowa</option>
#
<option value="KS">Kansas</option>
#
<option value="KY">Kentucky</option>
#
<option value="LA">Louisiana</option>
#
<option value="ME">Maine</option>
#
<option value="MD">Maryland</option>
#
<option value="MA">Massachusetts</option>
#
<option value="MI">Michigan</option>
#
<option value="MN">Minnesota</option>
#
<option value="MS">Mississippi</option>
#
<option value="MO">Missouri</option>
#
<option value="MT">Montana</option>
#
<option value="NE">Nebraska</option>
#
<option value="NV">Nevada</option>
#
<option value="NH">New Hampshire</option>
#
<option value="NJ">New Jersey</option>
#
<option value="NM">New Mexico</option>
#
<option value="NY">New York</option>
#
<option value="NC">North Carolina</option>
#
<option value="ND">North Dakota</option>
#
<option value="OH">Ohio</option>
#
<option value="OK">Oklahoma</option>
#
<option value="OR">Oregon</option>
#
<option value="PA">Pennsylvania</option>
#
<option value="PR">Puerto Rico</option>
#
<option value="RI">Rhode Island</option>
#
<option value="SC">South Carolina</option>
#
<option value="SD">South Dakota</option>
#
<option value="TN">Tennessee</option>
#
<option value="TX">Texas</option>
#
<option value="UT">Utah</option>
#
<option value="VT">Vermont</option>
#
<option value="VA">Virginia</option>
#
<option value="WA">Washington</option>
#
<option value="WV">West Virginia</option>
#
<option value="WI">Wisconsin</option>
#
<option value="WY">Wyoming</option>
#

    </select> 
    Zipcode 
    <input type="text" name="zip" maxlength="5" >
  </p>
  <p>Phone ex.(555) 555-5555 <input type="text" name="phone" maxlength="20">
Email <input type="text" name="email" maxlength="50"> </p>
  
  <p>Grade <input type="text" name="grade" maxlength="10">
  
   <?php

$host="localhost"; // Host name 
$username="***"; // Mysql username 
$password="***"; // Mysql password 
$db_name="***"; // Database name 
$tbl_name="teams"; // Table name 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// Retrieve data from database 
$sql="SELECT team FROM $tbl_name ORDER BY team";
$result=mysql_query($sql);
?>

  School <select name = "team">
<?php
// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
?>
  <option value = <?php echo $rows['team']; ?>><?php echo $rows['team']; ?></option> <?php
// close while loop 
}

// close connection 
mysql_close();
?>         
                               </select>
  </p>
  <p>Coach <input type="text" name="coach" maxlength="20">
  Height <input type="text" name="height" maxlength="10">
  Weight <input type="text" name="weight" maxlength="10">
  </p>
   <p>Grade Point Average (GPA) <input type="text" name="gpa" maxlength="10">
  SAT Score <input type="text" name="sat" maxlength="5">
  </p>
  <p>
  Notable Academic and Athletic Achievments: (2500 Character Maximum) </p>
  
  
  <textarea name="other" rows="10" cols="50"> </textarea>
  <p><input type="submit" value="Submit"></p>
</form>
<?php
}
?>

  Notable Academic and Athletic Achievments: (2500 Character Maximum) </p>


  <textarea name="other" rows="10" cols="50"><?php echo $row['other']; ?> </textarea>
  <p><input type="submit" value="Submit"></p>  <?php } ?>
</form>
<?php
}else{
?>

 

Right after that </p>.  See it?

That just gives me the blank screen I talked about in the OP.  I have a seperate "while" statement that runs in the "else" statement so that gets funky.

 

I tested the code below with the username already in the DB.  It showed both sets of forms.  So i am confused.

 Notable Academic and Athletic Achievments: (2500 Character Maximum) </p>
  
  
  <textarea name="other" rows="10" cols="50"><?php echo $row['other']; ?> </textarea>
  <p><input type="submit" value="Submit"></p> 
</form>
<?php
}else{
}
?>

 

if a variable is set to null, that is not the same thing (to my knowledge of php, and most OO languages) as null.  "" represents an empty string, not null.  When you query the DB for data, if there is no data, usually it'll return NULL, not the empty string.  So if($row['other']) != "") will evaluate to true if nothing is returned, since NULL is returned.  Use if(!isset($row['other'])) in your if statement to see if a value was returned or not.  This will evaluate to true if $row['other'] is in fact not set, or NULL.

Kenshintomoe225, I feel this could help.  I used the following code, but when there is no entry in the DB the page showed up blank.  When it was in the in the DB it showed up with the fields values set to the corresponding values in the DB.

 

Could you check out the code and help me out please?

 

<?php

$db_name="***";
$connection=mysql_connect("localhost","***","****") or die("I Couldn't connect");
$db=mysql_select_db($db_name,$connection) or die("I Couldn't select your database");
$table="player"; // Table name
$sql="select user, first, last, birth, address, city, state, zip, email, grade, team, coach, height, weight, gpa, sat, phone, other from $table WHERE user='$user'";
$result=mysql_query($sql,$connection) or die(mysql_error());
if(!isset($row['user'])){
while($row=mysql_fetch_array($result)) {

?> 
<form method="post" action="../player/insertupdate.php"> 
<input type="hidden" name="user" value="<?php echo $user; ?>">
  <p>First Name
    <input type="text" name="first" maxlength="20" value="<?php echo $row['first']; ?>">
Last Name
    <input type="text" name="last" maxlength="20" value="<?php echo $row['last']; ?>">
  </p>
  <p>Birth Date
    <input type="text" name="birth" maxlength="20" value="<?php echo $row['birth']; ?>">
  
  Address 
    <input type="text" name="address" maxlength="50" value="<?php echo $row['address']; ?>">
  </p>
  <p>
    City
    <input type="text" name="city" maxlength="20" value="<?php echo $row['city']; ?>">
    State 
    <select name="state" value="<?php echo $row['state']; ?>">
      #
<option value="">None</option>
#
<option value="AL">Alabama</option>
#
<option value="AK">Alaska</option>
#
<option value="AZ">Arizona</option>
#
<option value="AR">Arkansas</option>
#
<option value="CA">California</option>
#
<option value="CO">Colorado</option>
#
<option value="CT">Connecticut</option>
#
<option value="DC">District of Columbia</option>
#
<option value="DE">Delaware</option>
#
<option value="FL">Florida</option>
#
<option value="GA">Georgia</option>
#
<option value="HI">Hawaii</option>
#
<option value="ID">Idaho</option>
#
<option value="IL">Illinois</option>
#
<option value="IN">Indiana</option>
#
<option value="IA">Iowa</option>
#
<option value="KS">Kansas</option>
#
<option value="KY">Kentucky</option>
#
<option value="LA">Louisiana</option>
#
<option value="ME">Maine</option>
#
<option value="MD">Maryland</option>
#
<option value="MA">Massachusetts</option>
#
<option value="MI">Michigan</option>
#
<option value="MN">Minnesota</option>
#
<option value="MS">Mississippi</option>
#
<option value="MO">Missouri</option>
#
<option value="MT">Montana</option>
#
<option value="NE">Nebraska</option>
#
<option value="NV">Nevada</option>
#
<option value="NH">New Hampshire</option>
#
<option value="NJ">New Jersey</option>
#
<option value="NM">New Mexico</option>
#
<option value="NY">New York</option>
#
<option value="NC">North Carolina</option>
#
<option value="ND">North Dakota</option>
#
<option value="OH">Ohio</option>
#
<option value="OK">Oklahoma</option>
#
<option value="OR">Oregon</option>
#
<option value="PA">Pennsylvania</option>
#
<option value="PR">Puerto Rico</option>
#
<option value="RI">Rhode Island</option>
#
<option value="SC">South Carolina</option>
#
<option value="SD">South Dakota</option>
#
<option value="TN">Tennessee</option>
#
<option value="TX">Texas</option>
#
<option value="UT">Utah</option>
#
<option value="VT">Vermont</option>
#
<option value="VA">Virginia</option>
#
<option value="WA">Washington</option>
#
<option value="WV">West Virginia</option>
#
<option value="WI">Wisconsin</option>
#
<option value="WY">Wyoming</option>
#

    </select> 
    Zipcode 
    <input type="text" name="zip" maxlength="5" value="<?php echo $row['zip']; ?>">
  </p>
  <p>Phone ex.(555) 555-5555 <input type="text" name="phone" maxlength="20" value="<?php echo $row['phone']; ?>">
Email <input type="text" name="email" maxlength="50" value="<?php echo $row['email']; ?>"> </p>
  
  <p>Grade <input type="text" name="grade" maxlength="10" value="<?php echo $row['grade']; ?>">
  School <input type="text" name="team" maxlength="20" value="<?php echo $row['team']; ?>">
  </p>
  <p>Coach <input type="text" name="coach" maxlength="20" value="<?php echo $row['coach']; ?>">
  Height <input type="text" name="height" maxlength="10" value="<?php echo $row['height']; ?>">
  Weight <input type="text" name="weight" maxlength="10" value="<?php echo $row['weight']; ?>">
  </p>
   <p>Grade Point Average (GPA) <input type="text" name="gpa" maxlength="10" value="<?php echo $row['gpa']; ?>">
  SAT Score <input type="text" name="sat" maxlength="5" value="<?php echo $row['sat']; ?>">
  </p>
  <p>
  Notable Academic and Athletic Achievments: (2500 Character Maximum) </p>
  
  
  <textarea name="other" rows="10" cols="50"><?php echo $row['other']; ?> </textarea>
  <p><input type="submit" value="Submit"></p> 
</form>
<?php
}
}else{

?>
<form method="post" action="../player/insertplayer.php"> 
  <p>First Name
    <input type="text" name="first" maxlength="20">
Last Name
    <input type="text" name="last" maxlength="20">
  </p>
  <p>Birth Date
    <input type="text" name="birth" maxlength="20">
  
  Address 
    <input type="text" name="address" maxlength="50">
  </p>
  <p>
    City
    <input type="text" name="city" maxlength="20">
    State 
    <select name="state">
      #
<option value="">None</option>
#
<option value="AL">Alabama</option>
#
<option value="AK">Alaska</option>
#
<option value="AZ">Arizona</option>
#
<option value="AR">Arkansas</option>
#
<option value="CA">California</option>
#
<option value="CO">Colorado</option>
#
<option value="CT">Connecticut</option>
#
<option value="DC">District of Columbia</option>
#
<option value="DE">Delaware</option>
#
<option value="FL">Florida</option>
#
<option value="GA">Georgia</option>
#
<option value="HI">Hawaii</option>
#
<option value="ID">Idaho</option>
#
<option value="IL">Illinois</option>
#
<option value="IN">Indiana</option>
#
<option value="IA">Iowa</option>
#
<option value="KS">Kansas</option>
#
<option value="KY">Kentucky</option>
#
<option value="LA">Louisiana</option>
#
<option value="ME">Maine</option>
#
<option value="MD">Maryland</option>
#
<option value="MA">Massachusetts</option>
#
<option value="MI">Michigan</option>
#
<option value="MN">Minnesota</option>
#
<option value="MS">Mississippi</option>
#
<option value="MO">Missouri</option>
#
<option value="MT">Montana</option>
#
<option value="NE">Nebraska</option>
#
<option value="NV">Nevada</option>
#
<option value="NH">New Hampshire</option>
#
<option value="NJ">New Jersey</option>
#
<option value="NM">New Mexico</option>
#
<option value="NY">New York</option>
#
<option value="NC">North Carolina</option>
#
<option value="ND">North Dakota</option>
#
<option value="OH">Ohio</option>
#
<option value="OK">Oklahoma</option>
#
<option value="OR">Oregon</option>
#
<option value="PA">Pennsylvania</option>
#
<option value="PR">Puerto Rico</option>
#
<option value="RI">Rhode Island</option>
#
<option value="SC">South Carolina</option>
#
<option value="SD">South Dakota</option>
#
<option value="TN">Tennessee</option>
#
<option value="TX">Texas</option>
#
<option value="UT">Utah</option>
#
<option value="VT">Vermont</option>
#
<option value="VA">Virginia</option>
#
<option value="WA">Washington</option>
#
<option value="WV">West Virginia</option>
#
<option value="WI">Wisconsin</option>
#
<option value="WY">Wyoming</option>
#

    </select> 
    Zipcode 
    <input type="text" name="zip" maxlength="5" >
  </p>
  <p>Phone ex.(555) 555-5555 <input type="text" name="phone" maxlength="20">
Email <input type="text" name="email" maxlength="50"> </p>
  
  <p>Grade <input type="text" name="grade" maxlength="10">
  
   <?php

$host="localhost"; // Host name 
$username="****"; // Mysql username 
$password="***"; // Mysql password 
$db_name="****"; // Database name 
$tbl_name="teams"; // Table name 

// Connect to server and select database.
mysql_connect("$host", "$username", "$password")or die("cannot connect"); 
mysql_select_db("$db_name")or die("cannot select DB");

// Retrieve data from database 
$sql="SELECT team FROM $tbl_name ORDER BY team";
$result=mysql_query($sql);
?>

  School <select name = "team">
<?php
// Start looping rows in mysql database.
while($rows=mysql_fetch_array($result)){
?>
  <option value = <?php echo $rows['team']; ?>><?php echo $rows['team']; ?></option> <?php
// close while loop 
}

// close connection 
mysql_close();
?> 		  
									 </select>
  </p>
  <p>Coach <input type="text" name="coach" maxlength="20">
  Height <input type="text" name="height" maxlength="10">
  Weight <input type="text" name="weight" maxlength="10">
  </p>
   <p>Grade Point Average (GPA) <input type="text" name="gpa" maxlength="10">
  SAT Score <input type="text" name="sat" maxlength="5">
  </p>
  <p>
  Notable Academic and Athletic Achievments: (2500 Character Maximum) </p>
  
  
  <textarea name="other" rows="10" cols="50"> </textarea>
  <p><input type="submit" value="Submit"></p>
</form>
<?php
}
?>

This sql query selects what I need when the code runs correctly.

select user, first, last, birth, address, city, state, zip, email, grade, team, coach, height, weight, gpa, sat, phone, other from $table WHERE user='$user'

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.