PHP multi select quote script - php

I did something like this :
devis2.php
<script type="text/javascript" src="quote_validation2.js"></script>
<?php
$ddcount = 1;
foreach ($_POST as $key => $value) {
$$key = $value;
}
If (isset($_POST['garment_type']) && $ddcount == 1) {
$post_to = "devis2-resultats.php";
$ddcount = $ddcount + 1;
} Else {
$post_to = "devis2.php";
}
?>
<div style="float:right; display: block;"><img style="border: none;" border="0" src="images/quote-again.gif" width="120" height="16" /></div><br/><br/>
<form name="instantquote" onSubmit="return validator(this)" method="post" action="<?php echo $post_to; ?>">
Au bac:<br/><select multiple size="3" name="garment_type" class="quoteFields" tabindex="1">
<?php
If (isset($_POST['garment_type'])) {
echo "<option value=\"$garment_type\" selected>$garment_type</option> \n";
} Else {
echo "<option value=\"0\" selected>Choisir un soin</option> \n";
}
?>
<option value="soin1">soin1</option>
<option value="soin2">soin2</option>
</select><br/>Longueur des cheveux*:<br/>
<select name="colors_back" class="quoteFields" tabindex="5" size="1" onChange="Javascript:document.instantquote.submit()" >
<?php
If (isset($_POST['colors_back'])) {
echo "<option value=\"$colors_back\" selected>$colors_back</option> \n";
} Else {
echo "<option value=\"0\" selected>Choisir une longueur</option> \n";
}
?>
<option value="+ de 25 cm">+ de 25 cm</option>
<option value="- de 25 cm">- de 25 cm</option>
</select>
<input type="hidden" name="ddcount" value="<?php echo $ddcount; ?>">
<br/><br/><input type="submit" value="Obtenir votre devis" name="quote" class="quoteSubmit" tabindex="20">
</form>
devis2-resultats.php
<?php
foreach ($_POST as $key => $value) {
$$key = $value;
}
include("quote-prices2.php");
?>
<br/><br/><b>Au bac:</b> <?php echo $garment_type; ?><br/><br/>
<?php
If (!isset($_POST['ind_numbers'])) {
} Else {
?>
Individual Numbers:<?php echo $ind_numbers; ?><br/><br/>
<?php
}
If (!isset($_POST['ind_names'])) {
} Else {
?>
Individual Names: <?php echo $ind_names; ?><br/><br/>
<?php
}
If (!empty($email)) { ?>
<br/><br/><b>Envoyé à:</b> <?php echo $email; ?><br/><br/>
<?php
}
?>
<br/><br/><div style="font-size:16px; background-color:#fff; color:#bf3d71;"> <b>Total:</b> <?php $dectotal = sprintf('%0.2f', $total); echo $dectotal; ?> $</div><br/><br/><br>
quote-prices2.php
<?php
// INCOMING VARIABLES FOR PROCESSING: garment_type, garment_color, quantity, colors_front, colors_back, ind_numbers, ind_names
// GARMENT TYPE PRICE
$flash_charge = 0;
switch ($garment_type) {
case "soin1":
$price_garment_type = 6.00;
break;
case "soin2":
$price_garment_typea = 7.00;
break;
}
if ($_POST['garment_type'] === 'soin2') {
switch ($colors_back) {
case "+ de 25 cm":
$price_garment_typea = $price_garment_typea + 50;
break;
}}
$total_garment_pricing = $price_garment_type + $price_garment_typea;
$total_additionals = $total_garment_pricing;
$total = $total_garment_pricing + $total_additionals;
$per_garment_price = $total/2;
$total = $total/2;
?>
**quote_validation2.js**
function validator(form) {
if (form.colors_back.value == 0) {
alert("Vous devez sélectionner une longueur de cheveux.");
return false;
}
return true;
}
function CalcKeyCode(aChar) {
var character = aChar.substring(0,1);
var code = aChar.charCodeAt(0);
return code;
}
function checkNumber(val) {
var strPass = val.value;
var strLength = strPass.length;
var lchar = val.value.charAt((strLength) - 1);
var cCode = CalcKeyCode(lchar);
/* Check if the keyed in character is a number
do you want alphabetic UPPERCASE only ?
or lower case only just check their respective
codes and replace the 48 and 57 */
if (cCode < 48 || cCode > 57 ) {
var myNumber = val.value.substring(0, (strLength) - 1);
val.value = myNumber;
}
return false;
}
I'am very bad at php developement. At this point if I select soin1 & soin2 it display one price only. soin1 = 6 & soin2 = 7 if they are both selected I'd like to obtain 13 as a result. And of course if soin1,soin2 & + de 25 cm are selected I'd like to obtain 63 as a result. The question is how can I make multi select work to obtain the addition of soin1 & soin2. See the script here.

Related

How can I show the output vertically after submitting the html form?

