Jump to content

[SOLVED] auto select


dare87

Recommended Posts

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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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>

Link to comment
Share on other sites

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.