₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,330,238 members, 8,444,529 topics. Date: Monday, 13 July 2026 at 04:24 PM

Toggle theme

Who Can Solve This Problem Pls - Webmasters - Nairaland

Nairaland ForumScience/TechnologyWebmastersWho Can Solve This Problem Pls (1009 Views)

1 Reply (Go Down)

Who Can Solve This Problem Pls by cbrass(op): 4:03am On Jul 07, 2015
this thing has been freaking my arse out since yesteday. what am trying to do is use a pop up to edit a post on a page, please note that the posts were pulled out of a db which means they have ids assigned to them. am using a modal to create a pop up but my issue is pulling the exact post when the edit button is clicked, i know if i call it with the id it will appear successfully but knowing where to put the id in other to refernce it is my problem , cry cry cry cry cry cry cry cry cry cry cry

this is my code
<div class="modal fade" id="modal-form" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span><span class="sr-only">Close</span></button>
<h4 class="modal-title" id="myModalLabel">Edit Post</h4>
</div>
<div class="modal-body">
<?php
$amala = "SELECT * FROM page_timeline WHERE timelineID='$postID' ORDER BY timelineID DESC";
$fufu = $db->query($amala);
while($rop = $akpu->fetch_array())
{
$post_modify = $rop['post'];
?>
<form role="form">

<div class="form-group">
<textarea cols="60" name="pq2" class="wysihtml form-control" style="height: 75px" size="10" ><?php echo $post_modify; ?></textarea>
</div>

</form>

</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>

</div>
<?php } ?>
cc adewasco2k dhtml18 onyegbu
Re: Who Can Solve This Problem Pls by cbrass(op): 4:15am On Jul 07, 2015
I forgot to add the hurry part sha, my jquery knowledge isn't sound enough sad
Re: Who Can Solve This Problem Pls by maekhel(m): 7:09am On Jul 07, 2015
First of all where is $postID coming from?
Re: Who Can Solve This Problem Pls by dwebdesign(m): 8:12am On Jul 07, 2015
maekhel:
First of all where is $postID coming from?
Re: Who Can Solve This Problem Pls by adewasco2k(m): 8:21am On Jul 07, 2015
All you need is the HTML5 data attribute

add this data-id="$id" to the post you are editing then you can use element.getAttribute('data-id') to get the id of the post.


i dont really understand your question but this will help
Re: Who Can Solve This Problem Pls by cbrass(op): 9:32am On Jul 07, 2015
adewasco2k:
All you need is the HTML5 data attribute

add this data-id="$id" to the post you are editing then you can use element.getAttribute('data-id') to get the id of the post.


i dont really understand your question but this will help
What am trying to do is when users click on the<a href=> edit link </a> it should pop up. The window of that post but when I did it it just picked any post and not the actual post that has the edit link. Of course I know why it's doing this but how to fix it is what I don't know yet or do you have a code for pop ups
Re: Who Can Solve This Problem Pls by cbrass(op): 9:33am On Jul 07, 2015
maekhel:
First of all where is $postID coming from?
From a previous code above
Re: Who Can Solve This Problem Pls by maekhel(m): 9:50am On Jul 07, 2015
cbrass:
From a previous code above
Why not attach the post id to the edit link then use the id in your where clause in your update query
Re: Who Can Solve This Problem Pls by cbrass(op): 12:16pm On Jul 07, 2015
maekhel:
Why not attach the post id to the edit link then use the id in your where clause in your update query
That will only work if I want to redirect to another page but it's a pop up containing a textarea below that I want to use I don't want ppl to go to another page. You know like Facebook edit where you stay on your timeline when you be ant to modify a post
Re: Who Can Solve This Problem Pls by onyengbu: 3:14pm On Jul 07, 2015
cbrass:
That will only work if I want to redirect to another page but it's a pop up containing a textarea below that I want to use I don't want ppl to go to another page. You know like Facebook edit where you stay on your timeline when you be ant to modify a post
I am on mobile and can offer very limited help here.
However, your issue have a very very simple solution. Since you are using query, there a lot of possibilities.
You can just use add an attribute to the a href link that launches the modal box. By attribute I mean id, rel, class or even non HTML imagined ones that is only if you have ran out of standard HTML attributes for that element.
JQuery will recognize it. Let's say you added an attributed named ahr to the link, and the link looks like this:
<a href="javascript:void(0)" ahr="23">Edit</a>
, you can create a variable from it in jquery like this: var thisID = $(this).attr("ahr"wink;
With this, you can then use query load() to load the db returned values specific to the query variable - thisID into the text area or content editable div where you can modify the db content and then send back via query/ajax request.

I will create a complete sample code when I get to a PC.
Re: Who Can Solve This Problem Pls by cbrass(op): 4:15pm On Jul 07, 2015
maekhel:
Why not attach the post id to the edit link then use the id in your where clause in your update query
Yea... am beginning get the idea nw thanks
Re: Who Can Solve This Problem Pls by cbrass(op): 4:16pm On Jul 07, 2015
onyengbu:
I am on mobile and can offer very limited help here.
However, your issue have a very very simple solution. Since you are using query, there a lot of possibilities.
You can just use add an attribute to the a href link that launches the modal box. By attribute I mean id, rel, class or even non HTML imagined ones that is only if you have ran out of standard HTML attributes for that element.
JQuery will recognize it. Let's say you added an attributed named ahr to the link, and the link looks like this:
<a href="javascript:void(0)" ahr="23">Edit</a>
, you can create a variable from it in jquery like this: var thisID = $(this).attr("ahr"wink;
With this, you can then use query load() to load the db returned values specific to the query variable - thisID into the text area or content editable div where you can modify the db content and then send back via query/ajax request.

I will create a complete sample code when I get to a PC.
Am very greatfull sir, thanks alot
Re: Who Can Solve This Problem Pls by onyengbu: 7:14am On Jul 08, 2015
cbrass:
Am very greatfull sir, thanks alot
Good. Have you done it?
Re: Who Can Solve This Problem Pls by cbrass(op): 9:49am On Jul 08, 2015
onyengbu:
Good. Have you done it?
Not yet because I already moved to other things, that one was taking too much of my time but with what I see there I have a clue to how I should fix it however I don't mind if you post the solution you promised.
Re: Who Can Solve This Problem Pls by DualCore1: 10:22am On Jul 08, 2015
I didn't read your codes so I'm going to answer you based on the problem you have stated.

For the list (psuedocode)

create an iteration through your db records
<foreach>
<a href="your_file?id=$record_id">Edit Post</a>
</foreach>


For the modal window, pull the post from the db where ID = the "id" GET variable. Add the "id" GET variable as a hidden input type in the form and in the file that processes the DB update, retrieve the hidden attribute through POST.


You should look at this plugin
http://vitalets.github.io/x-editable/

See how it can be implemented, check one of my past projects:
http://sawyerrken.net/projects/dreni/
username: admin
password: admin

Once logged into the dashboard, click on the "Bets" botton. Once in the bets page, click on any of the values in blue to edit then and see how it works.
1 Reply

Domainking: Voguepay Problem. Pls HELPIs This Problem From My Firefox Or Google? (pic Attached)Php/mysql Gurus, Please Help Solve This Problem...234

10 Best Web Browsers For Android Device.I Want Someone Who Can Make A Website Like KongaMy First Topic