The who;e sequence(having operands , opertors and answer) in output is generating randomly which is perfect. but I want to show that in vertical manner
and this is the output I want to show after clicking on generate
then Q(2)will show up in the same way but after Q(1).
this is my html form.
<form action="" method="POST">
<div class="row">
<div class="col-25">
<label for="qnum">Select no.of questions:</label>
</div>
<div class = "col-75"><input type="number" id="qnum" name="que" value="1" min="1" max="100"></div>
<br /><br />
</div>
<br />
<div class="row">
<div class="col-25">
<label for="int">How many numbers You want in a sequence:</label></div>
<div class="col-75">
<select name="select" id="int">
<option value="2"> 2 </option>
<option value="3"> 3 </option>
<option value="4"> 4 </option>
<option value="5"> 5 </option>
<option value="6"> 6 </option>
<option value="7"> 7 </option>
<option value="8"> 8 </option>
<option value="9"> 9 </option>
<option value="10"> 10 </option>
</select>
</div>
</div>
<br />
<div class="row">
<div class="col-25">
<label for="dig">Select no. of digits:</label></div>
<div class="col-75">
<select name="digits" id="dig">
<option value="1"> 1 digit</option>
</select>
</div>
<br /><br /><br /><br />
</div>
<div class="row">
<div class="col-25"><label>Select operations:</label><br /></div>
<div class="col-75">
<input type="checkbox" id="mix" value="all" class="toggle-button"><label>All</label>
<input type="checkbox" id="add" name="operation[]" value="Addition" checked><label>Addition</label>
<input type="checkbox" id="sub" name="operation[]" value="Subtraction"><label>Subtraction</label>
<input type="checkbox" id="mult" name="operation[]" value="Multiplication"><label>Multiplication</label>
<input type="checkbox" id="div" name="operation[]" value="Division"><label>Division</label>
</div>
<br /><br />
<br /><br />
</div><br />
<input type="submit" name="submit" value="Generate"><br>
<br />
</form>
</div>
<!---Toggle button to select all operations if user select checkbox named "All" -->
<script language="JavaScript">
$( '.col-75 .toggle-button' ).click( function () {
$( '.col-75 input[type="checkbox"]' ).prop('checked', this.checked)
})
</script>
Basically I generating a random sequence of arithmetic expressions which is working perfectly without any error.
But after clicking generate button the output is showing horizontally and I want to generate it vertically.
So how can I do that?
Below is my php code which is generating the sequence perfectly without any error. How can I generate the output vertically?
<?php
error_reporting(E_ALL & ~E_NOTICE);
if(isset($_POST['submit']))
{
//validation for no of operation selected
$operation = $_POST['operation'];
if(empty($operation))
{
echo "Please Select at least one operation <br/>";
}
else
{
$N = count($operation); //count selected operation
echo "<br />";
echo "You have selected $N operation(s):";
for($i=0; $i < $N; $i++) //for loop for for operator array.
{
echo($operation[$i] . ", "); //display selected operation
}
echo "<br />";
//checkbox operations
if($N==1) //if only one operation is selected
{
if($operation[0]=='Addition')
{
$rOperators = array('+');
}
else if($operation[0]=='Subtraction')
{
$rOperators = array('-');
}
else if($operation[0]=='Multiplication')
{
$rOperators = array('*');
}
else
{
$rOperators = array('/');
}
}
else if ($N==2) //if only two operations are selected by the user
{
if($operation[0]=='Addition')
{
if($operation[1]=='Subtraction')
{
$rOperators = array('+','-');
}
else if($operation[1]=='Multiplication')
{
$rOperators = array('+','*');
}
else
{
$rOperators = array('+','/');
}
}
else if($operation[0]=='Subtraction')
{
if($operation[1]=='Multiplication')
{
$rOperators = array('-','*');
}
else
{
$rOperators = array('-','/');
}
}
else
{
$rOperators = array('*','/');
}
}
else if ($N==3) //if 3 operators gets selected by user
{
if($operation[0]=='Addition')
{
if($operation[1]=='Subtraction')
{
if($operation[2]=='Multiplication')
{
$rOperators = array('+','-','*');
}
else
{
$rOperators = array('+','-','/');
}
}
else
{
$rOperators = array('+','*','/');
}
}
else
{
$rOperators = array('-','*','/');
}
}
else
{
$rOperators = array('+','-','*','/');
}
}
//display sequence having only single digit numbers
if($_POST['digits'] == 1)
{
$q = $_POST['que'];
$previousInt = null; //Track the previous operand
$s = $_POST['select'];
for ($x = 1; $x<=$q; $x++) //for loop for no. of questions
{
$randomOperands = array();
$randomOperators = array();
// loop over $i n times
for ($i = 1; $i <=$s; $i++) //for loop for no. of integers user entered
{
$nextInt = rand(1, 9); // assign random operand to array slot
$randomOperands[] = $nextInt;
if($i < $s)
{
if($previousInt === 0) //No operator after last opearnd
{
//avoid division-by-zero
$randomOperators[] = $rOperators[rand(0, 2)];
}
else
{
$randomOperators[] = $rOperators[rand(0, $N-1)];
}
}
$previousInt = $nextInt;
}
// print array values
$exp = ''; //Generating the expression
foreach($randomOperands as $key=>$value1)
{
$exp .= $value1 . " " ;
if(isset($randomOperators[$key]))
{
$exp .= $randomOperators[$key] ." ";
}
}
$res = eval("return ($exp);");//evaluate the expression
//print expression
echo ("This is Q(".$x."):"), $exp."=". $res."<br>";
}
}
}
?>
Modify the code in which you are generating the expression which you are using as the input to the eval() function. Create another string say $output_string which can be used to output your answer. In this newly created string use proper HTML tags along with the generated string, for formatting it the way you want your output to look like.
It should look something like this:
$exp = ''; //Generating the expression
$output_string = ''; // new string which can be used for generating the output string
foreach ( $randomOperands as $key => $value1 ) {
$exp .= $value1 . " " ;
$output_string .= $value1 . " <br>" ;
if ( isset($randomOperators[$key]) ) {
$exp .= $randomOperators[$key] ." ";
$output_string .= $randomOperators[$key] ." <br> ";
}
}
$res = eval("return ($exp);");//evaluate the expression
//print expression
echo ("This is Q(".$x."): <br>"), $output_string."= <br>". $res."<br>";

Dynamic table using Bootstrap3 is not working properly.

