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"]
Related
I am trying to develop an application form app. .
I want to be able to click on an application id and be able to generate the application form in details. So am using Sessions and it only works for the last id in the database.
Basically passing an application ID into a session then calling it as a parameter for the next page. If this method cant work, could there be another? Hope am clear enough.
Here is my code.
<td>
<a href="applicants_details.php"> <?php echo $Applicant->getApplicationID(); ?>
<?php php $_SESSION["SELECTEDID"] = $Applicant->GetApplicationID(); ?>
</td>
Use $_GET,
applications.php
<a href="applicants_details.php?applicant_id=<?php echo $Applicant->GetApplicationID(); ?>"><?php echo $Applicant->GetApplicationID(); ?><\a>
applicant_details.php
<?php
echo $_GET['applicant_id'];
?>
Change your code on the table to:
<td>
<a href="applicants_details.php?id=<?php echo $Applicant->getApplicationID(); ?>">
<?php echo $Applicant->getApplicationID(); ?>
</a>
</td>
Then on the next page you can get the ID with:
<?php
$id = $_GET['id'];
?>
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>
I am trying to load pictures from database to jquery slider
infact what is stored at database is the name of the picture
i implemented this code, it's working without errors but it showing me nothing at slider all is empty
<div id="slider">
<?php
while ($result = mysqli_fetch_object($banner)):
?>
<img src="images/banner/<? $banner['picture'];?>/" width="950" height="400"alt="" title="<strong><? echo $banner['title'];?></strong><span><? echo $banner['description'];?> </span>" />
<?php
endwhile
?>
</div>
name of the table at database is banner in which i have id(INT), picture(varchar 50) title(varchar(100), description(longblob)
query is working and returning number of selected rows
but nothing is shown
You need to echo the result rather than just use the variable...
<div id="slider">
<?php
while ($result = mysqli_fetch_object($banner)):
?>
<img src="images/banner/<?php echo $banner['picture'];?>" width="950" height="400" alt="" title="<strong><? echo $banner['title'];?></strong><span><?php echo $banner['description'];?></span>" />
<?php
endwhile;
?>
</div>
I'm attempting to modify an app for facebook that uses php and javascript.
It allows a user to send gifts to each other's wall. When a gift is received, it show's on the app's notification page for that user.
The problem: after a gift is accepted, it still shows on the notifications page. I suppose because it was deemed necessary in order for the point system as well as the history functions to operate properly. It appears that gifts older than 30 days are no longer displayed. I tried to permanently change the date of the gift after it's accepted.
Can anyone please suggest possible ways to:
Option 1. After the gift is accepted, permanently change it to a different image to inform the user "you have already accepted this". Without removing it from the database.
Option 2. Remove the gift from the page (or prevent it from being displayed) after it's accepted...without deleting it from the database. .hide and display:none; are not viable options because the gift will be displayed again...every time the page loads.
Option 3. Last and least desired option, remove the gift from the page and database as well.
The original code for that page is below. The part of the code that I'm guessing needs to be modified is located between the asterisk dividers. I hope it's not too difficult to follow :-/
Thanks for your time.
<?php
if(!isset($facebook))
{
$user_id=$_POST['user_id'];
}
else
{
$user_id=$user_info['UserID'];
}
$news_limit=$current_time-2592000;
$history_query=mysql_query("SELECT * FROM ".$exchange_table." WHERE Time>'$news_limit'
AND ReceiverID='$user_id' ORDER BY Time DESC");
$history_num=mysql_num_rows($history_query); ?>
<div style="font-size:14px;width:720px;padding:10px;<?php echo $background_one; ?>"
align="left">
<div style="font-weight:bold;font-size:16px;color:#6f6f6f;">
<?php echo $nav_info['home']; ?>
</div>
<div style="width:100%;margin-top:10px;" align="center">
<img src="<?php echo $app_info['image_url']; ?>divider.gif">
<img src="<?php echo $app_info['image_url']; ?>divider.gif">
<img src="<?php echo $app_info['image_url']; ?>divider.gif">
</div> <?php
if($history_num>0)
{
$gift_query=mysql_query("SELECT GiftID,Name,Image FROM ".$gift_table." WHERE
Type='1'");
while($gift_info=mysql_fetch_assoc($gift_query))
{
$gift_array[$gift_info['GiftID']]['name']=$gift_info['Name'];
$gift_array[$gift_info['GiftID']]['image']=$gift_info['Image'];
} ?>
<div style=""> <?php
$i=1;
while($history_info=mysql_fetch_assoc($history_query))
{ ?>
<div style="margin-top:10px;">
<div style="float:left;width:75px;">
<img src="<?php echo
$app_info['upload_url'].$gift_array[$history_info['GiftID']]['image']; ?>"
style="width:75px;height:75px;">
</div>
<div style="float:left;margin-left:10px;">
<span style="font-size:18px;"><span id="month<?php echo $i; ?>"></span> -
Gift Received!</span><br>
You received a(n) <b><?php echo $gift_array[$history_info['GiftID']]
['name']; ?></b> from <b><fb:name uid='<?php echo $history_info['FacebookID']; ?>'
linked='false'></fb:name></b>!<br>
**************************************************************
<input id="share_button<?php echo $i; ?>" onclick="shareFeed('<?php echo
$gift_array[$history_info['GiftID']]['image']; ?>','<?php echo $history_info['GiftID'];
?>','<?php echo $gift_array[$history_info['GiftID']]['name']; ?>')" type="image" src="
<?php echo $app_info['image_url']; ?>share_button.png"
onmouseover="convert('share_button<?php echo $i; ?>','share_hover.png')"
onmouseout="convert('share_button<?php echo $i; ?>','share_button.png')"
style="height:29px;margin-top:5px;">
</div>
**************************************************************
<br style="clear:both;">
</div>
<script>
var date_text="";
var time_date=new Date();
var monthNames=
["January","February","March","April","May",
"June","July","August","September","October","November","December"];
time_date.setTime(<?php echo $history_info['Time']*1000; ?>);
document.getElementById('month<?php echo $i; ?
>').innerHTML=monthNames[time_date.getMonth()]+" "+time_date.getDate();
</script> <?php
$i++;
} ?>
</div> <?php
}
else
{ ?>
<div style="font-size:14px;font-weight:bold;margin-top:20px;" align="center">
No giftss received over the past 30 days.
</div> <?php
} ?>
</div>
I have a page where I use the jquery load function to load data from a php file. The problem is that it does not always return the correct number of results. I have tried receiving the data straight from the php file and that worked perfectly. What could cause this problem with the load function?? It should only return a max of 5 entries.
s_showLoader();
$("#s_content").load("sdata.php", {s_page:1, user:fbusername}, s_hideLoader);
The show and hide loader functions just show and hide a gif loader. page is the page of pagination to display and user is just used to verify the user is logged in.
UPDATE 1:
Here is example of what the sample return looks like. It is in a while loop and is generated for each entry that is returned.
<table border="0">
<tr><td width="500">
<?php if($s_rows['name']){ echo $s_rows['name']; }else{ echo "User"; } ?><?php echo " | <a id='s_datedata".$s_idnum."'>".$s_rows['date']."</a>"; ?>
<div class="s_label<?php echo $s_idnum; ?>"><?php echo $s_display; ?></div>
<br>More Info...<br>
<div class="list_con" id="s_condata<?php echo $s_idnum; ?>"><?php echo $s_rows['content']; ?></div>
<div class="list_tags" id="s_contags<?php echo $s_idnum; ?>"><?php echo $s_rows['tags']; ?></div>
</td>
<td width="10" align="right"><!-- delete button if correct user is logged in-->
<?php
if($user && ($fbuser == $s_rows['fb_id']) ){
//show delete button
?>
<img src="close-icon.png" title="Click here to delete your listing" class="delopt" id="<?php echo $s_idnum; ?>" onclick="return del_list(<?php echo $s_rows['id']; ?>,<?php echo $s_rows['fb_id']; ?>)" height="25" width="25" alt="delete" border="0">
<?php
}else{
//echo $fbuser."|".$rows['fb_id'];
}
?>
</td>
</tr>
</table>
UPDATE 2:
This is the only POST variable in the php file. The rest of the data comes from the standard facebook api.
$s_page_num = floor($_POST['s_page']);
You can use html content instead of load.
function Load_Content() {
$.ajax({
url: 'yourfilename.php',
cache: false,
data: "s_page="+s_page_value,
success: function (html) {
$("#s_content").html(html);
}
});
}