Jump to content

for each loop for html selection


CloudBreaker
Go to solution Solved by CloudBreaker,

Recommended Posts

The code is giving me no errors yet I get no selection.  Seems to be the right approach.  Starts on line 134 ends on 149.

 

Thanks,

CB

<?php

	$conn = mysqli_connect("localhost","root","","hsa_project_hub");

	session_start(); 

	if(!$_SESSION['user_loginName']){
	header("location: index.php");
	}
	else {
	
	$project_id=$_SESSION['project_id'];
	
	
	
	if(isset($_GET['id']) && is_numeric($_GET['id'])){
	
	
	$edit_id = $_GET['id'];
	
	$sql = "select rfis.no\n"
    . "FROM rfis\n"
    . "WHERE no=$edit_id";	
	
	$s = "SELECT * FROM `rfi_files` WHERE no=$edit_id ";
	
	$result=mysqli_query($conn,$sql);
	$row=mysqli_fetch_assoc($result);	
	
	
	
	$sql = "SELECT * FROM `rfis` WHERE no=$edit_id";
	
		
	$run = mysqli_query($conn,$sql);	
	
	$row = mysqli_fetch_array($run);
	
		$id				=$row["no"];
		$rfiNo			=$row["name"];
		$subject		=$row["subject"];
		$date_submit	=$row["date_submit"];
		$needed_by		=$row["needed_by"];
		$question		=$row["question"];
		$suggestion		=$row["gc_rsp"];
		$owner_rsp		=$row["owner_rsp"];
		$engr_rsp		=$row["engr_rsp"];
		$arch_rsp		=$row["arch_rsp"];
		$final_rsp		=$row["final_by"];
		$status			=$row["status"];
		
		
	$sql = "SELECT * FROM `rfi_files` WHERE no=$edit_id";
	
	$run = mysqli_query($conn,$sql);	
	
	$row = mysqli_fetch_array($run);
	
		$fileName		=$row["rfi_fileName"];
		
		echo $fileName;
		
	
		

		
		}
	
	echo $id;
	?> 

<!DOCTYPE HTML>

<style>
	form label {
	float: left;
	width: 150px;
	margin-bottom: 5px;
	margin-top: 5px;
	padding: 5px;
}
.clear {
	display: block;
	clear: both;
	width: 100%;
}

#rfi_container {
	background: #F0F0F0;
	font-family: 'Josefin Sans', sans-serif;
	font-weight: bold;
	color: #8F0000;
}

