Jump to content

Reloading problem


son.of.the.morning

Recommended Posts

That isn't all of the relevant code for the problem you've described, but you should be checking to see if the query did in fact deleted anything by using mysql_affected_rows before echoing a success message.

Link to comment
https://forums.phpfreaks.com/topic/252578-reloading-problem/#findComment-1294909
Share on other sites

Yea i know this, i am just tring to create the primary functions in. The other part of the code is a while loop that creats a list of records, each row containing a button that says delete with the url as...

 

<a href"?id=<?php ehco $rows['id'] ?>">delete</a>

 

it them returns the url and then i GET the var ID from the url using the code i showed on the previous post. Sorry i havnt explained my self very well here

Link to comment
https://forums.phpfreaks.com/topic/252578-reloading-problem/#findComment-1294910
Share on other sites

I didnt want to post the code becuase there is quite a lot of it but here it is anyway

 

<?php

if(isset($_GET['id'])) {

$DeleteId = $_GET['id'];

mysql_query("DELETE FROM blog_posts WHERE ID=$DeleteId") or die (mysql_error());

echo "Record #".$DeleteId." had been sucessfully deleted.";

} ?>

 

 

<?php 
				$rowNum = "0";
				while($record_rows = mysql_fetch_array($records_returned)){
					if(++$rowNum % 2 == 1 ) {
			?>
                <form action="" method="post" name="DeleteSelected">
                <div class="Record">
                	<div class="Thumbnail"><img src="../img/articles/thums/<?php echo $record_rows['img_url']; ?>" class="RecordThumbnail"/></div>
                    <div class="RecordContent">
                    	<div class="PostTitle"><strong><?php echo $record_rows['title']; ?></strong></div>
                        <div class="CheckItem">
                        	Select: <input name="DeleteItem<?php echo $record_rows['id']; ?>" type="checkbox" value="<?php echo $record_rows['id']; ?>" />
                        </div>
                        <div class="PostSnipit"><?php echo substr($record_rows['post'], 0,50)."..."; ?></div>
                    	<div class="SelectOptions">
                        <div class="DeleteRecord" name="sub">Delete Article</div>
                        <div id="VeiwRecord">Hide Details</div><div id="DeleteConfirm">Are you sure you would like to delete this record?   <a href="?id=<?php echo $record_rows['id']; ?>" class="BlankLink"><input name="SingleRecordDelete" type="button" value="Yes." class="DeleteBtn" /></a>   <input name="" type="button" value="No." class="DeleteBtn" id="HideDeleteOptions" /></div>
                        <div id="ViewMoreHidden">
						<div class="MoreText"><?php echo substr($record_rows['post'], 0,250)."..."; ?></div>
                            <div class="PostedOn"><i><?php echo "Posted on: ".$record_rows['date_posted']; ?></i></div>
                        </div>
                    </div>
                    </div>
                </div>
                <?php } else {?>

 

 

Link to comment
https://forums.phpfreaks.com/topic/252578-reloading-problem/#findComment-1294915
Share on other sites

The problem is not in the few lines of code that deletes the recored (that work's doesn't it) and the problem is not in the block of code that displays the data (that works doesn't it), the problem, if it is being caused by the code, is in the order in which the data is being deleted in the database table and when the data is being selected from the database table when the page is requested, which is why Pika asked for ALL the logic.

Link to comment
https://forums.phpfreaks.com/topic/252578-reloading-problem/#findComment-1294933
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.