Hi,
I've had a look through the forum(s), however, can't seem to find a solution to my issue (and I don't understand the PHP Manual).
Basically, got a website linked to a database, trying to pull data from one table and display onto the website where appropriate.
I have the following code:
<?php
include "console/include/code/common.php";
//Connect to Database
DBConnect();
$Link = mysql_connect(dbhost,user,password);?>
$Query = "SELECT * FROM database.tablename WHERE eventDay=1";
$Result = mysql_query ($Query, $Link) or die (mysql_error($Link));
//ON Debugging - code stops here resulting in Resource ID #3 - suggesting there is a problem
with the $Result. However, please check the following code to see if there are errors (if poss).
$Rows=mysql_num_rows($Result) or die (mysql_error($Rows));
$loop=0;
while ($loop<$Rows){
//Add all variables to the output loop.
$eventVisible=mysql_result($Result,$loop,"eventVisible");
$eventDay=mysql_result($Result,$loop,"eventDay");
$eventImagePath=mysql_result($Result,$loop,"eventImagePath");
$eventTitle=mysql_result($Result,$loop,"eventTitle");
$eventInfo=mysql_result($Result,$loop,"eventInfo");
$expiryYear=mysql_result($Result,$loop,"expiryYear");
$expiryMonth=mysql_result($Result,$loop,"expiryMonth");
$expiryDay=mysql_result($Result,$loop,"expiryDay");
//Print out the values into a table
}
if($eventVisible==1){
//EVENT VISIBLE
date_default_timezone_set('Europe/London');
if(mktime() < mktime(23,59,59,$expiryMonth,$expiryDay,$expiryYear)) {
//Event is before expiry?>
<img src="<?php echo $eventImagePath;?>" width="160" height="160" style="float:left"/> <p><b><?php echo $eventTitle;?></b><p><font color="#000"><?php echo $eventInfo;?></font>
<?php }; ?>
<?php };?>
<br clear="all">
<br>
<?php
//Increment the loop by 1 - so we actually get to an end!
$loop++;
//};?>
</div>
This code is for one tab - there are 6, so i simply copy the code, and change the query based on the tab that's selected.
As you can probably tell, I've tried to cut down and explain the code as much as possible - any questions though, feel free to ask.