#files {
	background: yellow;
	display:block;
}
</style>

		<html>
			<head>
			</head>
	
		<body>
		
		
		
		<h2><?php echo $project_id;?></h2>
		
		<form id="form1" name="form1" method="post" action="currentTest.php?id=<?php echo $id;?>" enctype="multipart/form-data"><br>
					<br class="clear" />
					<label for="name">RFI NO.</label><input type="text" name="name" id="name" value="<?php echo $rfiNo;?>" />
					<br class="clear" /> 
					<label for="subject">Subject:</label><input type="text" name="subject" id="subject" value="<?php echo $subject;?>" />
					<br class="clear" /> 
					<label for="date_submit">Date submitted:</label><input type="date" name="date_submit" id="date_submit" disabled value="<?php echo $date_submit;?>" />
					<br class="clear" /> 
					<label for="needed_by">Date Needed by:</label><input type="date" name="needed_by" id="needed_by" value="<?php echo $needed_by;?>" />
					<br class="clear" /> 
					<label for="question">Question:</label><textarea name="question" id="question" cols="100" rows="8"><?php echo $question;?></textarea>
					<br class="clear" />
					<label for="GC Uploaded File">GC Uploaded File:</label><a href="rfi_files/<?php echo $fileName;?>"><?php echo $fileName;?></a>
					<br class="clear" />
					<label for="gc_rsp">Contractor Suggestion:</label><textarea name="gc_rsp" id="gc_rsp" cols="100" rows="8"> <?php echo $suggestion;?></textarea>
					<br class="clear" /> 
					<label for="owner_rsp">Owner Response:</label><textarea name="owner_rsp" id="owner_rsp" cols="100" rows="8"><?php echo $owner_rsp;?> </textarea>
					<br class="clear" /> 
					<label for="engr_rsp">Engineer Response:</label><textarea name="engr_rsp" id="engr_rsp"  cols="100" rows="8"><?php echo $engr_rsp;?></textarea>
					<br class="clear" /> 
					<label for="arch_rsp">Architect Response:</label><textarea name="arch_rsp" id="arch_rsp" cols="100" rows="8"><?php echo $arch_rsp;?></textarea><br>			
					<br class="clear" />
					
					<?php $data = "SELECT * FROM `user_project` WHERE project_id=$project_id";
							$result=mysqli_query($conn,$data);
							//Fetch all
							mysqli_fetch_array($result,MYSQLI_ASSOC);
							// Free result set
							mysqli_free_result($result);					
							
							mysqli_close($conn);
							
					?>
					
					<label for="final_by">Answered by:</label><select name="answered_by" id="answered_by" >
						<option value=""> --Select-- </option>
						<?php foreach($data as $row): ?>
						<option><?=$row['first_name']?></option>
						<?php endforeach ?>
					</select>
					<br class="clear" /> 
					<label for="date_returned">Date Returned:</label><input type="date" name="date_returned" id="date_returned" /><br>
					<br class="clear" />
					<label for="status">Status:</label><select name="status" id="status" >
						<option><?php echo $status;?></option>
						<option value="CLOSED">CLOSED</option>
						<option value="at Architect">at Architect</option>
						<option value="at MEP Engineer">at MEP Engineer</option>
						<option value="at Structural Engineer">at Structural Engineer</option>
						<option value="at Civil Engineer">at Civil Engineer</option>
						<option value="at Landscape Architect">at Landscape Architect</option>
						<option value="at Owner">at Owner</option>
						<option value="at General Contractor">at General Contractor</option>
					</select>
					<br class="clear" /><br> 
							
					<input type="file" name="files[]" multiple="" />
					<br class="clear" /><br> 
					<center><input type="submit" name="submit_data" id="submit_data" value="Modify RFI" /></center>
					
					
				</form>
				
				
	<?php 
	
	if(isset($_POST['submit_data'])){
		
		//getting the text information and saving in local variables
			$rfiNo			= mysqli_real_escape_string($conn,$_POST['name']);
			$needed_by		= mysqli_real_escape_string($conn,$_POST['needed_by']);
			$subject		= mysqli_real_escape_string($conn,$_POST['subject']);
			$question		= mysqli_real_escape_string($conn,$_POST['question']);
			$suggestion		= mysqli_real_escape_string($conn,$_POST['gc_rsp']);
			$owner_rsp		= mysqli_real_escape_string($conn,$_POST['owner_rsp']);
			$engr_rsp		= mysqli_real_escape_string($conn,$_POST['engr_rsp']);
			$arch_rsp		= mysqli_real_escape_string($conn,$_POST['arch_rsp']);
			$answered_by	= mysqli_real_escape_string($conn,$_POST['answered_by']);
			$status			= mysqli_real_escape_string($conn,$_POST['status']);
			
			$update = "update rfis set name='$rfiNo',needed_by='$needed_by',subject='$subject',question='$question',gc_rsp='$suggestion',owner_rsp='$owner_rsp',
						engr_rsp='$engr_rsp',arch_rsp='$arch_rsp',status='$status' WHERE no=$id";

			$run_update = mysqli_query($conn, $update);
			
			if($run_update){
				echo "<script>alert('RFI has been successfully modified.')</script>";
				echo "<script>window.open('rfi_list.php','_self')</script>";
			}
	}
	?>
	
				
			</body>
			
		</html>
	<?php } ?>
Link to comment
Share on other sites

Never mind the above code...this following is what I'm trying to work with.  At least I'm getting something...I just have to narrow it down by project which is just grabbing the project id.  However I having short-term issues concatenating the last name after the first (there are two rows---first_name and last_name.)

<?php
//Open Connection
          $conn = mysqli_connect("localhost","root","","hsa_project_hub");
//Gather Information
      $sql = "SELECT * FROM user_project";
      $result = mysqli_query($conn,$sql) or die (mysql_error());
?>    
<form action="selectionTest.php" method="post">
        <p>Final Answer by:
        <select name="first_name" >
            <option value="" >--Select--</option>
            <!-- Loop For Fetch Result -->        
            <?php while($row = mysqli_fetch_array($result) ) : ?>
             <option value="first_name:" ><?php echo($row['first_name']);?></option>
            <?php endwhile; ?> 
            <!-- End Loop for Fetch Result -->
    </select>
    </p>
    <input type="submit" value="Complete"/>
</form> 
Edited by CloudBreaker
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.