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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

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

Post 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
Last edited by Celauran on Thu Jul 31, 2014 7:18 am, edited 2 times in total.
Reason: Use syntax tags. Please.
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

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

Post 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.
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

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

Post 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?
User avatar
Celauran
Moderator
Posts: 6427
Joined: Tue Nov 09, 2010 2:39 pm
Location: Montreal, Canada

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

Post 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?
jonnyfortis
Forum Contributor
Posts: 462
Joined: Tue Jan 10, 2012 6:05 am

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

Post 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
Post Reply