Symbianize Forum

Most of our features and services are available only to members, so we encourage you to login or register a new account. Registration is free, fast and simple. You only need to provide a valid email. Being a member you'll gain access to all member forums and features, post a message to ask question or provide answer, and share or find resources related to mobile phones, tablets, computers, game consoles, and multimedia.

All that and more, so what are you waiting for, click the register button and join us now! Ito ang website na ginawa ng pinoy para sa pinoy!

HELP php and mysqli user commadn access

arenjayson

Amateur
Advanced Member
Messages
149
Reaction score
0
Points
26
paano pag samahin and more than 3 arrays na equal khit na null ang laman
checkbox and gamit
HELP PLEASE!

here's my code:

<?php
$select = $mysqli->query("SELECT SubMenuCode FROM tblsubmenuaccess WHERE EmployeeID='24'")or die($mysqli->error);
$numrows = mysqli_num_rows($select);
if($numrows>0):

echo '
<table>

<form method="post" action="<?php echo $_SERVER["PHP_SELF"];?>">
';
while($row= $select->fetch_object())
{
echo '
<tr>

<td><input type="text" class="submenu" name="submenu[]" value="'.$row->SubMenuCode.'"></td>
<td><input type="checkbox" class="cmdAdd" name="cmdAdd[]" value="ADD" >ADD </td>
<td><input type="checkbox" class="cmdEdit" name="cmdEdit[]" value="EDIT" >EDIT </td>
</tr>
';
}
echo '
<input type="submit" id="btn-save" name="submit" value="save">
</form>
</table>
';
endif;



//i want this output
submenu cmdAdd cmdEdit
Accounts ADD EDIT
AdministratorUtilities null EDIT
Users ADD EDIT
UserSubModule ADD null

?>
View attachment 337631
 

Attachments

  • chebox.jpg
    chebox.jpg
    120.1 KB · Views: 5
Last edited:
Medyo magulo yung gusto mo mangyari. Can you add more details? Kung may visuals ka nito mas maganda sana.
 
Yan po sir pa view ng images thank!
 
ano po ung logic sa system nyu sir?

pag pindut mo ng save anong mangyayari?

also pwede ka gumawa ng loop para ma segregate ang values ng arrays,
 
Try this code: Do come back here, if this answers your question and you still need help.

Note: Since magkaiba ang "name" ng dalawang checkbox options (add / edit) mo, matic na yan magkahiwalay at hindi na kailangan i-segregate pa. Kung meron ka multiple options na selected ang ADD checkbox, matic na magiging array ang cmdAdd mo, given na ang ginawa mong name ng checkbox mo ay may [], indicating na array sya. Same goes for the EDIT checkbox.
Code:
	<div class="row">
	
		<div class="col-md-6">
		
			<form method="POST">
			
				<table class="table table-bordered table-condensed">
					<tr>
						<th class="col-md-10 text-center">Name</th>
						<th class="col-md-1 text-center">Add</th>
						<th class="col-md-1 text-center">Edit</th>
					</tr>
					<?php
						for($x = 1; $x <= 10; $x++){
							$tempValue = 'Option ' . $x;
							echo '<tr>';
								echo '<td>' . $tempValue . '</td>';
								
								if(isset($_POST['cmdAdd'])){ $checked = (in_array($tempValue, $_POST['cmdAdd'])) ? 'checked' : ''; }
								echo '<td class="text-center"><input type="checkbox" name="cmdAdd[]" value="' . $tempValue . '" ' . $checked . '/></td>';
								
								if(isset($_POST['cmdEdit'])){ $checked = (in_array($tempValue, $_POST['cmdEdit'])) ? 'checked' : ''; }
								echo '<td class="text-center"><input type="checkbox" name="cmdEdit[]" value="' . $tempValue . '" ' . $checked . '/></td>';
							echo '</tr>';
						}
					?>
					<tr>
						<td></td>
						<td colspan="2"><button class="btn btn-primary btn-sm btn-block" name="submitted">Submit</button></td>
					</tr>
				</table>
				
			</form>
			
		</div>
		
		<div class="col-md-6" style="border: 1px solid #f00;">
			<?php
				if(isset($_POST['submitted'])){
					echo '<pre>';
						print_r($_POST);
					echo '</pre>';
				}
			?>
		</div>
	
	</div>
 
pag save po dapat mag insert sa database like "Acounts","ADD" - "Accounts","EDIT"
ganyan po sir yung module at yung access nya kung pwede sya mag ADD lang sa Module na yon or Edit o kaya VIEW ganun po
bale ang nagawa kona jquery array nakukuha ko naman yung mga value ang problema hindi tama yung pag kakasunosunod ng command
dapat kung katapat nya ay UserModule tpos check mo is ADD or EDIT yun yong mag iinsert.
hirap po kasi iexplain eh. thanks po

- - - Updated - - -

sir para saan po yung $checked na variable?
thank you sir! malapit konang magawa sa tulong mo:clap:
medyo naguguluhan lang ako ng konti sa codes pero nabigyan moko ng malupit na logic
MARAMING SALAMAT!!!!

- - - Updated - - -

Try this code: Do come back here, if this answers your question and you still need help.

Note: Since magkaiba ang "name" ng dalawang checkbox options (add / edit) mo, matic na yan magkahiwalay at hindi na kailangan i-segregate pa. Kung meron ka multiple options na selected ang ADD checkbox, matic na magiging array ang cmdAdd mo, given na ang ginawa mong name ng checkbox mo ay may [], indicating na array sya. Same goes for the EDIT checkbox.
Code:
	<div class="row">
	
		<div class="col-md-6">
		
			<form method="POST">
			
				<table class="table table-bordered table-condensed">
					<tr>
						<th class="col-md-10 text-center">Name</th>
						<th class="col-md-1 text-center">Add</th>
						<th class="col-md-1 text-center">Edit</th>
					</tr>
					<?php
						for($x = 1; $x <= 10; $x++){
							$tempValue = 'Option ' . $x;
							echo '<tr>';
								echo '<td>' . $tempValue . '</td>';
								
								if(isset($_POST['cmdAdd'])){ $checked = (in_array($tempValue, $_POST['cmdAdd'])) ? 'checked' : ''; }
								echo '<td class="text-center"><input type="checkbox" name="cmdAdd[]" value="' . $tempValue . '" ' . $checked . '/></td>';
								
								if(isset($_POST['cmdEdit'])){ $checked = (in_array($tempValue, $_POST['cmdEdit'])) ? 'checked' : ''; }
								echo '<td class="text-center"><input type="checkbox" name="cmdEdit[]" value="' . $tempValue . '" ' . $checked . '/></td>';
							echo '</tr>';
						}
					?>
					<tr>
						<td></td>
						<td colspan="2"><button class="btn btn-primary btn-sm btn-block" name="submitted">Submit</button></td>
					</tr>
				</table>
				
			</form>
			
		</div>
		
		<div class="col-md-6" style="border: 1px solid #f00;">
			<?php
				if(isset($_POST['submitted'])){
					echo '<pre>';
						print_r($_POST);
					echo '</pre>';
				}
			?>
		</div>
	
	</div>

sir para saan po yung $checked na variable?
thank you sir! malapit konang magawa sa tulong mo
medyo naguguluhan lang ako ng konti sa codes pero nabigyan moko ng malupit na logic
MARAMING SALAMAT!!!!
 
Back
Top Bottom