Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
197 views
in Technique[技术] by (71.8m points)

MySQL and PHP Select Option with information from database

This is my project so far I have this I took the code from part of my project

<?php  error_reporting(E_ERROR | E_PARSE); ?>
<!DOCTYPE html>
<html>
<head>
<title>Call Ins </title>
<script type="text/javascript" src="Javascript/jquery.js"></script>
<script type="text/javascript" src="Javascript/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="Javascript/employee_number_autocomplete.js"></script>


<link href="css/create.css" rel="stylesheet" type="text/css" >
</head>
<body style="background-image: url('http://a0319p528/new_callins/images/background.jpg')">
<div align="center">
</div>
<h1 class="h1">Call Ins Entry Page<br><br></h1>
<div align="center">
<form action = "insert_process.php" method ="post" class="form" style="width: 700px; height: 575px">
<br><br><br><br><br>

	<table style="width: 81%">
<tr>	
	<!--start of Scheduled Date--!>
	<td style="width: 133px">Scheduled Date</td>
	<td style="width: 152px">
	<input name="Date_Scheduled" id="Date_Scheduled" type="text"value="<?php  echo date("M j, Y - g:i"); ?>"/>
</td>
	<!--end of Scheduled Date--!>
	<!--start of reason--!>
	<td style="width: 159px">Reason</td>
<td>
	<select name ="Reason" style="width: 160px" >
	<option value ="">Please select ...</option></select>
</td></tr>
	<!--end of reason--!>
	<!--start of Employee Name--!>			
<tr>
	<td style="width: 133px">Employee Name</td>
	<td style="width: 152px">
	<input type="text" id="Employee_Name" name="Employee_Name">
</td>
	<!--end of Employee Name--!>
	<!--start of Contact--!>
	<td style="width: 159px">Contact</td><td>
	<select name ="Contact" style="width: 160px">
	<option value ="">Please select ...</option></select>
</td></tr>
	<!--end of Contact--!>
	<!--start of Employee Number--!>
<tr>
     	<td style="width: 133px">Employee Number</td>
	<td style="width: 152px">
	<input type="text" id="Employee_Number" name="Employee_Number" ></td>
	<!--end of Employee Number--!>
	<!--start of Approval--!>	
	<td style="width: 159px">Approval</td>
<td>
	<select name ="Approval" style="width: 160px">
	<option value ="">Please select ...</option></select>
</td>
</tr>
	<!--end of Approval--!>
<tr>
	<td style="width: 133px">Time_Reported</td>
	<td style="width: 152px"><input name="Time_Reported" id="Time_Reported" type="text"value="<?php  echo date("M j, Y - g:i"); ?>"/></td>
</td>
	<!--end of Approval--!>
	<!--start of Scheduled Area--!>
	<td style="width: 159px">Scheduled Area</td>
	<td><select name ="Scheduled_Area" style="width: 160px" >
	<option value ="">Please select ...</option></select></td>
</tr>
	<!--end of Scheduled Area --!>
	</table>
<br>
	<input type="submit" value= "Submit Request "><br><br><br><br>
	<!--start of yes or no Checkbox--!>
	<p class="style1">Do not check Box bellow human resources use only<strong>.</strong></p>
	<label>no</label>
	<input type="checkbox" id="Complete" name="Complete" value="N">
	<label>yes</label>
	<input type="checkbox" id="Complete" name="Complete" value="Y"> <br>
	<!--end of no or yes checkbox--!>
</form>
</div>
</body>
</html>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

If I understand you right, you just want to select data from your database and use it in your HTML. This is a very basic question. If you don't know how to do this, I would recommend a "How to learn MySQL" book first. You won't have fun developing a website where you have to ask online for every line of code.

Edit: Okay, now there is some code. This should work:

<option value="<?php echo $rc; ?>"><?php echo $row["FIRSTNAME"]</option>

However, please don't use your code in a public website. It's not the topic of the question, but there is a huge SQL-Injection vulnerability in your code.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...