skiingguru1611 Posted October 25, 2008 Author Share Posted October 25, 2008 After if(!isset($row['user'])){ ?> I close the php code block and then put the form in html. I do not echo it or anything. Could that be the problem? Quote Link to comment https://forums.phpfreaks.com/topic/129997-help-with-phpmysql-code-needs-to-be-done-soon/page/2/#findComment-674709 Share on other sites More sharing options...
kenshintomoe225 Posted October 25, 2008 Share Posted October 25, 2008 Nah thats not the problem. <?php if(true) {?> <html> some html code here </html> <?php } ?> this is perfectly valid Also, can you paste the output of that SQL query for me? Quote Link to comment https://forums.phpfreaks.com/topic/129997-help-with-phpmysql-code-needs-to-be-done-soon/page/2/#findComment-674712 Share on other sites More sharing options...
skiingguru1611 Posted October 25, 2008 Author Share Posted October 25, 2008 Well the output depends on the user that is logged in. Quote Link to comment https://forums.phpfreaks.com/topic/129997-help-with-phpmysql-code-needs-to-be-done-soon/page/2/#findComment-674713 Share on other sites More sharing options...
Andy-H Posted October 25, 2008 Share Posted October 25, 2008 <?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()); $num = mysql_numrows($result,$connection); if($num != 0){ 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 } ?> Quote Link to comment https://forums.phpfreaks.com/topic/129997-help-with-phpmysql-code-needs-to-be-done-soon/page/2/#findComment-674715 Share on other sites More sharing options...
kenshintomoe225 Posted October 25, 2008 Share Posted October 25, 2008 Could you please provide an explanation of what you changed? Copy and pasting code rarely helps someone learn Quote Link to comment https://forums.phpfreaks.com/topic/129997-help-with-phpmysql-code-needs-to-be-done-soon/page/2/#findComment-674721 Share on other sites More sharing options...
skiingguru1611 Posted October 25, 2008 Author Share Posted October 25, 2008 Gives me this error with or without an entry in the DB. Warning: Wrong parameter count for mysql_numrows()[/qoute] Also it tries to display the "else" statement with or without the entry in the DB. <?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()); $num = mysql_numrows($result,$connection); if($num != 0){ 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 } ?> Quote Link to comment https://forums.phpfreaks.com/topic/129997-help-with-phpmysql-code-needs-to-be-done-soon/page/2/#findComment-674722 Share on other sites More sharing options...
skiingguru1611 Posted October 25, 2008 Author Share Posted October 25, 2008 I won't be on for like 6 hours. So I will see your replies in the morning. Thanks for all your help. Keep posting anything you think may help. Quote Link to comment https://forums.phpfreaks.com/topic/129997-help-with-phpmysql-code-needs-to-be-done-soon/page/2/#findComment-674725 Share on other sites More sharing options...
Andy-H Posted October 25, 2008 Share Posted October 25, 2008 Just changed if (!isset($row['user'])){ /// to $num = mysql_numrows($result); if($num != 0){ Quote Link to comment https://forums.phpfreaks.com/topic/129997-help-with-phpmysql-code-needs-to-be-done-soon/page/2/#findComment-674727 Share on other sites More sharing options...
Andy-H Posted October 25, 2008 Share Posted October 25, 2008 <?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()); $num = mysql_numrows($result); if($num != 0){ 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 } ?> ***** Quote Link to comment https://forums.phpfreaks.com/topic/129997-help-with-phpmysql-code-needs-to-be-done-soon/page/2/#findComment-674728 Share on other sites More sharing options...
skiingguru1611 Posted October 25, 2008 Author Share Posted October 25, 2008 Andy-H what did you change that time. BECAUSE IT WORKS!!! THANK YOU SOO MUCH. Quote Link to comment https://forums.phpfreaks.com/topic/129997-help-with-phpmysql-code-needs-to-be-done-soon/page/2/#findComment-674732 Share on other sites More sharing options...
kenshintomoe225 Posted October 26, 2008 Share Posted October 26, 2008 he changed the if statement to $num = mysql_numrows($result); if($num != 0){ Makes a lot of sense actually If it returns 0 rows, then it fount nothing in the database. Quote Link to comment https://forums.phpfreaks.com/topic/129997-help-with-phpmysql-code-needs-to-be-done-soon/page/2/#findComment-674754 Share on other sites More sharing options...
Andy-H Posted October 26, 2008 Share Posted October 26, 2008 no probs Quote Link to comment https://forums.phpfreaks.com/topic/129997-help-with-phpmysql-code-needs-to-be-done-soon/page/2/#findComment-674831 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.