Table sorting and searching text filed is not working properly using bootstrap 3. I am basically developing a query builder and making a dynamic table of my data but table sorting and searching is not working properly. Data display accurately but the table sort and search text box do not display data.
<?php
ini_set( "display_errors", 0);
include "include.php";
include "connect_to_mysql.php";
$table='Genomics_data_ncbi';
$display = array();
$qu_mul="";
?>
<html>
<head>
<title>TODO supply a title</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script type="text/javascript">
function formValidation(form)
{
var ccc = document.getElementById("first_box").value;
if(ccc == "") {
alert("Please enter a keyword !!!");
return false;
}
}
var intTextBox=0;
//FUNCTION TO ADD TEXT BOX ELEMENT
function addElement()
{
intTextBox = intTextBox + 1;
var contentID = document.getElementById("content");
var newTBDiv = document.createElement("div");
newTBDiv.setAttribute("id","strText"+intTextBox);
newTBDiv.innerHTML = "<select name='op[]'><option value='and'>AND</option> <option value='or'>OR</option> </select><select name='fieldsi[]'><option value='all'>All Fields</option><option value='' align='center' style='background-color: #FFCCCC'>Genome Information</option><option value='Gene_id'>Gene_id</option><option value='Gene_name'>Gene_name</option><option value='Gene_product'>Gene_product</option><option value='Function_of_proteins'>Function_of_proteins</option><option value='Protein_id'>Protein_id</option><option value='Localization_of_proteins'>Localization_of_proteins</option><option value='Strain_id'>Strain_id</option></select><select name='fieldsi_op[]'><option value='like'>LIKE</option><option value='not like'>Not LIKE</option><option value='equal'>Equal to</option><option value='not_equal'>Not equal to</option><option value='='> = </option><option value='!='> != </option><option value='<='> <= </option><option value='>='> >= </option><option value='<'> < </option><option value='>'> > </option></select> <input type='text' id='" + intTextBox + "' name='keyword[]'>";
contentID.appendChild(newTBDiv);
}
//FUNCTION TO REMOVE TEXT BOX ELEMENT
function removeElement()
{
if(intTextBox != 0)
{
var contentID = document.getElementById("content");
contentID.removeChild(document.getElementById("strText"+intTextBox));
intTextBox = intTextBox-1;
}
}
</script>
<!--<staticContent>
<remove fileExtension=".woff" />
<mimeMap fileExtension=".woff" mimeType="application/x-font-woff" />
<remove fileExtension=".woff2" />
<mimeMap fileExtension=".woff2" mimeType="application/font-woff2" />
</staticContent>
<p>
<button type = "button" class = "btn btn-default">
<span class = "glyphicons-halflings-regular.eot"></span>
</button>
<button type = "button" class = "btn btn-default">
<span class = "glyphicons-halflings-regular.ttf"></span>
</button>
<button type = "button" class = "btn btn-default">
<span class = "glyphicons-halflings-regular.woff"></span>
</button>
<button type = "button" class = "btn btn-default">
<span class = "glyphicons-halflings-regular.svg"></span>
</button>
<link href="tablesort/css/glyphicons-halflings-regular.eot" rel="stylesheet">
<link href="tablesort/css/glyphicons-halflings-regular.ttf" rel="stylesheet">
<link href="tablesort/css/glyphicons-halflings-regular.woff" rel="stylesheet">
<link href="tablesort/css/glyphicons-halflings-regular.svg" rel="stylesheet">-->
<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">
<script src="tablesort/js/jquery-3.3.1.js" type="text/javascript"></script>
<script src="tablesort/js/jquery.dataTables.min.js" type="text/javascript"></script>
<script src="tablesort/js/dataTables.bootstrap.min.js" type="text/javascript"></script>
<link href="tablesort/css/bootstrap.min.css" rel="stylesheet" type="text/css"/>
<link href="tablesort/css/dataTables.bootstrap.min.css" rel="stylesheet" type="text/css"/>
<script>
$(document).ready(function() {
$('#example').DataTable();
} );
</script>
</head>
<br>
<br>
<br>
<br>
<font color="#3d4983" face="Verdana" size="3"><b>Query Builder</b></font>
<br>
<p align='justify'>Users may build complex queries using the logical operators 'AND' and 'OR'. Each sub-query can be built using other operators such as LIKE, NOT LIKE, EQUAL and NOT EQUAL TO while dealing with strings like
words or letters and =, !=, <=, >=, < and > while dealing with numerical values. The Query builder aids to the flexibility of performing search on a number of fields simultaneously.</p>
<br>
<form name='form1' action="<?=$_SERVER['PHP_SELF']; ?>" method='post' onsubmit="return formValidation(this);">
<select name='fieldsi[]'>
<option value='all'>All Fields</option>
<option value='' style="background-color: #FFCCCC">Gene Information</option>
<option value='Gene_id'>Gene id</option>
<option value='Gene_name'>Locus tag</option>
<option value='Gene_product'> Gene product</option>
<option value='Function_of_proteins'> Protein function</option>
<option value='Protein_id'> Protein ID</option>
<option value='Localization_of_proteins'> Localization of protein</option>
<option value='Strain_id'> Strain ID</option>
</select>
<select name='fieldsi_op[]'>
<option value='like'>LIKE</option>
<option value='not like'>Not LIKE</option>
<option value='equal'>Equal to</option>
<option value='not_equal'>Not equal to</option>
<option value='='> = </option>
<option value='!='> != </option>
<option value='<='> <= </option>
<option value='>='> >= </option>
<option value='<'> < </option>
<option value='>'> > </option>
</select>
<input type='text' name='keyword[]' id='first_box'>
<input type="button" onclick="addElement()" value="+"> <input type="button" onclick="removeElement()" value="-">
<div id="content" ></div>
<br>
<input type='submit' value='Search'>
</form>
<br>
<br>
<body>
<?php
$dbServerName = "abc";
$dbUsername = "abc";
$dbPassword = "abc";
$dbName = "abc";
// create connection
$conn = new mysqli($dbServerName, $dbUsername, $dbPassword, $dbName);
// check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$sql = "SHOW COLUMNS FROM $table";
if(isset($_POST['keyword'])){
$key = $_POST['keyword'];
$op = $_POST['op'];
$field = $_POST['fieldsi'];
$field_op = $_POST['fieldsi_op'];
for($i=0;$i<count($key);$i++){
$keyw = $key[$i];
$field_val = $field[$i];
$field_op_val = $field_op[$i];
if($i>0){
$j = $i-1;
$operate = $op[$j];
if($operate != 'not'){
if($field_val == 'all'){
$result = mysqli_query($conn,$sql);
$result1 = mysqli_query("SHOW COLUMNS FROM $table");
echo "$result1";
if (mysqli_num_rows($result) > 0)
{
$i=0;
while ($row = mysqli_fetch_array($result))
{
if($i==0)
{
$fi_name = $row[0];
$display["$fi_name"] = 0;
$qu_mul = $qu_mul.' '.$operate.' '."$fi_name $field_op_val '%$keyw%'";
}
else
{
$fi_name = $row[0];
$display["$fi_name"] = 0;
$qu_mul.=" or "."$fi_name $field_op_val '%$keyw%'";
}
$i++;
}
}
}
else{
$display["$field_val"] = 0;
if(!preg_match('/[like]/i', $field_op_val)){
$qu_mul = $qu_mul.' '.$operate.' '."$field_val $field_op_val $keyw";
}
else if(preg_match('/equal/i', $field_op_val)){
$qu_mul = $qu_mul.' '.$operate.' '."$field_val ='$keyw'";
}
else if(preg_match('/not_equal/i', $field_op_val)){
$qu_mul = $qu_mul.' '.$operate.' '."$field_val !='$keyw'";
}
else{
$qu_mul = $qu_mul.' '.$operate.' '."$field_val $field_op_val '%$keyw%'";
}
}
}
else{
$qu_mul = $qu_mul.' '."and $field_val not like '%$keyw%'";
}
}
else{
if($field_val == 'all'){
$result = mysqli_query("SHOW COLUMNS FROM $table");
if (mysqli_num_rows($result) > 0)
{
$i=0;
while ($row = mysqli_fetch_array($result))
{
if($i==0)
{
$fi_name = $row[0];
$display["$fi_name"] = 0;
if(!preg_match('/[like]/i', $field_op_val)){
$qu = "$fi_name $field_op_val $keyw";
}
else if(preg_match('/equal/i', $field_op_val)){
$qu = "$fi_name ='$keyw'";
}
else if(preg_match('/not_equal/i', $field_op_val)){
$qu = "$fi_name !='$keyw'";
}
else{
$qu = "$fi_name $field_op_val '%$keyw%'";
}
}
else
{
$fi_name = $row[0];
$display["$fi_name"] = 0;
if(!preg_match('/[like]/i', $field_op_val)){
$qu.=" or "."$fi_name $field_op_val $keyw";
}
else if(preg_match('/equal/i', $field_op_val)){
$qu.=" or "."$fi_name ='$keyw'";
}
else if(preg_match('/not_equal/i', $field_op_val)){
$qu.=" or "."$fi_name !='$keyw'";
}
else{
$qu.=" or "."$fi_name $field_op_val '%$keyw%'";
}
}
$i++;
}
}
}
else{
$display["$field_val"] = 0;
if(!preg_match('/[like]/i', $field_op_val)){
$qu = "$field_val $field_op_val $keyw";
}
else if(preg_match('/equal/i', $field_op_val)){
$qu = "$field_val ='$keyw'";
}
else if(preg_match('/not_equal/i', $field_op_val)){
$qu = "$field_val !='$keyw'";
}
else{
$qu = "$field_val $field_op_val '%$keyw%'";
}
}
}
}
$dis="";
$display["Gene_id"] = 0;
#echo "$display";
$display["Gene_name"] = 0;
$display["Gene_product"] = 0;
$display["Function_of_proteins"] = 0;
$display["Protein_id"] = 0;
#$display["Protein_sequence"] = 0;
#$display["Nucleotide_sequence"] = 0;
$display["Protein_length"] = 0;
$display["Localization_of_proteins"] = 0;
$display["Strain_id"] = 0;
$display["Source"] = 0;
foreach($display as $key => $value){
$dis = "$dis"."$key,";
#echo "$dis";
}
$dis = preg_replace("/,$/",'',$dis);
$qu_pre = "select $dis from $table where ";
$sql = "$qu_pre"."$qu"."$qu_mul";
$res = $conn->query("$sql") or die($conn->error);
#echo"<table border=1>";
$res_no = mysqli_num_rows($res);
if($res_no == 0){
"<font color='brown' size='4'><b>No Record Found in CRAB-DB coressponding to your keyword !!!</b></font><br><br><input type='button' value='Go Back' onClick='history.go(-1)'><br><br><br>";
}
else{
$tot_res = mysqli_num_rows($res);
echo "Total number of records = $tot_res";
echo '<br>';
#<!-- back working properly-->
echo "<input type='button' onClick='history.go(-1)' value='Back'><br><br>";
echo '<div style="padding:0px 0px 0px 0px;">';
$query = mysqli_query($conn, $sql);
#echo "<table cellspacing=\"1\" class=\"tablesorter\">";
#echo "<thead><tr>";
if (mysqli_num_rows($query)){
$headerRow = true;
while ($row = mysqli_fetch_assoc($query)){
if ($headerRow){
$headerRow = false;
echo '<table id="example" class="table table-striped table-bordered" style="width:100%">';
echo "<thead>";
echo "<tr>";
foreach (array_keys($row) as $header)
{
echo "<th align = left>$header</a></th>";
}
echo "</tr>";
echo "</thead>";
}
echo '<tbody>';
#echo "<tbody>";
echo "<tr>";
#echo "<td>";
foreach ($row as $value){
echo "<td>$value</td>";
}
echo "</td>";
echo "</tr>";
#echo '</tr>';
echo '</tbody>';
}
}
}
while($row=mysqli_fetch_array($res)){
for($i=0;$i<mysqli_num_fields($res);$i++){
$f_name = mysqli_field_name($res, $i);
$f_val = $row[$f_name];
if($f_name == 'Gene_name'){
print"<td>$f_val</td>";
print "<td><a href='#####.php?Gene_name=$f_val&type=Gene_name' title='Click to See Details' style='text-decoration: none;'>$f_val</a></td>";
}
else if($f_name == 'Gene_id'){
$c_id = $row['Gene_name'];
$res_pub = mysqli_query("select * from $table where Gene_name='$c_id'");
}
print "</th>";
}
}
}
echo "</table>";
echo "<tfoot>";
echo "<tr>";
foreach (array_keys($row) as $header)
{
echo "<th align = left>$header</a></th>";
}
echo "</tr>";
echo "</table>";
echo "</body>";
echo "</html>";
Your code uses relative links. Don't do that. Use Absolute links!
<script src="jquery-3.3.1.js" type="text/javascript"></script>
Depending which folder this script is in, it will look from there, and not the site root.
However, changing it to
<script src="/path/to/jquery-3.3.1.js" type="text/javascript"></script>
Will load it from the site root all the time! In the example I put /path/to/jquery.js, if your index.php is in the public folder, then i usually put js in a js folder, so the link would be /js/jquery-3.3.1.js

