Get data from previous page - get

I create a popup window using onclick="window.open()" the question is how can i get the data from previous page? here is my code :
<?php
include ("conn.php");
extract($_GET);
$applicantID = $_GET['applicantID'];
$sql = "SELECT * FROM applicant WHERE applicantID ='$applicantID'";
$query = mysql_query($sql);
$data = mysql_fetch_array($query);
echo $data['applicantID'];
?>
When i echo $data['applicantID']; it doesn't show any data.
I use this <input type="button" value="Check" onclick="window.open('checkstatus.php','popup','width=800,height=800,scrollbars=yes,resizable=no,toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0'); return false" />

Why don't you use window.open('checkstatus.php?applicantID=something')? And retrieve it by $applicantID = $_GET['applicantID'] so that I hope it will work.

Related

select option from Bot response

I am new to API.ai. I want to functionality such that when a Bot response says something to select from various options, user will select one of the options.
e.g.,
If Bot response says 'Which type of websites do you want to build?'
Select one of the given options.
1) Static
2) Dynamic
3) One page.
I have gone though various helps from the documentation , but I do not know how to set this up.
Please help.
This is your answer :
$arr = [];
if ($var == "Which type of websites do you want to build?") {
$arr[] = "Static";
$arr[] = "Dynamic";
$arr[] = "One page";
} else {
$arr[] = "option1";
$arr[] = "option1";
$arr[] = "option1";
}
Html Code:
<select name="website">
<?php
foreach ($arr as $key => $value) {
?>
<option value="<?php echo $value ?>"><?php echo $value; ?></option>
<?php
}
?>
</select>
Let me know if you require more details.

simplesearch modx with date dropdown integration

