상대적으로 간단해야한다고 생각하는 일을하려고하는데 어떻게해야하는지 정확히 모르겠고 많은 예제를 검색하고 살펴 보았음에도 불구하고 어떻게해야할지 모르겠습니다.
날짜 입력 필드와 일 (7/14) 선택기가있는 양식이 있으며 사용으로 인해 날짜 또는 날짜가 변경되면 별도의 URL을 쿼리 한 다음 결과를 반환해야합니다.
내가 가진 문제는 :
양식에서 날짜 / 요일을 선택하지만 URL을 읽고 사용자를 리디렉션하지 않고 페이지를 새로 고쳐 URL을 읽은 결과를 반영하는 방법은 무엇입니까?
내가 의미하는 바를 보여주는 간단한 예를 모았습니다.
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>$( function() { $( "#datepicker" ).datepicker(); } ); </script>
</head>
<body>
<?php
// Example fully formatted URL
http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=2017-06-23&days=7
// http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=[DATESELECTED]&days=[DAYSSELECTED]
?>
<form action="http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&" method="GET">
<input class="datepicker" type="text" id="datepicker" name="date" value="">
<select><option value="7" id="days" name="days">7 days</option><option value="14">14 days</option></select>
<input type="hidden" name="c" value="3" />
<input type="submit" />
</form>
</body>
<?php
// Read contents of the URL
// dateselected = datepicker output
//$angelfish = file_get_contents('http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=' . $dateselected . '&days=' . $days);
// Display contents of the URL, i.e.
echo '<hr>';
echo 'Show example output that we are trying to achieve using above
selection but with defaults of date today and days of 7.';
echo '<br /><br />';
$dateselected = date('Y-m-d');
$daysselected = '7';
$angelfish = file_get_contents('http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=' . $dateselected . '&days=' . $daysselected);
echo $angelfish;
//At this point we'll format nicely with coloured rows, etc
?>
</body>
누군가 나를 올바른 방향으로 안내해 줄 수 있습니까?
감사합니다.
Rob
<pre>Please use below code <?php
$dateselected = date('Y-m-d');
$daysselected = '7';
if(isset($_POST['date']) && isset($_POST['days'])){
$dateselected=date('Y-m-d',strtotime($_POST['date']));
$daysselected = $_POST['days'];
}
?>
<head>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<link rel="stylesheet" href="/resources/demos/style.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script>$( function() { $( "#datepicker" ).datepicker(); } ); </script>
</head>
<body>
<?php
// Example fully formatted URL
http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=2017-06-23&days=7
// http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=[DATESELECTED]&days=[DAYSSELECTED]
?>
<form name="form1" method="POST">
<input class="datepicker" type="text" id="datepicker" name="date" value="">
<select name="days"><option value="7" id="days" name="days">7 days</option><option value="14">14 days</option></select>
<input type="hidden" name="c" value="3" />
<input type="submit" />
</form>
</body>
<?php
// Read contents of the URL
// dateselected = datepicker output
//$angelfish = file_get_contents('http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=' . $dateselected . '&days=' . $days);
// Display contents of the URL, i.e.
echo '<hr>';
echo 'Show example output that we are trying to achieve using above
selection but with defaults of date today and days of 7.';
echo '<br /><br />';
echo 'http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=' . $dateselected . '&days=' . $daysselected."<bR>";
$angelfish = file_get_contents('http://www.angelfishbooking.co.uk/feeds/roomavailability.aspx?id=Belle_Tout&date=' . $dateselected . '&days=' . $daysselected);
echo $angelfish;
//At this point we'll format nicely with coloured rows, etc
?>
</body></pre>
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다