PHP keeping session logged on after link

I have written a page that displays a load of data from MySQL database and all works perfect EXCEPT that when i click the Home link (the title of the page) it logs out and i need to log back in, im probably missing something stupid or not doing something i need, code below
<?php
session_start();
?><title>Vend365 Monitor (Beta test)</title>
<h1><u>Vend 365 online monitor (Beta test)<p></p></u></h3>
<?php
require_once ("V365Connect.php");
//Following if 'update' is clicked
if (isset($_POST['lastseen'])){?><p>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 1px;
text-align: left;
}
</style>
<h1>Vend 'Last Seen' times: Page loaded at <?php echo date("d/m/Y G:i:s"); ?></h1>
<?php
$result1 = mysql_query("SELECT distinct customer FROM vends order by customer") or die(mysql_error());
while($row = mysql_fetch_assoc($result1))
{ echo '<table><th>';
?><font size = "5">Customer - '<?php echo $row[customer];?>'</font><?php
echo '</th>';
$result2 = mysql_query("SELECT * FROM vends where customer ='".$row[customer]."'") or die(mysql_error());
while($row1 = mysql_fetch_assoc($result2))
{
echo '<tr><td>';
?>Machine <b>'<?php echo $row1[machine];?>'</b> last seen online at <b>'<?php echo $row1[lastseen];?>'</b> running version <b>'<?php echo $row1[myversion];?>'</b><?php
$today = date("d/m/Y G:i:s");
$lastseentime = $row1[lastseen];
$diff = $today-$lastseentime;
if ($diff == "1"){
?><b> <font color = "red"> -- Last seen online yesterday</font></b> <?php ;}
if ($diff > "1"){
?> <b><font color = "red"> -- Last seen online BEFORE yesterday</font></b> <?php ;}
echo '</td></tr><p>' ;
}
}?></table>
<?php
}else{
if (isset($_POST['update'])){
if ($_POST['checkbox']=='checked'){
$isalive = 1;
} else {
$isalive = 0;
}
if ($_POST['checkbox1']=='checked'){
$hb800 = 1;
} else {
$hb800 = 0;
}
if ($_POST['checkbox2']=='checked'){
$hb1100 = 1;
} else {
$hb1100 = 0;
}
if ($_POST['checkbox3']=='checked'){
$hb1400 = 1;
} else {
$hb1400 = 0;
}
if ($_POST['checkbox4']=='checked'){
$hb1700 = 1;
} else {
$hb1700 = 0;
}
if ($_POST['checkbox5']=='checked'){
$gcmreboot = 1;
} else {
$gcmreboot = 0;
}
if ($_POST['checkbox6']=='checked'){
$emailreboot = 1;
} else {
$emailreboot = 0;
}
if ($_POST['checkbox7']=='checked'){
$hbgcm = 1;
} else {
$hbgcm = 0;
}
if ($_POST['checkbox8']=='checked'){
$hbemail = 1;
} else {
$hbemail = 0;
}
if ($_POST['checkbox9']=='checked'){
$edigcm = 1;
} else {
$edigcm = 0;
}
if ($_POST['checkbox10']=='checked'){
$ediemail = 1;
} else {
$ediemail = 0;
}
if ($_POST['checkbox11']=='checked'){
$reportgcm = 1;
} else {
$reportgcm = 0;
}
if ($_POST['checkbox12']=='checked'){
$reportemail = 1;
} else {
$reportemail = 0;
}
if ($_POST['checkbox13']=='checked'){
$pingmailgcm = 1;
} else {
$pingmailgcm = 0;
}
if ($_POST['checkbox14']=='checked'){
$pingmailemail = 1;
} else {
$pingmailemail = 0;
}
if ($_POST['checkbox15']=='checked'){
$internetgcm = 1;
} else {
$internetgcm = 0;
}
if ($_POST['checkbox16']=='checked'){
$internetemail= 1;
} else {
$internetemail = 0;
}
if ($_POST['checkbox17']=='checked'){
$sqlgcm = 1;
} else {
$sqlgcm = 0;
}
if ($_POST['checkbox18']=='checked'){
$sqlemail = 1;
} else {
$sqlemail = 0;
}
if ($_POST['checkbox19']=='checked'){
$backupgcm = 1;
} else {
$backupgcm = 0;
}
if ($_POST['checkbox20']=='checked'){
$backupemail = 1;
} else {
$backupemail = 0;
}
$sqlupdate = "update vends set isalive='".$isalive."',customer='".$_POST['customer']."',machine='".$_POST['machine']."',mailserver='".$_POST['smtp']."',emails='".$_POST['emails']."',gcm='".$_POST['gcm']."',hb800='".$hb800."',hb1100='".$hb1100."',hb1400='".$hb1400."',hb1700='".$hb1700."',sqlserver='".$_POST['sqlserver']."',sqlport='".$_POST['sqlport']."',sqlinstance='".$_POST['sqlinstance']."',sqldatabase='".$_POST['sqldatabase']."',sqlname='".$_POST['sqlname']."',sqlpassword='".$_POST['sqlpassword']."',rebootgcm='".$gcmreboot."',rebootemail='".$emailreboot."',hbgcm='".$hbgcm."',hbemail='".$hbemail."',edigcm='".$edigcm."',ediemail='".$ediemail."',reportgcm='".$reportgcm."',reportemail='".$reportemail."',mailpinggcm='".$pingmailgcm."',mailpingemail='".$pingmailemail."',internetgcm='".$internetgcm."',internetemail='".$internetemail."',sqlgcm='".$sqlgcm."',sqlemail='".$sqlemail."',backupgcm='".$backupgcm."',backupemail='".$backupemail."',lastseen='".$lastseen."' where mac='".$_SESSION['mac']."'";
mysql_query($sqlupdate) or die(mysql_error());?><h1>
--->Customer - <font color = blue><?php echo $_SESSION['customer'];?></font>
<br />
--->Machine - <font color = blue><?php echo $_SESSION['machine'];?></font>
<p>
<?php
echo "Request sent";
}
else
{
//First load screen to select customer when correct details are entered
if (!isset($_POST['update'])){
if (!isset($_POST['customer'])){
if (!isset($_POST['machine'])){
if (isset($_POST['submit'])){
$result = mysql_query("SELECT * FROM users where user='".$_POST['user']."' and pass='".$_POST['pass']."'") or die(mysql_error());
$count = mysql_num_rows($result);
if ($count == 1){
?><p><p> <table style="border:1px solid black;"><tr><td><h1>Welcome '<?php echo $_POST['user'];?>'</td></tr></table><?php
$_SESSION['customer'];
$_SESSION['machine'];
$_SESSION['mac'];
if (!isset($_POST['customer'])) {
if (!isset($_POST['machine'])) {
echo "<h1><form action ='' method='post'>";
echo "Please Select Your Customer<br />";
$result1 = mysql_query("SELECT distinct customer FROM vends order by customer") or die(mysql_error());
echo "<select name='customer'>";
while($row = mysql_fetch_assoc($result1))
{
echo "<option value = '".$row[customer]."'>".$row[customer]."</option>";
}
echo "</select>";
echo "<input type='submit' value='Go'>";
echo "</form>";
echo "";
echo "Show all 'Last Seen' times";
?>
<form method='post'>
<input type='submit' value='Show Last Seen Status' name ='lastseen' />
</form>
<?php
}
}}else {
// If wrong details entered
echo "Sorry, wrong username or password, please go back and try again";
}
} else {
// Following is first time load screen
?>
<!DOCTYPE HTML> <html>
<head>
<link rel="stylesheet" type="text/css" href="style-sign.css">
</head><h1>
<title>Vend 365 Monitor</title>
<body id="body-color">
<div id="Sign-In">
<fieldset style="width:30%">
<legend>LOG-IN HERE</legend>
<form method="POST"> User <br><input type="text" style="font-size: 30px;" name="user" size="20"><br> Password <br><input type="password" style="font-size: 30px;" name="pass" size="20"><br>
<input id="button" type="submit" style="font-size: 30px; "name="submit" value="Log-In"> </form> </fieldset>
</div>
</body>
</html>
<?php
}}}
} else {
}
?>
<?php
// Select a vending machine
if (!isset($_POST['submit'])){
if (isset($_POST['customer'])) {
$example = $_POST['customer'];
$_SESSION['customer'] = $example;
$result2 = mysql_query("SELECT * FROM vends where customer='".$example."'") or die(mysql_error());
?><h1>
<font color = black>--->Customer - <font color = blue><?php
echo $_SESSION['customer'];?><p></font></font><?php
echo "<form action ='' method='post'>";
echo "Please Select Your Machine<br />";
echo "<select name='machine'>";
while($row = mysql_fetch_assoc($result2))
{
echo "<option value = '".$row[machine]."'>".$row[machine]."</option>";
}
echo "</select>";
echo "<input type='submit' value='Go'>";
echo "</form>";
}}
// show all customer/machine info
if (isset($_POST['machine'])) {
$example1 = $_POST['machine'];
$_SESSION['machine'] = $example1;?>
<h1><font color = black>--->Customer - <font color = blue><?php
echo $_SESSION['customer'];?><br /></font></font><br /><font color = black>--->Machine - <font color = blue><?php
echo $_SESSION['machine']; ?><p><?php
$result3 = mysql_query("SELECT * FROM vends where customer='".$_SESSION['customer']."' and machine ='".$_SESSION['machine']."'") or die(mysql_error());
while ($rows = mysql_fetch_assoc($result3))
{
$tag1 = $rows['hb800'];
$checkedstatus1 = '';
if($tag1 == '1')
{
$checkedstatus1 = 'checked';
} else {
$checkedstatus1 = 'unchecked';
}?><font color = black><form method='post'>
0800 Heartbeat check - <input type='checkbox' value='checked' name='checkbox1' <?php echo $checkedstatus1; ?> />
<br /><?php
$tag2 = $rows['hb1100'];
$checkedstatus2 = '';
if($tag2 == '1')
{
$checkedstatus2 = 'checked';
} else {
$checkedstatus2 = 'unchecked';
}?>
1100 Heartbeat check- <input type='checkbox' value='checked' name='checkbox2' <?php echo $checkedstatus2; ?> />
<br />
<?php $tag3 = $rows['hb1400'];
$checkedstatus3 = '';
if($tag3 == '1')
{
$checkedstatus3 = 'checked';
} else {
$checkedstatus3 = 'unchecked';
}?>
1400 Heartbeat check - <input type='checkbox' value='checked' name='checkbox3' <?php echo $checkedstatus3; ?> />
<br />
<?php
$tag4 = $rows['hb1700'];
$checkedstatus4 = '';
if($tag4 == '1')
{
$checkedstatus4 = 'checked';
} else {
$checkedstatus4 = 'unchecked';
}?>
1700 Heartbeat check - <input type='checkbox' value='checked' name='checkbox4' <?php echo $checkedstatus4; ?> /><br />
<?php
$tag5 = $rows['rebootgcm'];
$checkedstatus5 = '';
if($tag5 == '1')
{
$checkedstatus5 = 'checked';
} else {
$checkedstatus5 = 'unchecked';
}?>
Send GCM when rebooted - <input type='checkbox' value='checked' name='checkbox5' <?php echo $checkedstatus5; ?> /><br />
<?php
$tag6 = $rows['rebootemail'];
$checkedstatus6 = '';
if($tag6 == '1')
{
$checkedstatus6 = 'checked';
} else {
$checkedstatus6 = 'unchecked';
}?>
Send email when rebooted - <input type='checkbox' value='checked' name='checkbox6' <?php echo $checkedstatus6; ?> /><br />
<?php
$tag7 = $rows['hbgcm'];
$checkedstatus7 = '';
if($tag7 == '1')
{
$checkedstatus7 = 'checked';
} else {
$checkedstatus7 = 'unchecked';
}?>
Heartbeat check GCM - <input type='checkbox' value='checked' name='checkbox7' <?php echo $checkedstatus7; ?> /><br />
<?php
$tag8 = $rows['hbemail'];
$checkedstatus8 = '';
if($tag8 == '1')
{
$checkedstatus8 = 'checked';
} else {
$checkedstatus8 = 'unchecked';
}?>
Heartbeat check Email - <input type='checkbox' value='checked' name='checkbox8' <?php echo $checkedstatus8; ?> /><br />
<?php
$tag9 = $rows['edigcm'];
$checkedstatus9 = '';
if($tag9 == '1')
{
$checkedstatus9 = 'checked';
} else {
$checkedstatus9 = 'unchecked';
}?>
EDI fail check GCM - <input type='checkbox' value='checked' name='checkbox9' <?php echo $checkedstatus9; ?> /><br />
<?php
$tag10 = $rows['ediemail'];
$checkedstatus10 = '';
if($tag10 == '1')
{
$checkedstatus10 = 'checked';
} else {
$checkedstatus10 = 'unchecked';
}?>
EDI fail check Email - <input type='checkbox' value='checked' name='checkbox10' <?php echo $checkedstatus10; ?> /><br />
<?php
$tag11 = $rows['reportgcm'];
$checkedstatus11 = '';
if($tag11 == '1')
{
$checkedstatus11 = 'checked';
} else {
$checkedstatus11 = 'unchecked';
}?>
Report fail GCM - <input type='checkbox' value='checked' name='checkbox11' <?php echo $checkedstatus11; ?> /><br />
<?php
$tag12 = $rows['reportemail'];
$checkedstatus12 = '';
if($tag12 == '1')
{
$checkedstatus12 = 'checked';
} else {
$checkedstatus12 = 'unchecked';
}?>
Report fail Email - <input type='checkbox' value='checked' name='checkbox12' <?php echo $checkedstatus12; ?> /><br />
<?php
$gcm = $rows[gcm];
$tag13 = $rows['mailpinggcm'];
$checkedstatus13 = '';
if($tag13 == '1')
{
$checkedstatus13 = 'checked';
} else {
$checkedstatus13 = 'unchecked';
}?>
Ping email server GCM - <input type='checkbox' value='checked' name='checkbox13' <?php echo $checkedstatus13; ?> /><br />
<?php
$tag14 = $rows['mailpingemail'];
$checkedstatus14 = '';
if($tag14 == '1')
{
$checkedstatus14 = 'checked';
} else {
$checkedstatus14 = 'unchecked';
}?>
Ping email server Email - <input type='checkbox' value='checked' name='checkbox14' <?php echo $checkedstatus14; ?> /><br />
<?php
$tag15 = $rows['internetgcm'];
$checkedstatus15 = '';
if($tag15 == '1')
{
$checkedstatus15 = 'checked';
} else {
$checkedstatus15 = 'unchecked';
}?>
Ping internet fail GCM - <input type='checkbox' value='checked' name='checkbox15' <?php echo $checkedstatus15; ?> /><br />
<?php
$tag16 = $rows['internetemail'];
$checkedstatus16 = '';
if($tag16 == '1')
{
$checkedstatus16 = 'checked';
} else {
$checkedstatus16 = 'unchecked';
}?>
Ping internet fail email - <input type='checkbox' value='checked' name='checkbox16' <?php echo $checkedstatus16; ?> /><br />
<?php
$tag17 = $rows['sqlgcm'];
$checkedstatus17 = '';
if($tag17 == '1')
{
$checkedstatus17 = 'checked';
} else {
$checkedstatus17 = 'unchecked';
}?>
Failed SQL ping GCM - <input type='checkbox' value='checked' name='checkbox17' <?php echo $checkedstatus17; ?> /><br />
<?php
$tag18 = $rows['sqlemail'];
$checkedstatus18 = '';
if($tag18 == '1')
{
$checkedstatus18 = 'checked';
} else {
$checkedstatus18 = 'unchecked';
}?>
Failed SQL ping email - <input type='checkbox' value='checked' name='checkbox18' <?php echo $checkedstatus18; ?> /><br />
<?php
$tag19 = $rows['backupgcm'];
$checkedstatus19 = '';
if($tag19 == '1')
{
$checkedstatus19 = 'checked';
} else {
$checkedstatus19 = 'unchecked';
}?>
Backup fail GCM - <input type='checkbox' value='checked' name='checkbox19' <?php echo $checkedstatus19; ?> /><br />
<?php
$tag20 = $rows['backupemail'];
$checkedstatus20 = '';
if($tag20 == '1')
{
$checkedstatus20 = 'checked';
} else {
$checkedstatus20 = 'unchecked';
}?>
Backp fail email - <input type='checkbox' value='checked' name='checkbox20' <?php echo $checkedstatus20; ?> /><br />
<u><b><p>Details</b></u><p>
<?php $_SESSION['mac'] = $rows[mac]; ?>
Mac address - '<?php echo $_SESSION['mac']; ?>'<br />
Customer name - '<?php echo $rows[customer]; ?>'<br />
Machine name - '<?php echo $rows[machine]; ?>'<br />
Current version - '<?php echo $rows[myversion]; ?>'<br />
GCM app code - <input type='text' value='<?php echo $gcm; ?>' size=150 rows=4 name='gcm' />......<br />
SMTP server - '<?php echo $rows[mailserver]; ?>'<br />
Email addresses (seperate by commas) - '<?php echo $rows[emails]; ?>'<br /><p>
<u><b>SQL Credentials</b></u><p>
SQL server - '<?php echo $rows[sqlserver]; ?>'<br />
SQL Port - '<?php echo $rows[sqlport]; ?>'<br />
SQL Instance - '<?php echo $rows[sqlinstance] ?>'<br />
SQL Database - '<?php echo $rows[sqldatabase]; ?>'<br />
SQL User name - '<?php echo $rows[sqlname]; ?>'<br />
SQL Password - '<?php echo $rows[sqlpassword]; ?>' <br /><p>
<p>
<u><b>Alive status</u></b><p>
Last seen online - '<?php echo $rows[lastseen]; ?>'<br />
<?php
$tag = $rows['isalive'];
$checkedstatus = '';
if($tag == '1')
{
$checkedstatus = 'checked';
} else {
$checkedstatus = 'unchecked';
}?>
Request 'IsAlive' status - <input type='checkbox' value='checked' name='checkbox' <?php echo $checkedstatus; ?> /> - This will send a GCM and Email if alive.<p>
<input type='submit' value='Update account details' name ='update' /><p>
</form><p>
<?php
}}}}
?>

