Jump to content

Two SQL Queries, one seems to be causing problems.


Merdok

Recommended Posts

I guys,

 

Its been a while since I've posted in here but I've recently started working with an MSSQL database and there are some slight differences to MySQL which I've not quite got my head around. Below is a page script that I'm using to display page content in an admin area.

 

I also want to display two fields again in the sidebar, I had a fair amount of difficulty in getting the sidebar content to display at all... now I seem to have reached a point where it will only display the last row in the database.

 

I've been trying to figure out what i've been doing wrong for 2 days, it seems that none of the coders in my company can help either so I turn to you guys.

 

Any ideas what i've messed up?

 

<?php 
// Begin SEO
$title = 'Amteus PLC || Help and Support Site || Welcome';
$keywords = 'Amteus, Enki, Support, Media Buzz';
$description = 'Amteus Help and support site';
$robots = 'index, follow';
//End SEO

$featurebar = 0; // If set to '0' the feature bar will not be displayed on a page
$parent_id = 0; // Tells the page which navigation section to highlight (0 turns highlighting off)
$pageID = 0; // Tells the page which content to pull from the database (0 indicates static content page)
$subnavID = '<ul><li><a href="#">Manage pages</a></li></ul>'; //Contains the content for the subnav bar. ( setting to NULL disables bar)
require_once("includes/head.php"); //includes the head tags
include_once("includes/header.php"); // includes the page header

//if delete has been clicked delete the requested ID
if(isset($_GET['delete']))
{
   $dberase = "DELETE FROM global_content WHERE globalID = '{$_GET['delete']}'";
   odbc_exec($conn,$dberase);
}
?>

<!-- javascript confirm deletion of article -->
<script language="JavaScript">
function delete_a_tron(side_ID)
{
   if (confirm("Are you sure you want to delete this entry?'"))
   {
      window.location.href = 'index.php?delete=' + side_ID;
   }
}
</script>
<?php $side_SQL = 'SELECT * FROM global_content';
$sidebar = odbc_exec($conn,$side_SQL); 
while (odbc_fetch_row($sidebar))
{  	

	$side_ID=odbc_result($sidebar,"globalID");
	$sidetitle=odbc_result($sidebar,"short_title");
}

$sql="SELECT * FROM global_content WHERE globalID = '{$_GET['pageID']}'";
$result=odbc_exec($conn,$sql);
while (odbc_fetch_row($result))
{
  		$globalID=odbc_result($result,"globalID");
	$pageID=odbc_result($result,"pageID");
	$short_title=odbc_result($result,"short_title");
  		$header=odbc_result($result,"header1");
	$header2=odbc_result($result,"header2");
	$bodytext=odbc_result($result,"bodytext");
	$datestamp=odbc_result($result,"date_created");
	}
	?>
        
        	
<div id="sidebar">
<div class="box">
	<h1 class="header"><span class="text">Page List</span></h1>
<div id="box_content">
<table class="admin-list" width="100%">

	<tr>
		<td><a href="global_view.php?pageID=<?php echo $side_ID ?>"><?php echo $sidetitle ?></a></td>   
		<td width="20px"><a href="global_edit.php?pageID=<?php echo $side_ID ?>"><img src="../elements/admin-edit.png" alt="Edit Page" /></a></td>   
		<td width="20px"><a href="javascript:delete_a_tron('<?php echo $side_ID ?>')">
			<img src="../elements/admin-delete.png" alt="Delete Page"/></a>
		</td>
	</tr>
	<tr><td colspan="3" class="background"><td></tr>

</table>
</div>
</div>
</div>
  <h1 class="body"><?php echo $header ?></h1>
  <?php if($header2) { ?>
  <h2> <?php echo $header2 ?> </h2> <?php } 
  echo $bodytext
  ?>
  
  <p><strong>Page ID Number:</strong> <?php echo $pageID ?></p>
  <p><strong>Date Created:</strong> <?php echo $datestamp ?></p>
<?php
include_once("includes/footer.php"); ?>

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.