Code: Select all
if ( !isset($_GET['id']) || empty($_GET['id']) || !is_numeric($_GET['id']) )
{
//header('Location: article_list.php');
die("The search identifier " . $_GET['id'] . " had errors.");
}Moderator: General Moderators
Code: Select all
if ( !isset($_GET['id']) || empty($_GET['id']) || !is_numeric($_GET['id']) )
{
//header('Location: article_list.php');
die("The search identifier " . $_GET['id'] . " had errors.");
}Code: Select all
`news_dtl` (
`idx` int(8) unsigned NOT NULL auto_increment,
`section` int(1) NOT NULL default '0',
`author` varchar(35) default NULL,
`title` varchar(150) NOT NULL default '',
`lead` text NOT NULL,
`body` text NOT NULL,
`comments` varchar(255) default NULL,
PRIMARY KEY (`idx`)
)
`news_mas` (
`id` int(8) unsigned NOT NULL auto_increment,
`date` varchar(8) NOT NULL default '',
`location` varchar(3) NOT NULL default '0',
`section` int(1) NOT NULL default '0',
PRIMARY KEY (`id`)
)Code: Select all
-article_list.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<link href="../../default.css" rel="stylesheet" type="text/css">
<link href="../../balita.css" rel="stylesheet" type="text/css">
</head>
<?php
require("../../config.php");
conn_db($host, $user, $pass, $dbse);
?>
<body>
<div align="center">
<table width="396" border="1" cellpadding="0" cellspacing="0" bordercolor="#666666" class="tble">
<?php
$query = 'select news_mas.location, news_mas.section, news_dtl.title from news_mas, news_dtl
where news_mas.id = news_dtl.idx and news_mas.section = news_dtl.section order by news_mas.location ASC';
$result = mysql_query($query);
while($ctr = mysql_fetch_array($result)){ //Begin While
$xsec = $ctr['section'];
switch ($xsec){ // Begin Switch
case 1;
$sec = 'Balita';
break;
case 2;
$sec = 'Opinyon';
break;
case 3;
$sec = 'Kalingawan';
break;
case 4;
$sec = 'Sports';
break;
} // End Switch
echo '<tr><td height="20"><span class="article_title">'.$ctr['location'].' - '.$sec.': '.'<a href="view_article.php?id='.$ctr['id'].'">'.$ctr['title'].'</a></span></td>';
echo '<td width="40" height="20"><div align="center"><span class="maintxt">Edit</span></div></td></tr>';
}// End While
?>
</table>
</div>
</body>
</html>Code: Select all
-view_article.php
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
<link href="../../default.css" rel="stylesheet" type="text/css">
<link href="../../balita.css" rel="stylesheet" type="text/css">
</head>
<?php
require ("../../config.php");
conn_db($host, $user, $pass, $dbse);
?>
<body>
<div align="center">
<table width="590" border="0" cellpadding="3" cellspacing="0">
<?php
if ( !isset($_GET['id']) || empty($_GET['id']) || !is_numeric($_GET['id']) )
{
die("The search identifier " . $_GET['id'] . " had errors.");
}
$id = $_GET['id'];
$query = "select title, author, body from news_dtl
where idx = '$id'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
echo'
<tr>
<td width="594" height="79"><div id="divalign">
<div align="left" class="dtitle">'.$row['title'].'</div>
<p class="byline">'.$row['author'].'</p>
<br>
<p>'.nl2br($row['body']).'</p>
</div></td>
</tr>';
?>
</table>
</div>
</body>
</html>Code: Select all
$query = 'select news_mas.location, news_mas.section, news_dtl.title from news_mas, news_dtl
where news_mas.id = news_dtl.idx and news_mas.section = news_dtl.section order by news_mas.location ASC';Code: Select all
$query = 'SELECT news_mas.id, news_mas.location, news_mas.section, news_dtl.title
FROM news_mas, news_dtl
WHERE news_mas.id = news_dtl.idx
AND news_mas.section = news_dtl.section
ORDER BY news_mas.location ASC';Code: Select all
-edtfrm.php
<HTML>
<HEAD>
<link href="../../frmStyle.css" rel="stylesheet" type="text/css">
<link href="../../balita.css" rel="stylesheet" type="text/css">
<link href="../../default.css" rel="stylesheet" type="text/css">
</HEAD>
<BODY>
<?php
require("../../config.php");
conn_db($host, $user, $pass, $dbse);
if ( !isset($_GET['id']) || empty($_GET['id']) || !is_numeric($_GET['id']) )
{
die("The search identifier " . $_GET['id'] . " had errors.");
}
$id = $_GET['id'];
$query = "select news_mas.id, news_mas.location, news_mas.section, news_dtl.title, news_dtl.author, news_dtl.lead,
news_dtl.body, news_dtl.comments from news_mas, news_dtl where news_mas.id = '$id' and news_dtl.idx = '$id'";
$result = mysql_query($query);
$row = mysql_fetch_array($result);
$loc = $row['location'];
$sec = $row['section'];
?>
<div align="center">
<form method="post" action="edtscript.php?id=<?= $row['id']; ?>">
<table width="525" border="0" cellpadding="3" cellspacing="0" class="frmtable">
<tr>
<td height="25" colspan="3" nowrap></td>
</tr>
<tr>
<td width="77" height="26" align="right" nowrap><img src="../../images/location.jpg" width="77" height="20"></td>
<td width="460" valign="top" ><select name="<?= $loc; ?>" id="location">
<option value="XXX">Super Balita</option>
<? if($loc == "CDO"){ ?>
<option value="CDO" selected>Cag. de Oro</option> <? } else { ?>
<option value="CDO">Cag. de Oro</option> <? } ?>
<? if($loc == "CBU") { ?>
<option value="CBU" selected>Cebu</option> <? } else {?>
<option value="CBU">Cebu</option> <? } ?>
<? if($loc == "DVO") {?>
<option value="DVO" selected>Davao</option> <? } else {?>
<option value="DVO">Davao</option> <? } ?>
<? if($loc == "GSN") { ?>
<option value="GSN" selected>Gen. Santos</option> <? } else {?>
<option value="GSN">Gen. Santos</option> <? } ?>
</select>
</td>
<td width="1"></td>
</tr>
<tr>
<td height="26" nowrap><img src="../../images/section.jpg"></td>
<td valign="top" ><select name="<?= $sec ?>" id="section">
<option value="0">- - - - - - - - - - - - - - - -</option>
<? if($sec == 1) {?>
<option value="1" selected>Balita</option> <? } else {?>
<option value="1">Balita</option> <? } ?>
<? if($sec == 2) {?>
<option value="2" selected>Opinyon</option> <? } else {?>
<option value="2">Opinyon</option> <? } ?>
<? if($sec == 3) {?>
<option value="3" selected>Kalingawan</option> <? } else {?>
<option value="3">Kalingawan</option> <? } ?>
<? if($sec == 4) {?>
<option value="4" selected>Sports</option> <? } else {?>
<option value="4">Sports</option> <? } ?>
</select></td>
<td></td>
</tr>
<tr>
<td height="26" nowrap><img src="../../images/title.jpg"></td>
<td ><input name="title" type="text" class="frmarea" id="title" value="<?= $row['title']; ?>"></td>
<td></td>
</tr>
<tr>
<td height="26" nowrap><img src="../../images/author.jpg"></td>
<td ><input name="author" type="text" class="frmarea" id="author" value="<?= $row['author']; ?>"></td>
<td></td>
</tr>
<tr>
<td height="26" nowrap><img src="../../images/lead.jpg"></td>
<td rowspan="2" valign="top" ><textarea name="lead" cols="65" rows="3" class="frmarea" id="lead"><?= $row['lead']; ?></textarea></td>
<td rowspan="2"></td>
</tr>
<tr>
<td height="22" nowrap></td>
</tr>
<tr>
<td height="27" nowrap><img src="../../images/image.jpg"></td>
<td><input name="image" type="file" class="frmarea" id="image"></td>
<td></td>
</tr>
<tr>
<td height="26" nowrap><img src="../../images/caption.jpg" border="0"></td>
<td rowspan="2" valign="top" ><textarea name="caption" rows="3" class="frmarea" id="caption"></textarea></td>
<td rowspan="2"></td>
</tr>
<tr>
<td height="26" nowrap></td>
</tr>
<tr>
<td height="26" nowrap ><img src="../../images/body.jpg" border="0"></td>
<td rowspan="2" valign="top" ><textarea name="body" cols="65" rows="15" class="frmarea" id="body"><?= $row['body']; ?></textarea></td>
<td rowspan="2"></td>
</tr>
<tr>
<td height="182" nowrap></td>
</tr>
<tr>
<td height="61" valign="top" nowrap ><img src="../../images/comments.jpg"></td>
<td valign="top"><textarea name="comments" rows="4" class="frmarea" id="comments"><?= $row['comments']; ?></textarea></td>
<td></td>
</tr>
<tr>
<td height="37"></td>
<td ><table width="100%" border="0" cellpadding="3" cellspacing="0">
<tr>
<td width="69" height="31" ><input name="cmdEdt" type="submit" class="btun" id="cmdEdt" value="Update"></td>
<td width="69" ><input name="cmdCancel" type="submit" class="btun" id="cmdCancel" value="Cancel"></td>
<td width="130"> </td>
<td width="75" valign="top"><input name="cmdRet" type="submit" class="btun" id="cmdRet" value="Return"></td>
<td width="69" ><input name="cmdReset" type="reset" class="btun" id="cmdReset" value="Reset"></td>
</tr>
</table></td>
<td></td>
</tr>
</table>
</form>
</div>
</BODY>
</HTML>Code: Select all
-edtscript.php
<?php
require("../../config.php");
conn_db($host, $user, $pass, $dbse);
if ( !isset($_GET['id']) || empty($_GET['id']) || !is_numeric($_GET['id']) )
{
die("The search identifier " . $_GET['id'] . " had errors.");
}
$id = $_GET['id'];
if($_POST['cmdEdt'])
{
$save = 0;
$location = trim($_POST['location']);
$section = trim($_POST['section']);
$title = trim($_POST['title']);
$author = trim($_POST['author']);
$lead = trim($_POST['lead']);
$body = trim($_POST['body']);
$comments = trim($_POST['comments']);
$date = date('m.d.y');
$query = "update news_mas, news_dtl
set news_mas.date = '$date', news_mas.location = '$location', news_mas.section = '$section',
news_dtl.section = news_mas.section, news_dtl.author = '$author', news_dtl.title = '$title'
news_dtl.lead = '$lead', news_dtl.body = '$body', news_dtl.comments = '$comments'
where news_mas.id = news_dtl.idx";
mysql_query($query);
$save = mysql_affected_rows();
if($save > 0)
{
header("Location: ../preview/article_list.php");
}else{
die("No affected row");
}
}
?>Code: Select all
$query = "update news_mas, news_dtl
set news_mas.date = '$date', news_mas.location = '$location', news_mas.section = '$section',
news_dtl.section = news_mas.section, news_dtl.author = '$author', news_dtl.title = '$title'
news_dtl.lead = '$lead', news_dtl.body = '$body', news_dtl.comments = '$comments'
where news_mas.id = news_dtl.idx";Code: Select all
$query = "update news_mas, news_dtl
set news_mas.date = '$date', news_mas.location = '$location', news_mas.section = '$section',
news_dtl.section = news_mas.section, news_dtl.author = '$author', news_dtl.title = '$title'
news_dtl.lead = '$lead', news_dtl.body = '$body', news_dtl.comments = '$comments'
where news_mas.id = news_dtl.idx AND news_mas.id='$id'";Code: Select all
AND news_mas.id='$id'Code: Select all
$query = "update news_mas, news_dtl
set news_mas.date = '$date', news_mas.location = '$location', news_mas.section = '$section',
news_dtl.section = news_mas.section, news_dtl.author = '$author', news_dtl.title = '$title'
news_dtl.lead = '$lead', news_dtl.body = '$body', news_dtl.comments = '$comments'
where news_mas.id = news_dtl.idx";
mysql_query($query);
$save = mysql_affected_rows();
if($save > 0)
{
header("Location: ../preview/article_list.php");
}else{
die("No affected row");
}Code: Select all
$query = "UPDATE news_mas, news_dtl SET
news_mas.date = '$date',
news_mas.location = '$location',
news_mas.section = '$section',
news_dtl.section = '$section', # changed this from news_mas.section to '$section'
news_dtl.author = '$author',
news_dtl.title = '$title', # Added a comma here (syntax issue)
news_dtl.lead = '$lead',
news_dtl.body = '$body',
news_dtl.comments = '$comments' #Added a space after this line (Syntax issue)
WHERE news_mas.id = news_dtl.idx";
if ( !$result = mysql_query($query) )
{
die("There was an error with the update query: " . mysql_error());
}
$save = mysql_affected_rows($result);
if($save > 0)
{
header("Location: ../preview/article_list.php");
}
else
{
die("No affected row");
}Code: Select all
$query = "UPDATE news_mas, news_dtl SET
news_mas.date = '$date',
news_mas.location = '$location',
news_mas.section = '$section',
news_dtl.section = '$section', # changed this from news_mas.section to '$section'
news_dtl.author = '$author',
news_dtl.title = '$title', # Added a comma here (syntax issue)
news_dtl.lead = '$lead',
news_dtl.body = '$body',
news_dtl.comments = '$comments' #Added a space after this line (Syntax issue)
WHERE news_mas.id = news_dtl.idx";Code: Select all
$query = "Update news_mas, news_dtl Set
news_mas.date = '$date',
news_mas.location = '$location',
news_mas.section = '$section',
news_dtl.section = '$section',
news_dtl.author = '$author',
news_dtl.title = '$title',
news_dtl.lead = '$lead',
news_dtl.body = '$body',
news_dtl.comments = '$comments' Where news_mas.id = news_dtl.idx
And news_mas.id = '$id'"; # <- Added ChangeCode: Select all
header("Location: ../preview/article_list.php");