You can use method $_GET for trasport value to other page then use selected method:(您可以使用$ _GET方法将值转移到其他页面,然后使用所选方法:)
<?php
$value=$_GET['VALUE1']
$othervalue=$_GET['VALUE2']
echo '<option value="$value" selected>$othervalue</option>
EDIT: All code, in the first page a use "/submit-review.php?valueid=$ID&valuename=$NAME" for trasport value to next page :(编辑:所有代码,在第一页中使用“ /submit-review.php?valueid=$ID&valuename=$NAME”将值转移到下一页:)
<h2 class="single-heading">
<?php echo get_the_title(); ?>
Review
<a href="
<?php echo home_url().'/submit-review.php?valueid=$ID&valuename=$NAME'; ?>
" class="btn btn-light text-right pbd-title-btn" id="title" value="
<?php echo get_the_title($post->ID); ?>
" >
<i class="fa fa-plus" aria-hidden="true">
</i>Write a Review</a>
</h2>
And on the next page i will convert $_GET to the local variable for use it on selected box:(然后在下一页上,我将$ _GET转换为局部变量,以便在选定的框上使用它:)
<div class="col-md-12 col-lg-12 col-xs-12 col-sm-12">
<label class="control-label">Select Breeder Name/Entity <span class="required">*</span></label>
<select class="category form-control" data-placeholder="Select an option" id="pbd_review_name" name="pbd_review_name_id" >
<?php
$valueID= $_GET['valueid'];
$valueNAME= $_GET['valuename'];
echo "<option value='$valueID' selected>$valueNAME</option>";
$res = get_posts(array('post_type' => 'review', 'post_status' => 'publish', 'posts_per_page' => -1));
if(!empty($res)){
foreach($res as $row){
$b_name = $row->post_title;
$b_photo = get_post_meta($row->ID,'photo',true);
$b_suburb = get_post_meta($row->ID,'suburb',true);
$b_state = get_post_meta($row->ID,'state',true);
$b_website = get_post_meta($row->ID,'website',true);
echo '<option value="'.$row->ID.'" data-name="'.$b_name.'" data-photo="'.$b_photo.'" data-suburb="'.$b_suburb.'" data-state="'.$b_state.'" data-website="'.$b_website.'" >'.$b_name.'</option>';
}
}
?>
</select>
edit 3:(编辑3:)
use SESSION for resolve your problem(first page):(使用SESSION解决您的问题(第一页):)
<h2 class="single-heading">
<?php echo get_the_title(); ?>
Review
<a href="
<?php echo home_url().'/submit-review/'; ?>
" class="btn btn-light text-right pbd-title-btn" id="title" value="
<?php echo get_the_title($post->ID); ?>
" >
<i class="fa fa-plus" aria-hidden="true">
</i>Write a Review</a>
</h2>
$_SESSION['id'] = $post->ID;
$_SESSION['title'] = $post->title;
On the second page:(在第二页上:)
<div class="col-md-12 col-lg-12 col-xs-12 col-sm-12">
<label class="control-label">Select Breeder Name/Entity <span class="required">*</span></label>
<select class="category form-control" data-placeholder="Select an option" id="pbd_review_name" name="pbd_review_name_id" >
<?php
$valueID= $_SESSION['id'];
$valueNAME= $_SESSION['title'];
echo "<option value='$valueID' selected>$valueNAME</option>";
$res = get_posts(array('post_type' => 'review', 'post_status' => 'publish', 'posts_per_page' => -1));
if(!empty($res)){
foreach($res as $row){
$b_name = $row->post_title;
$b_photo = get_post_meta($row->ID,'photo',true);
$b_suburb = get_post_meta($row->ID,'suburb',true);
$b_state = get_post_meta($row->ID,'state',true);
$b_website = get_post_meta($row->ID,'website',true);
echo '<option value="'.$row->ID.'" data-name="'.$b_name.'" data-photo="'.$b_photo.'" data-suburb="'.$b_suburb.'" data-state="'.$b_state.'" data-website="'.$b_website.'" >'.$b_name.'</option>';
}
}
?>
</select>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…