Page 1 of 1

php query not returning a value of site built in code codeig

Posted: Thu Jul 31, 2014 7:06 am
by jonnyfortis
having an issue build a news detail page (newsarticle.php)
the orginal site was built in codeigniter and am just adding a couple of other pages one being a news detail page. the trouble is the news detail page is not displaying any records. the link from the news list is call the correct newsID.

the news list page

Code: Select all

<?php
mysql_select_db($database_ab, $ab);
$query_rsNews = "SELECT * FROM antontBattyNews WHERE newsDate LIKE '%2014%' ORDER BY newsID DESC";
$query_limit_rsNews = sprintf("%s LIMIT %d, %d", $query_rsNews, $startRow_rsNews, $maxRows_rsNews);
$rsNews = mysql_query($query_limit_rsNews, $ab) or die(mysql_error());
$row_rsNews = mysql_fetch_assoc($rsNews);
 
        <?php do { ?>
         <?php echo $row_rsNews['newsDate']; ?><dt><strong>
          <?php echo $row_rsNews['newsTitle']; ?></strong><br>
         </dt>
         <dd><?php echo TrimByLength($row_rsNews['newsDesc'], 100, true); ?><a href="newsarticle?newsID=<?php echo $row_rsNews['newsID']; ?>">Read More</a></dd>
         <?php } while ($row_rsNews = mysql_fetch_assoc($rsNews)); ?>

I know there isnt an extension at the end of the newsarticle (newsarticle.php) this is intentional (something with the framework)

and newsarticle (newsarticle.php)

Code: Select all

<?php
  $colname_rsNews = "-1";
if (isset($_GET['newsID'])) {
  $colname_rsNews = $_GET['newsID'];
}
mysql_select_db($database_ab, $ab);
$query_rsNews = sprintf("SELECT * FROM antontBattyNews WHERE newsID = %s", GetSQLValueString($colname_rsNews, "int"));
$rsNews = mysql_query($query_rsNews, $ab) or die(mysql_error());
$row_rsNews = mysql_fetch_assoc($rsNews);
$totalRows_rsNews = mysql_num_rows($rsNews);
  ?>
         <p><?php echo $row_rsNews['newsDate']; ?></p>
         <p><?php echo $row_rsNews['newsTitle']; ?><br>
         <?php echo $row_rsNews['newsDesc']; ?></p>
any help would be appreciated
thanks

Re: php query not returning a value of site built in code co

Posted: Thu Jul 31, 2014 7:24 am
by Celauran
You really ought to be doing this inside CI. Use the ORM over raw SQL calls and the MVC pattern to keep your presentation and business logic separate. If you aren't familiar with either of those, working on this site presents the ideal opportunity to learn. Look at other controller actions if you're getting stuck.

Re: php query not returning a value of site built in code co

Posted: Thu Jul 31, 2014 7:33 am
by jonnyfortis
Celauran wrote:You really ought to be doing this inside CI. Use the ORM over raw SQL calls and the MVC pattern to keep your presentation and business logic separate. If you aren't familiar with either of those, working on this site presents the ideal opportunity to learn. Look at other controller actions if you're getting stuck.
ok i really need to get familar with CI, so i take it there is no quick fix for this issue whilst i am learning the correct way?

Re: php query not returning a value of site built in code co

Posted: Thu Jul 31, 2014 8:48 am
by Celauran
Learning the basics shouldn't take long at all (i.e., you'll be done and have this solved before the end of today). Which version of CI is this built against? Is news its own entity? Is there a news model and controller?

Re: php query not returning a value of site built in code co

Posted: Thu Jul 31, 2014 9:07 am
by jonnyfortis
Celauran wrote:Learning the basics shouldn't take long at all (i.e., you'll be done and have this solved before the end of today). Which version of CI is this built against? Is news its own entity? Is there a news model and controller?
i will find out these answers then post the answers
thanks