I have a query that returns a row of values
<?php
$chapter_title = $story_data['chapter_title'];
and i have an href link that shows a modal when clicked
echo "<a href='#deleteModal' name='$chapter_title' >delete chapter</a>";
which shows
echo "<div id='deleteModal' class='modalDialog'>
<div>
<h3>Delete Chapter Confirmation </h3><h3 style = 'color:red'> $chapter_title</h3><hr>
<div style='display:inline-block;width:auto%'>
<text>You are about to delete this chapter. <br />It cannot be restored at a later time! <br />Do you still want to continue?</text>
<br><br>
<div id='create_btn'><a href=''>Delete</a></div>
<div id='cancel_btn'><a href=''>Cancel</a></div>
<br><br>
</div>
</div>
</div>";
?>
but i am having a problem in displaying the correct $chapter_title. Even when i click the delete button of the second row, it still shows the title of the first row. Please help me on what to do.
Instead of
<h3 style = 'color:red'> $chapter_title</h3>
Try echoing the content
<h3 style = 'color:red'><?php echo $chapter_title; ?></h3>
Correction
<a href='#deleteModal' name='<?php echo $chapter_title; ?>' >delete chapter</a>
Related
I need to know How to pass variable between two web pages with PHP without using session , have a DIV link in which inside there is id i want to pass to another page when a link is clicked but i fail to do it. please help me:
firstpage.php ( where there is a link) :
......
<?php
$identity = $_POST['book_id'];
while($ResultsRow=mysql_fetch_array($res)) {
?>
<div class="col-md-2 offset-md-2">
<div class='thumbnail'>
<a href="shopping.php?<?php echo $identity?>" target="blank">
<input type="text" name="book_id" value="<?php echo
$ResultsRow['id'] ?>">
</div>
</div>
</a> <!-- end of link -->
..........
Secondpage.php (where i want to retrieve book id):
....
<p> <?php $myvarC = $_POST['identity'];
echo $myvarC;
?> </p>
....
I think you should try something like below:
firstpage.php
<a href="shopping.php?identity=<?php echo $identity?>" target="blank">
secondpage.php
<p> <?php $myvarC = $_GET['identity'];
echo $myvarC;
?> </p>
You can include it in the urlquery like
shopping.php?id=1234
and then read it on the other side.
You can do this by $_GET;
First Page
<a href="shopping.php?id=<?php echo $identity?>" target="blank">
Second Page
<?php $myvarC = $_GET['id'];
echo $myvarC;
?>
Create a correct url with parameters
<a href="shopping.php?id=<?php echo $identity?>" target="_blank">
And get that value using
<?php
$myVarC = $_GET['id'];
echo $myVarC
?>
First Page
<a href="shopping.php?identity=<?php echo $identity?>" target="blank">
Second Page
<p> <?php $myvarC = $_REQUEST['identity'];
echo $myvarC;
?> </p>
I am trying to delete separate messages from a users inbox on my website. The user can go to the inbox, turn on the Delete Messages function which will show an extra HTML checkbox. This checkbox will then update the database to delete each message.
The messages and delete function are shown using the code below:
<p>
<a href="<?php echo 'http://basecentre.co.uk/', $message["username"]; ?>">
<img alt="" align="left" hspace="20" height="50" width="50"
src="<?php
echo 'http://basecentre.co.uk/userimages/',
$message["dp"];
?>">
</a>
<font color='<?php if ($message['unread']) echo '#FF0000'; ?>'>
<strong> <?php echo $message['first_name']; ?>
<?php echo $message['last_name']; ?> (
<?php echo date('d/m/Y H:i:s', $message['date']); ?>):
</strong>
</font>
<br />
<input type="checkbox" name="messageid" value="<?php echo $message['id']; ?>">
<?php echo $message['text']; ?>
</p>
The code to process the information is still being worked on, however I have hit a snag. The variable shows only ONE message id when it should actually show a list of all message id's that have been marked. Here is the processing code:
<?
/// DELETE MESSAGES
if (isset($_POST['delmessages'])) {
$delmessage_id = $_POST['messageid'];
echo $delmessage_id;
exit();
}
?>
How can I configure the variable to show more than one message id at a time ? Any ideas would be helpful. Thanks!
instead of
... name="foo"...
in your inputs, you need to use
... name="foo[] "
and all values will be in array $_POST[" foo"]
OK, I've been struggling with trying to pass parameters from the page to the popup div (within the same page) using jquery mobile. I'd just like to be able to edit or items from the database within a popup.
Here's the array of items I'm trying to update:
<div class="ui-block-c">
<?php
$fam_mem = $_db->rows('SELECT * from family_member', array());
foreach($fam_mem as $f)
{
echo "<a href='?id=$f[member_ID]#edit_fam_mem' data-mini='true' data-theme='d' data-inline='true' data-role='button' data-rel='popup' data-position-to='window' data-transition='pop' data-icon='gear' data-iconpos='notext'>Edit</a>";
echo "<a href='?id=$f[member_ID]#delete_fam_mem' data-mini='true' data-theme='d' data-inline='true' data-role='button' data-rel='popup' data-position-to='window' data-transition='pop' data-icon='delete' data-iconpos='notext'>Delete</a>";
}
?>
</div> <!--End ui-block-c-->
Here's the code for the popup div:
<div data-role="popup" id="delete_fam_mem" data-theme="d" data-overlay-theme="b" class="ui-content" style="max-width:340px;">
<?php //include_once("./delete_fam_mem.php");?>
<h3>Delete Family Member</h3>
<?php
echo "id is ", $_GET[id]; exit;
$del = $_db->query("DELETE FROM family_member WHERE member_ID = ", array($_GET[id]));
if ( $del )
echo "Chore $_GET[title] deleted successfully.";
else "Could not be deleted, maybe you should go to counseling.";
?>
<button class="button" onclick='closefancy()'>OK!</button>
</div> <!--End Delete Family Member-->
Some reason it will not pass the id from the page to popup. Any help would be greatly appreciated! Thanks!
just submitted a proposal which suggests how one could take parameters from the opener-button into the popups beforeposition event, see https://github.com/jquery/jquery-mobile/issues/7136
Put in your tag id property. Like 'id'.
And put one element to recive the value in your page. Like:
<input type="hidden" name="recivedId" />
So you can do something like that using jquery:
$('#a').on('click',function(){
$('#recivedId').val($(this).attr('href'));
})
I am trying to generate unique IDs for each modal, as I will be loading in an address specific map to each modal. My issue is that when I click the link:
<a data-toggle="modal" href="#myModal_<? echo $meeting['ID'] ?>" ><? echo $meeting['Address'].", ".$meeting['City'] ?></a>
it tries to take me to mypage.php/#myModal_8 (or whatever the given ID is, instead of pulling up that specific modal. The modals work great is I don't have the ID attached, but they won't load dynamic content that way.
<a data-toggle="modal" href="#myModal_<? echo $meeting['ID'] ?>" ><? echo $meeting['Address'].", ".$meeting['City'] ?></a>
</p>
<div class="modal hide" id="#myModal_<? echo $meeting['ID'] ?>">
<div class="modal-body">
<? echo $meeting['Address'] ?>
</div>
<div class="modal-footer">
Close
</div>
</div>
Any help on this would be much appreciated. Thank you!
It's all about the ID you are giving to the modal : id="#myModal_<? echo $meeting['ID'] ?>"
The # is only needed for the jQuery selector, not the ID. Which would give :
<div class="modal hide" id="myModal_<? echo $meeting['ID'] ?>">
Further more, you should open your php tags with <?php for the reasons described here : Are PHP short tags acceptable to use?
This is my first serious foray into javascript/ajax.
Overview:
I have an index page listing multiple records, each on different rows. For each record I have a link which pops open a small javascript window which contains a symfony form. All goes well, with the exception that I can't figure out how to pass the popup javascript the object Id of each record. Here's what I have:
Starting with the Action:
public function executeTrackReferrals(sfWebRequest $request){
$userId = $this->getUser()->getId();
$this->pager = new sfDoctrinePager('referral', sfConfig::get('app_pager'));
$this->pager->setQuery(Doctrine_Core::getTable('Referral_submissions')->getUsersSubmissions($userId));
$this->pager->setPage($request->getParameter('page', 1));
$this->pager->init();}
Main index page:
<?php
include_partial('<a bunch of other includes >');
include_partial('referral/rtsIndex', array('pager' => $pager));
?>
_rtsIndex partial:
<table>
<?php foreach ($pager->getResults() as $r => $referral): ?>
<?php
$referralObject = Doctrine_Core::getTable('referral')->getReferralObjectById($referral->getId());
$submissionObject = Doctrine_Core::getTable('referral_submissions')->getObjectByReferralId($referralObject->getId());
?>
<TR VALIGN=TOP>
<td WIDTH=10% ALIGN="center" class="_7">
<P ALIGN=CENTER>
<script type='text/javascript'>
$('.popup_changestatus').click(function(){
// put the row id into the hidden field in the popup
var rowId = $(this).parent().find('span.row_id').html();
$('test').val(rowId);
fg_popup_form("fg_formContainer","fg_form_InnerContainer","fg_backgroundpopup");
return false;
});
</script>
<a href="#" class="popup_changestatus">
<?php echo utilities::getStatusCode($submissionObject->getCandidateStatus()); ?>
</a>
<span class="row_id" style="display: none">
<?php echo $referral->getId() ?>
</span>
</P>
</td>
</TR>
</table>
the Javascript popup form code mentioned above, includes this line:
<?php include_partial('referral/changeStatusCodeForm'); ?>
The above line renders the actual symfony form:
_changeStatusCodeForm partial:
<?php
$object = new referral_submissionsForm(<this is where I need to pass an ID for each popup form>);
echo $object;
?>
Can anyone steer me in the right direction?
If interested in the actual javascript code, it's a pretty nifty open source popup:
http://www.html-form-guide.com/contact-form/simple-modal-popup-contact-form.html
EDIT:
Here is the contents of contactform-code.php:
<script type='text/javascript' src='/project/misc/simple-popup-form-1/scripts/gen_validatorv31.js'></script>
<script type='text/javascript' src='/project/misc/simple-popup-form-1/scripts/fg_ajax.js'></script>
<script type='text/javascript' src='/project/misc/simple-popup-form-1/scripts/fg_moveable_popup.js'></script>
<script type='text/javascript' src='/project/misc/simple-popup-form-1/scripts/fg_form_submitter.js'></script>
<div id='fg_formContainer'>
<div id="fg_container_header">
<div id="fg_box_Title">Change Status</div>
<div id="fg_box_Close">Close(X)</div>
</div>
<div id="fg_form_InnerContainer">
<form id='contactus' action='javascript:fg_submit_form()' method='post' accept-charset='UTF-8'>
<input type='hidden' name='submitted' id='submitted' value='1'/>
<input type='hidden' name='<?php echo $formproc->GetFormIDInputName(); ?>' value='<?php echo $formproc->GetFormIDInputValue(); ?>'/>
<input type='text' class='spmhidip' name='<?php echo $formproc->GetSpamTrapInputName(); ?>' />
<div class='short_explanation'>* required fields</div>
<div id='fg_server_errors' class='error'></div>
<div class='container'>
<?php
// $form = new referral_submissionsForm();
include_partial('referral/changeStatusCodeForm');
?>
</form>
</div>
</div>
First, you shouldn't directly use Doctrine_Core into your model. The best way here, is to make a leftJoin on your 2 tables when you pass the query to the pager. Then, in your template, you just fetch the relation (like $object->getRelation()).
Regarding to your problem, you should pass the ID when building the <div id='fg_formContainer'> since it's the content of your popup. The part come from this file: contactform-code.php.
Show us where do you build this div and you will have the place where you have to pass the id.
Edit:
Well, I finally get your problem. You have one popup define on your page that can be called on each click from each row. And you want to know how to pass the row id to the global popup.
This can be done in javascript. Instead of :
<a href='javascript:fg_popup_form("fg_formContainer","fg_form_InnerContainer","fg_backgroundpopup" );'>
<?php echo utilities::getStatusCode($submissionObject->getCandidateStatus()); ?>
</a>
You can better use :
<a href="#" class="popup_contact">
<?php echo utilities::getStatusCode($submissionObject->getCandidateStatus()); ?>
</a>
<!-- use this hidden span to put the row id, to be able to retrieve it using jQuery -->
<span class="row_id" style="display: none">
<?php echo $referral->getId() ?>
</span>
And then, define an action using jQuery (for example):
$('.popup_contact').click(function() {
// put the row id into the hidden field in the popup
var rowId = $(this).parent().find('span.row_id').html();
$('#submitted').val(rowId);
fg_popup_form("fg_formContainer", "fg_form_InnerContainer", "fg_backgroundpopup");
return false;
})