Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have the following code:
echo "<td><textarea wrap='soft' class=tarea3 name='inston[]'>".$r['inston']."</textarea></td>\n";
I'd like to use that inston variable to associate with a dropdown list. I have working code for the dropdown list:
<tr><td class="tdt">
<?php te('Hosting Server');?>:</td> <td title='Select server'>
<select validate='required:true' class='mandatory' name='manufacturerid'>
<option value=''>Select</option>
<?php
foreach ($agents5 as $a) {
$dbid=$a['id'];
$atype=$a['label']; $s="";
if (isset($manufacturerid) && $manufacturerid==$a['id']) $s=" SELECTED ";
echo "<option $s value='$dbid' title='$dbid'>$atype</option>\n";
}
echo "</select>\n";
?>
</td></tr>
and a sql query for the above mentioned dropdown script,
$sql="SELECT * FROM items where itemtypeid=32 OR itemtypeid=44 order by label";
$sth=db_execute($dbh,$sql);
while ($r=$sth->fetch(PDO::FETCH_ASSOC)) $agents5[$r['id']]=$r;
How can we use the code above to associate inston variable?
Your question isn't clear and from what i understood, is suppose the answer to be this
First of all , use an id for the select tag and textarea and use an onChange function like this:
<textarea wrap='soft' class=tarea3 name='inston[]' id='inston'>".$r['inston']."</textarea>
<select validate='required:true' class='mandatory' name='manufacturerid' id='manufacturerid' onChange='setInston()'>
and the use this javascript function :
function setInston() {
var x = document.getElementById("manufacturerid").value;
document.getElementById("inston").innerHTML= x+"
";
}
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 3 years ago.
Improve this question
I have the following code printing out an array. I'd like to print this out into a selectable list.
foreach ($local as $record)
{
print($record->friendlyName);
}
Output example:
[checkbox] Option 1
[checkbox] Option 2
[checkbox] Option 3
[checkbox] Option 4
[checkbox] Option 5
Ideally I could take action on the selected option. Thank you!
I would do it like this. Depends, what value you want to get. Whether it's id of $record or it's friendlyName.
Its friendlyName:
<?php foreach ($local as $record) { ?>
<input type="checkbox" name="checkboxes[]" value="<?=$record->friendlyName?>">
<a><?=$record->friendlyName?></a>
<br>
<?php } ?>
Its ID:
<?php foreach ($local as $recordId => $record) { ?>
<input type="checkbox" name="checkboxes[]" value="<?=$recordId?>">
<a><?=$record->friendlyName?></a>
<br>
<?php } ?>
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
my question is how to make button disabled?
I have two buttons on/off,i had already stored as off in table..when the users wants him to update the table,the webpage will display as the disabled button of off button.
If you are fetching data using query you can achieve this as like
<input type='button' value='button' <?php if($data === "off"){echo "disabled";}/>
Try the code:
<?php
$db_value = true or false; // put your database retrieved value here
if($db_value == true ):
echo '<button type="button" name ="myButton" disabled>OFF</button>';
else:
echo '<button type="button" name ="myButton">ON</button>';
endif;
?>
'Try something like this:
<?php
$x=1; //says "on" is 1 and "off" is 0 in your database value.here you can check your database value and apply condition accordingly
if($x==1) {
$disabled="disabled=true";
} else {
$disabled="";
}
echo '<input type="button" name="button" value="button" '.$disabled.'>';
?>
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to post $dataHeadArr value through session and get it in next page.
<?php
if(isset($_POST["search"]))
{ $storename=$_POST["StoreName"];
$dataHeadArr=$db->query("SELECT *FROM `opening_stk`");?>
On for the page you have posted put
<?php
if(isset($_POST["search"])){
session_start();
$storename=$_POST["StoreName"];
$dataHeadArr=$db->query("SELECT * FROM `opening_stk`");
while($row=mysql_fetch_assoc($dataHeadArr)){
$allRows[]=$row;
}
$_SESSION['dataHeadArr']=$allRows;
}
?>
For the page that you want to retreive the variable put
<?php
session_start();
$dataHeadArr=$_SESSION['dataHeadArr'];
//This mysql result been parsed already, so you should be
//able to access values when you loop through it from here
for($i=0;$i<count($dataHeadArr); $i++){
echo "Printing row ".$i."</br>";
foreach($dataHeadArr[$i] as $key=>$item){
//Prints out all value for the row
echo $item[$key]."</br>";
}
echo "</br>";
}
?>
You may just set it in the POST or SESSION array and then retrieve it on next page. For ex-
$_POST['dataHeadArr']=$dataHeadArr;
To store...
$_SESSION['dataHeadArr'] = 'Whatever';
Then to retrieve simply..
if(isset($_SESSION['dataHeadArr'])){
echo $_SESSION['dataHeadArr'];
}
Make sure to call session_start(); at the top of every page.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
This is my HTML Code
<input type="checkbox" value="fotoğraf" name="materyal[]"> Fotoğraf
<input type="checkbox" value="resim" name="materyal[]">Resim
<input type="checkbox" value="çizelge" name="materyal[]">Çizelge
<input type="checkbox" value="katlanabilir harita" name="materyal[]"> Katlanabilir Harita
There are checkbox and i'll take values with $_POST['materyal'] and then i want to write screen values with comma if values more than one. if checkbox values empty i don't write anything screen.
if (isset($_POST['materyal']) && !empty($_POST['materyal'])) {
$materyal = $_POST['materyal'];
echo "İçerdiği extra materyaller ; ";
foreach ($materyal as $materyallist) {
foreach ($materyallist as $yenimateryal){
array_push($sonmateryal, $yenimateryal);
}
}
echo implode(", ", $sonmateryal);
}
This is my code. when i want to use implode in if contiditon, I take mistake.
How can i do
It seems like you just want to show the contents?
$sonmateryal = array();
if (isset($_POST['materyal']) && !empty($_POST['materyal'])) {
echo "İçerdiği extra materyaller ; ";
foreach ($_POST['materyal'] as $materyallist) {
foreach ($materyallist as $yenimateryal) {
$sonmateryal[] = $yenimateryal;
}
}
}
echo implode(", ", $sonmateryal);
update according to given HTML
if (!empty($_POST['materyal'])) {
echo "İçerdiği extra materyaller ; ".htmlentities(implode(',', $_POST['materyal']));
}
Since you're posting the inputs as simple array's this will implode the results with a comma if the post-ed value isn't empty..
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I have a page that contains a DB query, If there is a county in the URL then I run another query.
<head>
<title>Query results in $county</title>
</head>
...
if (isset($county)) {
// If county is set
$sth = $conn->prepare("SELECT * FROM directory WHERE user_active != '' AND County = :county");
} else {
// Run another query
}
I want to add the county in the page title if the county is set. Is this possible?
if (isset($county)) {
echo "<title>Query results in $county</title>\n";
} else {
echo "<title>Some other title</title>\n";
}
Absolutely. Just make sure your php that sets $county comes before the start of your html, then change your title tag to this:
<title>Query results in <?php echo $county;?></title>
Edit: Although j08691's answer is more comprehensive.