multiple - same name radio

I'm starting to make a little quiz page, where there are 3 choices opportunities. I here by to find out about what it is right,
Html
<p><input type="radio" name="svar[1]"><?php echo $svar1;?></p>
<p><input type="radio" name="svar[2]"><?php echo $svar2;?></p>
<p><input type="radio" name="svar[3]"><?php echo $svar3;?></p>
Php
if($_POST["svar"][1] == $ok)
{
$_POST["rigtigok"] = 1;
}
elseif($_POST["svar"][2] == $ok)
{
$_POST["rigtigok"] = 1;
}
elseif($_POST["svar"][3] == $ok)
{
$_POST["rigtigok"] = 1;
}
what I would like it / it must be outward is $ok is true with what comes from the database
if it shows like this:
$_POST["svar"][3] == $ok
then it will at the same time the $ok = 3
then it will also say that the content fits with what is being clicked by radio contents.
My Content from the database looks like this:
<form action="#" method="post">
<?php
if ($stmt = $this->mysqli->prepare('SELECT id, title, svar1, svar2, svar3, ok FROM quiz ORDER BY RAND() LIMIT 1')) {
$stmt->execute();
$stmt->bind_result($id, $title, $svar1, $svar2, $svar3, $ok);
while ($stmt->fetch()) {
?>
<h3><?php echo $title;?></h3>
<div style="padding:5px 10px;">
<p><input type="radio" name="svar[1]"><?php echo $svar1;?></p>
<p><input type="radio" name="svar[2]"><?php echo $svar2;?></p>
<p><input type="radio" name="svar[3]"><?php echo $svar3;?></p>
</div>
<?php
if(isset($_POST["ok"]))
{
if($_POST["svar"][1] == $ok)
{
$_POST["rigtigok"] = 1;
}
elseif($_POST["svar"][2] == $ok)
{
$_POST["rigtigok"] = 1;
}
elseif($_POST["svar"][3] == $ok)
{
$_POST["rigtigok"] = 1;
}
}
}
$stmt->close();
} else {
echo 'Der opstod en fejl i erklæringen: ' . $this->mysqli->error;
}
?>
<br/>
<input type="submit" name="ok" value="Nyt Spørgsmål" class="new upload_boxxen">
</form>
<?php
echo print_r($_POST["svar"]);
if(isset($_POST["ok"]))
{
if($_POST["rigtigok"] == 1)
{
echo "test";
}
}
EDIT
How it is that I do not get anything out of $_POST["rigtigok"] to be the first me later that I can give my 3 points for his correct answer?

