Jump to content

Any way to cut this code down?


pouncer

Recommended Posts

if (isset($_POST['update'])) {
	$rss_id = $_POST['rss_id'];
	$link = $_POST["txtRSS_" . $rss_id];

	updateLink($rss_table, $rss_id, $link);
}

elseif (isset($_POST['delete'])) {
	$rss_id = $_POST['rss_id'];

	deleteLink($rss_table, $rss_id);
}

elseif (isset($_POST['view_rss'])) {
	$rss_id = $_POST['rss_id'];
	$link = $_POST["txtRSS_" . $rss_id];

	viewRSS($link);
}

 

It's just if statements, but the contents of some of them are the same like the $rss_id variables.

 

Link to comment
https://forums.phpfreaks.com/topic/153335-any-way-to-cut-this-code-down/
Share on other sites

I'm sure we could find SOMETHING to cut down, but would need more code. What you have that doesn't give enough information for us to determine if something can be removed or adjusted etc.

 

Post the form where the $_POST values are coming from, and additionally any other code on the page of those if/else statements.

The html form is built dynamically.

 

		<form method ='post' action='index.php' name='rss_record'>
		<input name='txtRSS_15' type='text' id='txtRSS' size='70' value='http://slashdot.org/rss/slashdot.rss'/>
		<input name='update' type='submit' value='Update'/>

		<input name='delete' type='submit' value='Delete'/>
		<input name='view_rss' type='submit' value='View'/>
		<input type='hidden' name='rss_id' value='15'>
		</form>

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.