//or and allows to link to url if clicked on, if $url is specified. //also allows for row seperation by color depend of value of $i(0 or 1). if ($i == 0) { $outputString = 'onmouseover="this.style.backgroundColor=\''.ROLLOVER_OVER.'\'" onmouseout="this.style.backgroundColor=\''.ROLLOVER_EVEN.'\'" onClick="location=\''.$url.'\'"'; } else { $outputString = 'onmouseover="this.style.backgroundColor=\''.ROLLOVER_OVER.'\'" onmouseout="this.style.backgroundColor=\''.ROLLOVER_ODD.'\'" onClick="location=\''.$url.'\'"'; }; return $outputString; } function connectDb($user, $pass, $host, $db) { //this function connects to a mysql server $sock = mysql_connect($host, $user, $pass) or die("Could not connect : " . mysql_error()); //this function connects to a mysql database, once a server has been reached. if(isset($sock)) { if(!mysql_select_db($db, $sock)) { echo mysql_error(); } } return $sock; } $socket = connectDb('kartkekc','2akmvhjd','localhost','kartkekc_db'); $sql = "SELECT * FROM WEB_USER"; //$query = "SELECT * FROM CIRCUIT"; $query = mysql_query($sql, $socket) or die("Query failed : " . mysql_error()); //$result = mysql_query($query) or die("Query failed : " . mysql_error()); $browser = $_SERVER["HTTP_USER_AGENT"]; /* Session */ require 'db/db_connect.php'; // require our database connection // which also contains the check_login.php // script. We have $logged_in for use. // color and font options to be set on all pags require 'php/style.php'; // Initiliaze html stuff (from style.php) echo $html_body; if ($logged_in == 0) { //kirjautuminen epäonnistui echo "$html_font_heading"."KART-KEKET SUOJATTU SIVU"."$html_font_heading_end"; echo "

\n"; echo ''; //ohje echo ""; echo "
$html_font_normal"."Tämä sivu vaatii kirjautumisen."."$html_font_normal_end
$html_font_normal"."Kirjaudu yläpalkista ja yritä linkkiä uudelleen."."$html_font_normal_end
"; echo $html_body_end; exit; } session_start(); if(isset($_SESSION["username"])) { echo "Welcome to our site!\n"; } else { echo "You are not logged in!\n"; } echo "k a r t - k e k e t\n"; /* roll over*/ define("ROLLOVER_OVER", "#3C5561"); define("ROLLOVER_EVEN", "#3C5571"); define("ROLLOVER_ODD","#E2E2E2"); echo ''; //for($count = 0; $count < 11; $count++) { // echo ''; // echo ''; // echo ''; //} echo '
blah blah
'; echo "

\n"; /* Printing results in HTML */ echo "\n"; echo "\t\n"; echo "\t\t\n"; echo "\t"; echo "\t\n"; echo "\t\t\n"; echo "\t"; echo "
$browser
Tämä tavara tulee MFIA tietokannasta
\n"; echo "
\n"; echo "\n"; $s=0; //show all the data via a while loop while($data = mysql_fetch_assoc($query)) { if ($s == 0) { $i=0; $s=1; } else { $s=0; $i=1; } if(!$column){ echo "\t\n"; //using foreach, list all columns that was returned in the $data array from mysql_fetch_assoc foreach($data as $key => $value) { echo "\t\t\n"; } echo ''; $column=1; } //echo "\t\n"; echo ''; //using foreach, list all the data that was returned in the $data array from mysql_fetch_assoc foreach($data as $key => $value) { //echo $key.' = '.$value.'
'; echo "\t\t\n"; } echo ''; } echo "
$key
$value
\n"; /* Printing results in HTML echo "\n"; while ($line = mysql_fetch_array($result, MYSQL_ASSOC)) { echo "\t\n"; foreach ($line as $col_value) { echo "\t\t\n"; } echo "\t\n"; } echo "
$col_value
\n"; */ echo "\n"; /* Free resultset */ mysql_free_result($query); /* Closing connection mysql_close($sock); */ ?>