Iam new to modx(revolution version 2.5.7) and simple search(simplesearch-1.9.2-pl)
I need to add date dropdown (need to fetch results with matching date which is a template variable as type date ) with simplesearch extra in modx plugin. I have attached screenshot of my searchpage for reference. Please help me to solve this.
https://forums.modx.com/thread/95128/advsearch-to-show-search-value-based-on-dropdown-box.
After many painful debugging , got my code working.
[b]My code[/b] ,
[[!AdvSearchForm? &tpl=`AdvanceSearchForm_tpl`]]
</h1>
<h2>Results</h2>
<p>[[!AdvSearch? &parents=`12`&queryHook=`FilterCalenderSnippet` ]]
[b]form tpl (AdvanceSearchForm_tpl) :--[/b]
[code]<form id="[[+advsearch.asId]]_advsea-form" class="advsea-form" action="[[~[[+advsearch.landing]]]]" method="[[+advsearch.method]]">
<fieldset>
<input type="hidden" name="id" value="[[+advsearch.landing]]" />
<input type="hidden" name="asId" value="[[+advsearch.asId]]" />
[[+advsearch.helpLink]]<input type="text" id="[[+advsearch.asId]]_advsea-search" name="[[+advsearch.searchIndex]]" value="[[+advsearch.searchValue]]" />
[[$SeminarCalendarDateChunk]]// give the dropdown of dates,you can put your form elements
[[+advsearch.liveSearch:isnot=`1`:then=`<input type="submit" id="[[+advsearch.asId]]_advsea-submit" name="sub" value="[[%advsearch.search? &namespace=`advsearch` &topic=`default`]]" />`:else`=``]]
</fieldset>
</form>
[[+advsearch.resultsWindow]]
[b]Query Hook snippet(FilterCalenderSnippet)[/b]
[ul]
[li]My Date tv is EventDateTv[/li]
[/ul]
[code]
<?php
$andConditions = array();
// here i need to show events between one given input month. so I did some php to fetch first and last days of given month
if (!empty($_REQUEST['calendar_date'])) {
$dateToTest = $_REQUEST['calendar_date'];// my form element name is calendar_date
$lastday = date('Y-m-t',strtotime($dateToTest));
$andConditions['tv.EventDateTv:>='] = $dateToTest;
$andConditions['tv.EventDateTv:<='] = $lastday ;
}
if (!empty($andConditions)) {
$qhDeclaration = array(
'qhVersion' => '1.3',
'andConditions' => $andConditions
);
$hook->setQueryHook($qhDeclaration);
}
return true;
[/code]`enter code here`

redirecting search result, form submit

in my index page I have this code to call search action:
$this->renderPartial('search');
and this is the search action code:
$criteria = new CDbCriteria();
if (isset($_GET['city'])) {
$q = $_GET['city'];
$criteria->compare('fileName', $q, true, 'OR');
$criteria->compare('tags', $q, true, 'OR');
$dataProvider = new CActiveDataProvider("Files", array('criteria' => $criteria));
$this->redirect('result', array('dataProvider'=>$dataProvider));
}
$dataProvider = new CActiveDataProvider("Files", array('criteria' => $criteria));
$this->render('search');
and this is the search view:
<form method="get">
<?php
$url = CHtml::normalizeUrl(array("files/search"));
$model = Files::model();
$c = new FilesController('view');
$this->widget('zii.widgets.jui.CJuiAutoComplete',array(
'model'=>$model,
'id'=>'autocomplete',
'attribute'=>$model->fileName,
'name'=>'city',
'source'=>$c->actionAutoComplete(),
// additional javascript options for the autocomplete plugin
'options'=>array(
'minLength'=>'1',
),
'htmlOptions'=>array(
'style'=>'height:20px;',
'placeholder'=>'search',
'value'=>'isset($_GET["city"]) ? CHtml::encode($_GET["city"]) : "" ',
),));
?>
<input type="submit" value="search" />
</form>
I want to show the search results in another view, so once clicked the search submit button I want to redirect to another view to show the results, but in this code the search result is shown in the index page.
so how to do it?
you can either set the url that you want your form to be send, like:
$form = $this->beginWidget('bootstrap.widgets.TbActiveForm', array(
'action' => Yii::app()->createUrl('anotherController/anotherView'),
'method' => 'post',
));
or you can redirect to another page after your done in index, like:
$this->redirect(array('anotherController/anotherView'));

$wpdb not seeming to work with

I'm using the following code to populate a WordPress dropdown menu with all the unique values from a custom field:
<form name="search" action="" method="get">
<select name="stateprov">
<option>Select...</option>
<?php
$metakey = 'state_prov';
statesProvs = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = %s ORDER BY meta_value ASC", $metakey) );
if ($statesProvs) {
foreach ($statesProvs as $stateprov) {
echo "<option value=\"" . $stateprov . "\">" . $stateprov . "</option>";
}
}
?>
</select>
<input type="submit" value="search" />
</form>
However, it takes nothing from the DB so the popup list is empty.
Trying a different query like
$statesProvs = $wpdb->get_col( "SELECT ID FROM $wpdb->posts WHERE post_author = 2" );
Works as expected. I get a popup with a bunch of Post ID's in it. But the query that's supposed to work on my custom metadata just brings up an empty menu (and print_r reveals an empty array).
The data is definitely in the DB... what am I doing wrong?
It may also be significant that I'm using a custom metabox PHP class that writes all the custom-created field keys and values into the value of the _custom_meta metakey. If I've put that correctly. Thus:
a:61:{s:10:"state_prov";s:2:"CA";s:13:"vertical_drop";s:13:"3100ft / 945m";s:14:"base_elevation";s:14:"7953ft / 2424m";s:16:"summit_elevation";s:15:"11053ft / 3369m";s:12:"skiable_area";s:10:"3500 acres";s:16:"average_snowfall";s:14:"400in / 1016cm";s:13:
Etc. Is this way of storing the custom metadata preventing wpdb from accessing it properly?
Thanks!
you must use global $wpdb before you start the wpquery, refer codex for more details
<form name="search" action="" method="get">
<select name="stateprov">
<option>Select...</option>
<?php
global $wpdb;
$metakey = 'state_prov';
$wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = %s ORDER BY meta_value ASC", $metakey) );
if ($statesProvs) {
foreach ($statesProvs as $stateprov) {
echo "<option value=\"" . $stateprov . "\">" . $stateprov . "</option>";
}
}
?>
</select>
<input type="submit" value="search" />
</form>
Etc. Is this way of storing the custom metadata preventing wpdb from
accessing it properly?
Yes.
In general, Wordpress isn't capable of searching or sorting through serialized PHP arrays.
The most viable solution here is to store this data point ('state_prov') in its own custom field. This will allow you to naturally search and sort using $wpdb. It also seems like you want this custom field to be private/hidden, in which case you'll want to prefix it with an underscore: '_state_prov'.
Another option, assuming the above isn't viable for your needs, is to use MySQL String Functions; but this is far from ideal or optimized (especially if the database grows significantly.) Rough, untested example below.
// Assuming all state_prov are exactly 2 characters in length
$identifier = 's:10:"state_prov";s:2:"';
$identifier_length = strlen($identifier);
$wpdb->get_col($wpdb->prepare("SELECT DISTINCT(SUBSTR(`meta_value`, INSTR(`meta_value`, '$identifier')+$identifier_length, 2)) as `state_prov` FROM $wpdb->postmeta WHERE `meta_key`=%s ORDER BY `state_prov` ASC", $metakey) );

Custom predefined code template

I've been looking everywhere but I'm either blind or it's really not there.
I'm looking for some option to add some sort of code template to Dreamweaver (CS5.5) which I can access with some shortcode via the code hinting menu. In Zend (PHP IDE) you could define such code blocks like
$query = "";
$sql = mysql_query($query);
$result = mysql_fetch_assoc($sql);
and let Zend put them into your code when typing "qry" and hitting enter.
Is there such an option in Adobe Dreamweaver CS5.5?
I'we been looking for the same and found a solution. Try to add to your dreamweaver instalation path
"\Adobe Dreamweaver CS5\configuration\CodeHints\php_codehints.xml"
into to the section
<menugroup MMString:name="php/CORE" id="PHP_CORE"></menugroup>
following code:
<menu pattern="$query" doctypes="PHP_MySQL" displayrestriction="PHP_Script"
caseSensitive="true" icon="shared/mm/images/hintKeyword.png"
MMString:source="php/CORE" >
<menuitem label="mssql fetch //complete" value="="
SELECT * FROM
WHERE
";
$Qresult = mssql_query($query);
while ($Qdata = mssql_fetch_assoc($Qresult)) {
echo $Qdata[''];
};
" icon="shared/mm/images/hintMisc.gif"/>
</menu>
Now when you type $query to your code within PHP site, dreamweaver will offer you "mssql fetch //complete"
Analogically other code blocks. For example following:
<menu pattern="for" doctypes="PHP_MySQL" displayrestriction="PHP_Script"
caseSensitive="true" icon="shared/mm/images/hintKeyword.png"
MMString:source="php/CORE" >
<menuitem label="foreach()//complete" value="each ($arr as $k => $v) {
}" icon="shared/mm/images/hintMisc.gif"/>
<menuitem label="for()//complete" value=" ($i=0; $i<=$ ; $i++) {
};" icon="shared/mm/images/hintMisc.gif"/>
</menu>
<menu pattern="if" doctypes="PHP_MySQL" displayrestriction="PHP_Script"
caseSensitive="true" icon="shared/mm/images/hintKeyword.png"
MMString:source="php/CORE" >
<menuitem label="if()//complete" value=" ( ) {
}" icon="shared/mm/images/hintMisc.gif"/>
<menuitem label="if else//complete" value=" ( ) {
}
else {
}" icon="shared/mm/images/hintMisc.gif"/>
</menu>
I thing this solution works on Dreamweaver since CS versions, may be in MX too.
On the other site you can simply use SHIFT+F9 and define your own code block to paste.

Resources