Page 1 of 1

[Solved] Image/text on load help.

Posted: Tue Jul 11, 2006 9:42 am
by Addos
Hi,
I have a page here http://www.jlp.ie/past_events.php where I’d need the last ‘More’ “Calyx Charity Concert 2005 – November 2005” information to display on the right. For example this page http://www.jlp.ie/future_events.php does exactly what I want. I don’t know why the first page won’t display anything when the page loads and I’m not too sure how to go about making the last entry in the database appear. Both pages of code seem to be the same and below is the code from the first page above. Can anyone help me out and possibly tell me why one loads an image/text on the right and the other doesn’t?

Thanks
Brian

Code: Select all

<?php require_once('****/jpl.php'); ?>
<?php
$colname_GetNewsDetails = "1";
if (isset($_GET['id'])) {
  $colname_GetNewsDetails = (get_magic_quotes_gpc()) ? $_GET['id'] : addslashes($_GET['id']);
}
mysql_select_db($*****, $jpl);
$query_GetNewsDetails = sprintf("SELECT * FROM future_events WHERE id = %s", $colname_GetNewsDetails);
$GetNewsDetails = mysql_query($query_GetNewsDetails, $jpl) or die(mysql_error());
$row_GetNewsDetails = mysql_fetch_assoc($GetNewsDetails);
$totalRows_GetNewsDetails = mysql_num_rows($GetNewsDetails);

mysql_select_db($*****, $jpl);
$query_GetNewsFuture = "SELECT id, heading, live FROM future_events ORDER BY sort ASC";
$GetNewsFuture = mysql_query($query_GetNewsFuture, $jpl) or die(mysql_error());
$row_GetNewsFuture = mysql_fetch_assoc($GetNewsFuture);
$totalRows_GetNewsFuture = mysql_num_rows($GetNewsFuture);

 // Details of image 1 Main page 
if (isset($row_GetNewsDetails['img']) && file_exists('images/'.$row_GetNewsDetails['img'])) {
  $image_info_1 = getimagesize('images/'.$row_GetNewsDetails['img']);
   }
    $dims_1 = isset($image_info_1) ? $image_info_1[3] : '';


?>
<body>

    <?php echo $row_GetNewsFuture['heading']; ?></td>
    <a href="past_events.php?id=<?php echo $row_GetNewsFuture['id']; ?>"><img src="images/more.jpg" alt="Read More" width="34" height="13"></a>

 <?PHP }; ?> <?php } while ($row_GetNewsFuture = mysql_fetch_assoc($GetNewsFuture)); ?>
  
<?php if ($dims_1) { echo $row_GetNewsDetails['heading']; ?>

	 <img src="images/<?php echo $row_GetNewsDetails['img']; ?>" alt=""  <?php echo $dims_1; ?> /> <?PHP } ?>
	    
		<?php echo nl2br($row_GetNewsDetails['details']);  ?>

Posted: Tue Jul 11, 2006 10:46 am
by MarK (CZ)
Seems to be simply because there's no entry with id '1'.

You could do this by
a)

Code: Select all

SELECT id FROM future_events ORDER BY time DESC
to get the id of the most recent event (instead of setting '1' on line 3)

b)

Code: Select all

SELECT * FROM future_events ORDER BY time DESC
to get directly the last entry.

Replace the `time` column with something similar you have there (something that rises with every entry).

Posted: Tue Jul 11, 2006 1:02 pm
by Addos
Thanks very much this is sorted now!
Brian