dare87 Posted March 20, 2008 Share Posted March 20, 2008 I have a page the show a bunch of employees, and I would like to add a link that says "Apply Now" by each one. When they hit that link I would like it to take them to another page that has a "Refferd By:" selection. Is there a way to make it auto select that person by clicking that link? Page one is team.php <?php // Connect to the database. require_once ('../mysql_connect.php'); // The number of pages to display per page. $display = 6; // Calculate how many pages will be needed. // If the number of pages has not been calculated, then it will need to calculated. if (isset($_GET['np'])) $num_pages = $_GET['np']; else // Needs to be calculated. { // Count the number of records in the database. $query = "SELECT COUNT(*) FROM team ORDER BY date_registered DESC"; $result = mysql_query ($query); $row = mysql_fetch_array ($result, MYSQL_NUM); $num_records = $row[0]; // Calculate the number of pages to use. if ($num_records > $display) $num_pages = ceil ($num_records / $display); else $num_pages = 1; } // Determine in the database to start returning results. if (isset($_GET['s'])) $start = $_GET['s']; else $start = 0; // Make the query. $query = "SELECT team_id, name, title, dphone, ext, cphone, fax, toll, email, picture FROM team WHERE access_level >=1 ORDER BY name ASC LIMIT $start, $display"; // Run the query. $result = @mysql_query ($query); // If the query ran w/o error, print out the results. if ($result) { while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) { echo ' <table width="475" border="0" cellspacing="0" cellpadding="0"> <tr> <td background="../images/team/top.gif" width="475" height="26"> </td> </tr> <tr> <td background="../images/team/middle.gif"> <table> <tr> <td> </td> <td><img src="../images/team/' . $row['picture'] . '.jpg" width="120" height="160" alt="' . $row['name'] . '"> </td> <td> </td> <td> <span style="font-size:15px; font-weight:bold;">' . $row['name'] . '</span><br> <i>' . $row['title'] . '</i><br><br> Office: ' . $row['dphone'] . ' ext: ' . $row['ext'] . '<br> Mobile: ' . $row['cphone'] . '<br> Fax: ' . $row['fax'] . '<br> Toll Free: ' . $row['toll'] . '<br> ' . $row['email'] . ' </td> </tr> !!!!!!!ADD APPLY NOW LINK AROUND HERE!!!!!!! </table> </td> </tr> <tr> <td background="../images/team/bottom.gif" width="475" height="30"> </td> </tr> </table> '; } // Free up the resources. mysql_free_result ($result); // Make links to other pages, if necessary. if ($num_pages > 1) { echo '<br /><p>'; // Determine what page the script is on. $current_page = ($start / $display) + 1; // If it's not the first page, create a previous button. if ($current_page != 1) echo '<a href="team.php?s=' . ($start - $display) . '&np=' . $num_pages . '">Previous</a> '; // Make all the numbered pages. for ($i = 1; $i <= $num_pages; $i++) if ($i != $current_page) echo '<a href="team.php?s=' . (($display * ($i - 1))) . '&np=' . $num_pages . '">' . $i . '</a> '; else echo $i . ' '; // If it's not the last page, make a Next button. if ($current_page != $num_pages) echo '<a href="team.php?s=' . ($start + $display) . '&np=' . $num_pages . '">Next</a> '; echo '</p>'; } } else { // If the query did not run successfully, print out an error message. echo 'The User List could not be retrieved.'; } // Close the database connection. mysql_close(); ?> Page two is loanapp.php <?php include('includes/top.php'); ?> <div id="main"> <div id="sideBarLeft"><?php include('includes/left.php'); ?></div> <div id="content"> <form name="composeLoan" action="loanapp.php" method="post"> <table width="585" style="FONT-SIZE: 8pt; COLOR: black; FONT-FAMILY: Verdana,Arial,Helvetica,Serif; BORDER-COLLAPSE: collapse"> <tr> <td align="right">Refferd By:</td> <td align="left" colspan="3"><select name="emails"> <option value="select">Select One</option> <option value="none">No One</option><?php // Retrieve all the names and add them to the pull-down menu. require_once('../mysql_connect.php'); $query = "SELECT team_id, name FROM team ORDER BY name ASC"; $results = @mysql_query ($query); while ($row = mysql_fetch_array ($results, MYSQL_NUM)) echo '<option value="' . $row[0] . '">' . $row[1] . '</option>\n';?> </select></td> </tr> <tr> <td> </td> <td><input type="submit" class="button" name="submit" value="Submit"></td> </tr> <tr> <td> </td> <td class="smallText">* Highlighted forms designate required fields.</td> </tr> </table> </form> <?php if (isset($_POST['submit'])) // The form has been submitted. { // Initialize an error array to contain any error messages. $errors = array(); // Check for a info...............BLAH BLAH BLAH // Submit the article. if (empty($errors)) { // Connect to the database. require_once('../mysql_connect.php'); $query = "INSERT INTO BLaH SET BLAH, BLAH"; $results = @mysql_query($query); if ($results) echo 'Thank you. Your article has been posted.'; else echo 'Your article could not be added to the database.'; } else foreach ($errors as $msg) echo " - $msg<br/>\n"; } ?> </div> <div id="footer"><?php include('includes/bottom.php'); ?></div> </div> THANKS Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 20, 2008 Share Posted March 20, 2008 Is TeamID the primary key? in the while loop add <?php echo "<a href=\"loanapp.php?refer=".$row['TTeamID']."\">Click Here</a>"; ?> Then on the second page the while loop becomes <?php while ($row = mysql_fetch_array ($results, MYSQL_NUM)){ echo "<option value=\"".$row[0]."\""; if($_GET['refer'] == $row[0]){echo " selected ";} echo ">".$row[1]."</option>"; ?> Quote Link to comment Share on other sites More sharing options...
dare87 Posted March 20, 2008 Author Share Posted March 20, 2008 I am getting this error Parse error: syntax error, unexpected $end in /loanapp.php on line 369 The code on that line is </html> Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 20, 2008 Share Posted March 20, 2008 I gave u an example you need to work it into what u have... Quote Link to comment Share on other sites More sharing options...
dare87 Posted March 20, 2008 Author Share Posted March 20, 2008 I did <td> <span style="font-size:15px; font-weight:bold;">' . $row['name'] . '</span><br> <i>' . $row['title'] . '</i><br><br> Office: ' . $row['dphone'] . ' ext: ' . $row['ext'] . '<br> Mobile: ' . $row['cphone'] . '<br> Fax: ' . $row['fax'] . '<br> Toll Free: ' . $row['toll'] . '<br> ' . $row['email'] . '<br> <a href=loanapp.php?refer=' . $row['team_id'] . '>Apply Now</a> </td> <select name="refer"> <option value="select">Select One</option> <option value="none">No One</option><?php // Retrieve all the names and add them to the pull-down menu. require_once('../mysql_connect.php'); $query = "SELECT team_id, name FROM team ORDER BY name ASC"; $results = @mysql_query ($query); while ($row = mysql_fetch_array ($results, MYSQL_NUM)){ echo "<option value=\"".$row[0]."\""; if($_GET['refer'] == $row[0]){echo " selected ";} echo ">".$row[1]."</option>\n";?> </select> Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 20, 2008 Share Posted March 20, 2008 you don't close the while loop Quote Link to comment Share on other sites More sharing options...
dare87 Posted March 20, 2008 Author Share Posted March 20, 2008 I don't know how... I'm kinda stupid Quote Link to comment Share on other sites More sharing options...
cooldude832 Posted March 20, 2008 Share Posted March 20, 2008 if I opened it with a { maybe you should close it with a } Quote Link to comment Share on other sites More sharing options...
dare87 Posted March 20, 2008 Author Share Posted March 20, 2008 Okay, I shouldn't be that stupid.... but THANKS!!! Quote Link to comment 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.