1

answers

0

votes

Vote

business in Business Channel,
Written by: beeky on Jul 28 2012, 9:43am

Using databases with WebEasy 9

I want to re-design a simple website I use for our charity. Part of the current site uses an SQL database to show activities going on a daily basis. It also uses tables in the database to populate fields with member information etc. Is there a tutorial which shows how I can create fields on the web page and attach data to them via say cpanel. At present I use a php wrapping to "include" various aspects I want visable to users of the site. For example this code:

<?php

//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
or die("Unable to connect to MySQL");
//echo "Connected to MySQL<br>";

//select a database to work with
$selected = mysql_select_db("eachfrie_Events",$dbhandle)
or die("Could not select eachfrie_Events");
/// query db and loop through rows example

//use the ternary operator to find the year from the post value or set it to the current year
$year = (is_numeric((int)$_POST['year'])) ? ((int)$_POST['year']) : date("Y");

$info1 = "Please select a financial year from the drop down box to display the programme year required:";


$query = mysql_query("SELECT * FROM tblEvents WHERE FinancialYear =$year ORDER BY EventDate;") or die(mysql_error());
//$query = mysql_query("SELECT * FROM tblEvents WHERE FinancialYear =$year ORDER BY EventDate;");
//$query = mysql_query("SELECT * FROM tblEvents WHERE FinancialYear =2010 ORDER BY EventDate;");

//$table = "<table border=\"1\">\n";
$table = "<form method=post><table border=\"1\" cellspacing=\"10\" body bgcolor=\"#AABBCC\" Align=Center>\n";
$tableHead = "<tr>
<th>Event</th>
<th>Location</th>
<th>Status</th>
<th>Type of Event</th>
<th>Date</th>
<th>Start Time</th>
<th>End Time</th>
<th>Coordinator</th>
<th>Comments</th>
<th>Funds Raised</th>
<th>Financial Year
<select name='year' onchange='form.submit();'>
<option>2009</option>
<option>2010</option>
<option>2011</option>
<option>2012</option>
<option>2013</option>
<option>2014</option>
<option>2015</option>
<option>2016</option>
<option>2017</option>
<option>2018</option>
<option>2019</option>
<option>2020</option>
</select>
</th>
</tr>\n";

while($row = mysql_fetch_array($query)){

$tablerow .= "<tr>
<td>".$row['eventname']."</td>
<td>".$row['eventlocation']."</td>
<td>".$row['eventstatus']."</td>
<td>".$row['eventtype']."</td>
<td>".$row['eventdate']."</td>
<td>".$row['starttime']."</td>
<td>".$row['endtime']."</td>
<td>".$row['coordinator']."</td>
<td>".$row['comments']."</td>
<td>".$row['fundsraised']."</td>
<td>".$row['financialyear']."</td>
</tr>\n";
}
$tableEnd = "</table></form>\n";
?>

retrieves event data from the database and generates a table to show the associated records. Can I do this as an insert between the HTML code fragments or is this not possible. If I can't use databases with WebEasy it is of little or no benefit to me. Can anyone help please?

1 Citizens Answers

Arthur K. says:

Hello Beeky,

Unfortunately, WebEasy does not create databases or work with databases. It is a front-end template based html page builder.
You can try using the HTML CODE FRAGMENT feature to insert php coding, however I do not believe it would work.
You would also need to change the html file type of the document from .htm to php if I am not mistaken.

0

Votes

Vote
Jul 30 2012, 11:26am | Report

Post your comment

default Avatar

You might be interested in these related contributions