Jump to content

jamiemosteller

New Members
  • Posts

    4
  • Joined

  • Last visited

jamiemosteller's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Here is connect.php with the db info blanked out <?php function connectDB() { $hostname='***************'; $username='***********'; $password='**************'; $dbname='************'; mysql_connect($hostname, $username, $password) OR DIE('Unable to connect to database! Please try again later.'); mysql_select_db($dbname); } ?> And utility.php <?php function showerror() { die("Error " . mysql_errno() . " : " . mysql_error()); } function insertAthlete($Type,$WeightClass,$LastName,$FirstName,$GradYear,$Wins,$Losses,$School) { mysql_query("INSERT INTO athlete VALUES (DEFAULT,'$Type','$WeightClass','$LastName','$FirstName','$GradYear','$Wins','$Losses','$School')"); } function getAthletesAll() { $sql="SELECT * from athlete"; $resultAthletes = mysql_query($sql); return $resultAthletes; } function getAthletes() { $sql="SELECT athleteType, weightClass, firstName, lastName, gradYear, wins, losses from athlete"; $resultAthletes = mysql_query($sql); return $resultAthletes; } function getAthleteTypes() { $sql="SELECT * from athleteType"; $resultAthleteTypes = mysql_query($sql); return $resultAthleteTypes; } function getSchools() { $sql="SELECT schoolName from school"; $resultSchools = mysql_query($sql); return $resultSchools; } function displayAthletes($resultAthletes) { // Start a table, with column headers print "<style> table,th,td { font-family:Arial; font-size:16; color:#000066; border:1px solid black; border-collapse:collapse; } </style>"; print "\n<table style=width:950px>\n<tr>\n" . "\n\t<th>Athlete ID</th>" . "\n\t<th>Athlete Type</th>" . "\n\t<th>Weight Class</th>" . "\n\t<th>First Name</th>" . "\n\t<th>Last Name</th>" . "\n\t<th>Grad Year</th>" . "\n\t<th>Wins</th>" . "\n\t<th>Losses</th>" . "\n\t<th>SchoolID</th>" . "\n</tr>"; // Until there are no rows in the result set, fetch a row into // the $row array and ... while ($row = @ mysql_fetch_row($resultAthletes)) { // ... start a TABLE row ... print "\n<tr>"; // ... and print out each of the attributes in that row as a separate TD (Table Data). foreach($row as $data) print "\n\t<td> {$data} </td>"; // Finish the row print "\n</tr>"; } // Then, finish the table print "\n</table>\n"; } ?>
  2. I don't get any output period. even when I simplify it to just be echo $attribute; as your suggested. I tried making a simple php file with just the below and that works as expected, so I think the db stuff is all good <?php include("connect.php"); include("utility.php"); connectDB(); $result = getSchools(); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { foreach ($row as $attribute) { echo $attribute; } } ?>
  3. Ansego, did you purposely leave out the semi-colon at the end? I've tried this both ways and still no luck
  4. Below is the code I'm trying to do to create a drop down of schools, that are in my db. <html> <form action="login.php" method="post"> <TABLE> <TR> <TH>School </TH> </TR> <TD> <select name="School"><option value="">-- School Name --</option> <?php include("connect.php"); include("utility.php"); connectDB(); $result = getSchools(); while ($row = mysql_fetch_array($result, MYSQL_NUM)) { foreach ($row as $attribute) { echo "<option>"; echo $attribute; echo "</option>"; } } ?> </select> </TD> </TABLE> <input type="submit" /> </form> </html>
×
×
  • 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.