php session vars

I'm working on news archive page for my website, search over archive is done with start date, end date and news category as search parameters. Form values are stored in $_SESSION var, and then they are passed around as an array for pagination and other purposes.
My question would be how to prevent displaying search results on main archive search page if user for some reason goes again to it to make a new search.
here's the code
<?php
session_start();
if (isset($_POST['submit'])) {
//get data from the form
$archFld_1 = $_POST['archiveFld1'];
$archFld_2 = $_POST['archiveFld2'];
$archFld_3 = $_POST['archiveFld3'];
//just some check on fields
if (strlen($archFld_1) > 10) { $archFld_1 = ""; }
if (strlen($archFld_2) > 10) { $archFld_2 = ""; }
//save them as a array and store to session var
$_archValues = array($archFld_3, $archFld_1, $archFld_2);
$_SESSION['storeValues'] = $_archValues;
}
if (isset($_SESSION['storeValues'])) {
//check params for search
//set cat for query
if ($_SESSION['storeValues'][0] > 0) { $valCat = "AND newsCat=". $_SESSION['storeValues'][0] ." "; } else { $valCat = ""; }
//set date for query
if(($_SESSION['storeValues'][1] != "" ) && ($_SESSION['storeValues'][2] == "")) {
$DateStart = $_SESSION['storeValues'][1];
$valDate = " AND STR_TO_DATE(newsDate, '%d-%m-%Y') >= STR_TO_DATE('$DateStart', '%d-%m-%Y') ";
}
if(($_SESSION['storeValues'][2] != "") && ($_SESSION['storeValues'][1]=="")) {
$DateEnd = $_SESSION['storeValues'][2];
$valDate = " AND STR_TO_DATE(newsDate, '%d-%m-%Y') <= STR_TO_DATE('$DateEnd', '%d-%m-%Y') ";
}
if(($_SESSION['storeValues'][1]!="") && ($_SESSION['storeValues'][2] != "")) {
$DateStart = $_SESSION['storeValues'][1];
$DateEnd = $_SESSION['storeValues'][2];
$valDate = " AND STR_TO_DATE(newsDate, '%d-%m-%Y') BETWEEN STR_TO_DATE('$DateStart', '%d-%m-%Y') AND STR_TO_DATE('$DateEnd', '%d-%m-%Y') ";
}
//query string and stire it to session
$archQuery_string = $valCat.$valDate;
$_SESSION['storeQuery'] = $archQuery_string;
}
//pagination start
$page = $_GET['id'];
$perPage = 10;
$result = wbQuery("SELECT * FROM wb_news WHERE newsLang=1 ". $_SESSION["storeQuery"] ."ORDER BY newsId DESC");
$totalPages = mysql_num_rows($result);
if(!$page)
$page = 1;
$start = ($page - 1)*$perPage;
?>
<div id="sps_middle">
<div class="sps_cnt">
<div id="sps_middle_ly1">
<div class="sps_cnt_small">
<div class="sps_page_title"><h3><?php echo $wb_lng['txtArchiveTitle']; ?></h3></div>
<div class="sps_pages_cnt" style="padding-top: 10px; float: left; margin-bottom: 15px;">
<div class="sps_middle_col01">
<div style="float: left;">
<p>
<?php echo $wb_lng['txtArchiveInfo']; ?>
</p>
<form action="<?php $PHP_SELF; ?>" method="post" name="archiveForm" class="archiveForm">
<ul>
<li>
<input name="archiveFld1" type="text" id="archiveFld1" value="<?php echo $wb_lng['txtArhivaFld_01']; ?>" />
<input name="archiveFld2" type="text" id="archiveFld2" value="<?php echo $wb_lng['txtArhivaFld_02']; ?>" />
<select name="archiveFld3">
<option value="0"><?php echo $wb_lng['txtArhivaFld_07']; ?></option>
<option value="0" ><?php echo $wb_lng['txtArhivaFld_06']; ?></option>
<option value="1"><?php echo $wb_lng['txtArhivaFld_03']; ?></option>
<option value="2"><?php echo $wb_lng['txtArhivaFld_04']; ?></option>
<option value="3"><?php echo $wb_lng['txtArhivaFld_05']; ?></option>
</select>
</li>
<li style="float: right;">
<input name="reset" type="reset" class="sps_archiveform_btn" value="<?php echo $wb_lng['txtArchiveFormReset']; ?>"/>
<input name="submit" type="submit" class="sps_archiveform_btn" value="<?php echo $wb_lng['txtArchiveFormSend']; ?>"/>
</li>
</ul>
</form>
</div>
<hr />
<?php
if (#HERE GOES SOME CODE TO PERFORM THE CHECK!!!#) {
//perform db query
$result = wbQuery("SELECT * FROM wb_news WHERE newsLang=1 ". $_SESSION['storeQuery'] ."ORDER BY newsId DESC LIMIT $start, $perPage");
//count rows
$totalnews = mysql_num_rows($result);
$count = 1;
if($totalnews == 0) {
//no results, say to the user
echo "\t\t\t<div class=\"cil_news_text_big\">\n\t\t\t\t".$wb_lng['txtArchiveNoEntries']."\n\t\t\t</div>\n";
} else {
//we have results, yeeeeeeeeey
while($ROWnews = mysql_fetch_object($result)){
//set link extensions by the news cat
switch ($ROWnews->newsCat) {
case 1:
$newsCat_link = "news";
break;
case 2:
$newsCat_link = "statements";
break;
case 3:
$newsCat_link = "events";
break;
}
//text summary
if (strlen($ROWnews->newsShort) > 0 ) {$newsShortTxt = strip_tags($ROWnews->newsShort);
if ($lang_id==2) { $newsShortTxt = wbTranslit($newsShortTxt); }
} else {
$newsShortTxt = strip_tags($ROWnews->newsFull);
if ($lang_id==2) { $newsShortTxt = wbTranslit($newsShortTxt); }
}
$newsShortTxt = wbShorTxt($newsShortTxt, 210, "... <a title=\"".$wb_lng['txtShowMore']."\" href=\"http://".$_SERVER['HTTP_HOST']."/".$lang_link."/".$newsCat_link."/".$ROWnews->newsId."/full/\">".$wb_lng['txtShowMore']."...</a>");
//show news
echo "\t\t<div class=\"sps_news_list\">\n";
echo "\t\t<div class=\"sps_news_l\">\n";
echo "\t\t\t<img alt=\"\" src=\"http://".$_SERVER['HTTP_HOST']."/content/images/news/_thumb/".$ROWnews->newsImageThumb."\" />\n";
echo "\t\t</div>";
echo "\t\t<div class=\"sps_news_r\">\n";
//transliterate title
if ($lang_id==2) { $newsTitle = wbTranslit($ROWnews->newsTitle); } else { $newsTitle = $ROWnews->newsTitle; }
echo "\t\t\t<div class=\"sps_news_title\">\n\t\t\t\t<a title=\"".$newsTitle."\" href=\"http://".$_SERVER['HTTP_HOST']."/".$lang_link."/".$newsCat_link."/".$ROWnews->newsId."/full/\">".$newsTitle."</a>\n\t\t\t</div>\n";
echo "\t\t\t<div class=\"sps_news_date\">\n\t\t\t\t".$ROWnews->newsDate."\n\t\t\t</div>\n";
echo "\t\t\t<div class=\"sps_news_text_sh\">\n\t\t\t\t".$newsShortTxt."\n\t\t\t</div>\n";
echo "\t\t</div>";
echo "\t\t</div>";
//show <hr /> based on $count
if($totalnews != $count) { echo "\t\t\t<hr />\n"; }
$count++;
}
}
//pagination check
if($totalPages>$perPage) {
?>
<hr />
<div class="sps_pagginate">
<?PHP wbPageTurnFront($PHP_SELF."/".$lang_link."/archive/", $totalPages, $page, $perPage); ?>
</div>
<?php
}
}
?>
Any ideas?
Tnx :)
If user goes to make it a new search then you can clear the session at that time.
unset($_SESSION['storeValues']);

Categories