I am trying to fetch results from Mysql database to several textboxes.
Here is my code that prints the results.
This page is called api2.php
How can I direct and print each row result into spesific texbox. in my index.php
<?php
include 'db.php';
$return_arr = array();
$fetch = mysql_query("SELECT * FROM user");
while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
$row_array['1'] = $row['name'];
$row_array['2'] = $row['name2'];
$row_array['3'] = $row['name3'];
$row_array['4'] = $row['name4'];
$row_array['5'] = $row['name5'];
array_push($return_arr,$row_array);
}
echo json_encode($return_arr);
?>
index.php needs to get the results on load from database (api.php) and disable textbox. The post part to database is ok
<!DOCTYPE html>
<html lang="en">
<head><meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)">
<meta name="created" content="tir, 03 mar 2015 17:47:17 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<meta http-equiv="refresh" content="" >
<title>Vin lotteri</title>
<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="main">
<form id="myForm" action="userInfo.php" method="post">
<form method="get" id="form">
<center>
<h2>Vin lotteri</h2>
<br>
Velg nummer<br>
Skriv inn navnet ditt på di nummerene du ønsker<br>
Husk, kun 5 lodd pr. pers.<br><br>
<!-- javascript/jQuery -->
<script src="script/jquery-1.8.1.min.js" type="text/javascript"></script>
<script src="script/my_script.js" type="text/javascript"></script>
<div id="holder"></div>
</head>
<body>
<script>
$.getJSON( "api.php", function( data ) {
$.each( data, function( key, val ) {
$('#holder').append( "<input value='" + val + "' name='" + val + "'/>");
});
});
</script>
<style type="text/css">
.tg {border-collapse:collapse;border-spacing:0;}
.tg td{font-family:Arial, sans-serif;font-size:14px;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
.tg th{font-family:Arial, sans-serif;font-size:14px;font-weight:normal;padding:10px 5px;border-style:solid;border-width:1px;overflow:hidden;word-break:normal;}
</style>
<table class="tg">
<tr>
<th class="tg-031e">1</th>
<th class="tg-031e"><input type="text" name="l1" id="l1" /></th>
<th class="tg-031e">2</th>
<th class="tg-031e"><input type="text" name="l2" id="l2" /></th>
<th class="tg-031e">3</th>
<th class="tg-031e"><input type="text" name="l3" id="l3" /></th>
<th class="tg-031e">4</th>
<th class="tg-031e"><input type="text" name="l4" id="l4" /></th>
<th class="tg-031e">5</th>
<th class="tg-031e"><input type="text" name="l5" id="l5" /></th>
</tr>
</table>
<br>
<input type="submit" name="submit" id="submit" value="Neste" >
</form>
<span id="result"></span>
</div>
</div>
</body>
</html>
I have tried for days to get dta into my textbox with no luck.
As what I can see now I need a little help with one question:
I fetch from my database with this called api2.php:
<?php
//--------------------------------------------------------------------------
// 1) Connect to mysql database
//--------------------------------------------------------------------------
include 'db.php';
$return_arr = array();
$fetch = mysql_query("SELECT * FROM user");
while ($row = mysql_fetch_array($fetch, MYSQL_ASSOC)) {
$row_array['1'] = $row['name'];
$row_array['2'] = $row['name2'];
array_push($return_arr,$row_array);
}
echo json_encode($return_arr);
?>
Then I use getJSON to get in my index.php:
<script>
$.getJSON("api2.php", function (data) {
$.each(data, function (key, value) {
$('#l1').val();
$('#l2').val();
});
});
And then I want it to appear into textbox in index.php:
<input type="text" name="l1" id="l1" />
<input type="text" name="l2" id="l2" />
I see that I have to find the right value, but I dont know how.
$('#l1').val(???);
I tought it was something like: $('#l1').val(echo "'$name'")
Try this. I tested it and it works>
HTML (this html accommodates your needs)
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=euc-kr">
<meta name="generator" content="CoffeeCup HTML Editor (www.coffeecup.com)">
<meta name="created" content="tir, 03 mar 2015 17:47:17 GMT">
<meta name="description" content="">
<meta name="keywords" content="">
<meta http-equiv="refresh" content="">
<title>Vin lotteri</title>
<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<div class="container">
<div class="main">
<form id="myForm" action="userInfo.php" method="post">
<form method="get" id="form">
<center>
<h2>Vin lotteri</h2>
<br>
Velg nummer<br>
Skriv inn navnet ditt på di nummerene du ønsker<br>
Husk, kun 5 lodd pr. pers.<br><br>
<!-- javascript/jQuery -->
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script src="script/my_script.js" type="text/javascript"></script>
<div id="holder"></div>
</head>
<body>
<style type="text/css">
.tg {
border-collapse: collapse;
border-spacing: 0;
}
.tg td {
font-family: Arial, sans-serif;
font-size: 14px;
padding: 10px 5px;
border-style: solid;
border-width: 1px;
overflow: hidden;
word-break: normal;
}
.tg th {
font-family: Arial, sans-serif;
font-size: 14px;
font-weight: normal;
padding: 10px 5px;
border-style: solid;
border-width: 1px;
overflow: hidden;
word-break: normal;
}
</style>
<table class="tg">
<tr>
<th class="tg-031e">1</th>
<th class="tg-031e"><input type="text" name="l1" id="l1"/></th>
<th class="tg-031e">2</th>
<th class="tg-031e"><input type="text" name="l2" id="l2"/></th>
<th class="tg-031e">3</th>
<th class="tg-031e"><input type="text" name="l3" id="l3"/></th>
<th class="tg-031e">4</th>
<th class="tg-031e"><input type="text" name="l4" id="l4"/></th>
<th class="tg-031e">5</th>
<th class="tg-031e"><input type="text" name="l5" id="l5"/></th>
</tr>
</table>
<br>
<input type="submit" name="submit" id="submit" value="Neste">
</center>
</form>
<span id="result"></span>
</div>
</div>
<script>
$.getJSON("api.php", function (data) {
$.each(data, function (key, value) {
$('#l'+(key+1)).val(value);
});
});
</script>
</body>
</html>
Note: Please DO NOT use <center></center> is deprecated. Ypou can remove them yourself, if you want to.
JSON (This is just an dummy example) This code is for prove that it works.
<?php
header('Content-Type: application/json');
echo json_encode(array('jose','leandro','pedro'));
Related
I don't know how to modify the following code to make it upload multiple files by selecting once. By the following code I am able to upload one file at a time. Just wish to modify it as through this code not only I am uploading the file but also showing all the files uploaded, on the same page for download and delete.
<html>
<title>Brief upload</title>
<link href="globe.png" rel="shortcut icon">
<?php
date_default_timezone_set("Asia/Calcutta");
//echo date_default_timezone_get();
?>
<?php
$conn=new PDO('mysql:host=localhost; dbname=deu', 'root', '') or die(mysql_error());
if(isset($_POST['submit'])!=""){
$name=$_FILES['photo']['name'];
$size=$_FILES['photo']['size'];
$type=$_FILES['photo']['type'];
$temp=$_FILES['photo']['tmp_name'];
$date = date('Y-m-d H:i:s');
$caption1=$_POST['caption'];
$link=$_POST['link'];
move_uploaded_file($temp,"files/".$name);
$query=$conn->query("INSERT INTO upload (name,date) VALUES ('$name','$date')");
if($query){
header("location:index.php");
}
else{
die(mysql_error());
}
}
?>
<html>
<body>
<link href="css/bootstrap.css" rel="stylesheet" type="text/css" media="screen">
<link rel="stylesheet" type="text/css" href="css/DT_bootstrap.css">
<link rel="stylesheet" type="text/css" href="css/font-awesome.css">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="font-awesome/css/font-awesome.min.css"/>
</head>
<script src="js/jquery.js" type="text/javascript"></script>
<script src="js/bootstrap.js" type="text/javascript"></script>
<script type="text/javascript" charset="utf-8" language="javascript" src="js/jquery.dataTables.js"></script>
<script type="text/javascript" charset="utf-8" language="javascript" src="js/DT_bootstrap.js"></script>
<?php include('dbcon.php'); ?>
<style>
.table tr th{
border:#eee 1px solid;
position:relative;
#font-family:"Times New Roman", Times, serif;
font-size:12px;
text-transform:uppercase;
}
table tr td{
border:#eee 1px solid;
color:#000;
position:relative;
#font-family:"Times New Roman", Times, serif;
font-size:12px;
text-transform:uppercase;
}
#wb_Form1
{
background-color: #00BFFF;
border: 0px #000 solid;
}
#photo
{
border: 1px #A9A9A9 solid;
background-color: #00BFFF;
color: #fff;
font-family:Arial;
font-size: 20px;
}
</style>
<div class="alert alert-info">
Brief Uploading System
</div>
<table cellpadding="0" cellspacing="0" border="0" class="table table-bordered">
<tr><td><form enctype="multipart/form-data" action="" id="wb_Form1" name="form" method="post">
<!--<input type="file" name="photo[]" id="photo" multiple>-->
<input type="file" name="photo" id="photo" required="required"></td>
<td><input type="submit" class="btn btn-danger" value="SUBMIT" name="submit">
</form> <strong>SUBMIT HERE</strong></tr></td></table>
<div class="col-md-18">
<div class="container-fluid" style="margin-top:0px;">
<div class = "row">
<div class="panel panel-default">
<div class="panel-body">
<div class="table-responsive">
<form method="post" action="delete.php" >
<table cellpadding="0" cellspacing="0" border="0" class="table table-condensed" id="example">
<thead>
<tr>
<th>ID</th>
<th>FILE NAME</th>
<th>Date</th>
<th>Download</th>
<th>Remove</th>
</tr>
</thead>
<tbody>
<?php
$query=mysql_query("select * from upload ORDER BY id DESC")or die(mysql_error());
while($row=mysql_fetch_array($query)){
$id=$row['id'];
$name=$row['name'];
$date=$row['date'];
?>
<tr>
<td><?php echo $row['id'] ?></td>
<td><?php echo $row['name'] ?></td>
<td><?php echo $row['date'] ?></td>
<td>
<span class="glyphicon glyphicon-paperclip" style="font-size:20px; color:blue"></span></td>
<td>
<span class="glyphicon glyphicon-trash" style="font-size:20px; color:red"></span>
</td>
</tr>
<?php } ?>
</tbody>
</table>
</div>
</form>
</div>
</div>
</div>
</div>
</body>
</html>
You can upload multiple files in this way
Input field must be defined as an array i.e. images[]
It should be defined as multiple="multiple"
<input name="images[]" type="file" multiple="multiple" />
// Count # of uploaded files in array
$total = count($_FILES['images']['name']);
// Loop through each file
for( $i=0 ; $i < $total ; $i++ ) {
//Get the temp file path
$tmpFilePath = $_FILES['images']['tmp_name'][$i];
//Make sure we have a file path
if ($tmpFilePath != ""){
//Setup our new file path
$newFilePath = "./uploadFiles/" . $_FILES['images']['name'][$i];
//Upload the file into the temp dir
if(move_uploaded_file($tmpFilePath, $newFilePath)) {
//Handle other code here
}
}
}
For more details PHP Multiple Upload
I want to turn my table into a datatable so that user can read data displayed more easily and the I could add live filters to select only some type of datas. This is my code, I already wrote the code needed to make it possible.
Despite all, if the code is ran, the table isn't dinamic and doesn't turn into a datatable.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>FILTRARE PER GENE</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js" integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy" crossorigin="anonymous"></script>
</head>
<body>
<div>
<div id="holder">
<h1><?php echo "FILTRO PER GENE DELLE VARIANTI";?></h1></div>
<hr />
<br>
<div id="sidebar" style="width:50%">
NUOVA RICERCA
  |
DATI UTENTE
  |
HOME
<P> </P>
</div>
<input type="text" id="search" placeholder="Live Search...">
<BR>
<form action="filtro_per_gene_selezione_per_var_RICERCA_PAZ.php" method="POST">
GENE <select name="gene">
<option></option>
<option>CFH</option>
<option>CD46</option>
<option>CFI</option>
<option>CFB</option>
<option>C3</option>
<option>ADAMTS13</option>
<option>THBD</option>
<option>DGKE</option>
<input type='submit' name='vai' value'Invia'>
</form><BR /><BR />
<div class="container">
<div class="row">
<div class="col-mid-8 col-mid-offset-2">
<table class="table table-striped table-bordered table-hover">
<thead>
<tr>
<td width="9%"><b>RISULTATO</b></td>
<td width="9%"><b>dnaCode</b></td>
<td width="9%"><b>Chr</b></td>
<td width="9%"><b>Start</b></td>
<td width="9%"><b>End</b></td>
<td width="5%"><b>Alt</b></td>
<td width="5%"><b>Ref</b></td>
<td width="9%"><b>Zigosity</b></td>
<td width="9%"><b>Gene</b></td>
<td width="9%"><b>Func</b></td>
<td width="9%"><b>Gene Context</b></td>
<td width="9%"><b>Dist</b></td>
</tr>
</thead>
<tbody>
<?php
$conn= mysql_connect("local", "user", "pass");
if (!$conn)
{
die("Connessione non riuscita <br>" . mysql_error());
//}else{
//echo "Connessione al database stabilita con successo<br><br>";
}
mysql_select_db("database_var", $conn);
if(isset($_POST["vai"])){
$dna=$_POST["dna"];
}
$sql="SELECT V.dnaCode, V.Chr, V.Start, V.End, V.Alt, V.Ref, V.zygosity, A.gene, A.Func, A.GeneContext, A.Dist FROM variante as V JOIN annotazioni as A ON V.Start = A.Start AND V.Alt=A.Alt AND V.Ref=A.Ref WHERE V.dnaCode='" .$dna. "'";
$result_gene = mysql_query($sql, $conn) or die(mysql_error());
$record_gene=mysql_fetch_array($result_gene);
$index=1;
while ($record_gene=mysql_fetch_array($result_gene)){
echo '
<tr>
<b><td>'.$index.'</td></b>
<td>'.$record_gene['dnaCode'].'</td>
<td>'.$record_gene['Chr'].'</td>
<td>'.$record_gene['Start'].'</td>
<td>'.$record_gene['End'].'</td>
<td>'.$record_gene['Alt'].'</td>
<td>'.$record_gene['Ref'].'</td>
<td>'.$record_gene['zygosity'].'</td>
<td>'.$record_gene['gene'].'</td>
<td>'.$record_gene['Func'].'></td>
<td>'.$record_gene['GeneContext'].'</td>
<td>'.$record_gene['Dist'].'</td>
</tr>
';
++$index;
};
?>
</tbody>
</table>
</div>
</div>
</div>
<script
src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin="anonymous"></script>
<script type="text/javascript" src="file:///C|/xampp/htdocs/DB/js/jquery.dataTables.min.js"></script>
<script type="text/javascript" src="file:///C|/xampp/htdocs/DB/js/dataTables.bootstrap.min.js"></script>
<script>
$(document).ready(function(){
$('.table').DataTable();
});
</script>
</body>
</html>
This question already has answers here:
PHP parse/syntax errors; and how to solve them
(20 answers)
Closed 6 years ago.
Its working at first but when I re-edit it since it looks messy, the result is now error, can somebody please help me.
I think i already closed the braces and scripts, i dont know what's wrong with it.
<?php
session_start();
require("functions.php");
if(!isset($_GET['id'])&&isset($_SESSION['username'])) header("Location: ?id=".getId($_SESSION['username']));
?>
<!-- HEAD -->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>System of Account</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<!-- Meta, title, CSS, favicons, etc. -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" >
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" ></script>
<link rel="stylesheet" href="animate.css">
<link href="fonts/css/font-awesome.min.css" rel="stylesheet">
<link rel="shortcut icon" href="favicon.png">
<link href="css/animate.min.css" rel="stylesheet">
<link href="fonts/css/font-awesome.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css" media="print" href="print.css" />
<!--<link type="text/css" rel="stylesheet" href="styles.css" />-->
<style>
body{
margin: 0 auto;
background-image:url("../clsimages/GG.jpg");
background-repeat: no-repeat;
background-size: 100% 720px;
-webkit-background-size:cover;
-moz-background-size:cover;
-o-background-size:cover;
}
.container{
width: 65%;
height:615px;
background-color: rgba(52, 73, 94, 0.3);
margin-top: 50px;
border-radius:4px;
border: 2px solid black;
}
</style>
<style>
table{
float:left;
border: 1px solid ;
}
</style>
<style>
ul {
width: 70%;
margin: auto;
}
</style>
<style>
.div{
width: 250%;
}
.form-control{
border: 2px dashed #D1C7AC;
width: 230px;
color: #1E049E;
onfocus="this.value=''
font-weight: bold;
font-size: 18px;
font-family: "Times New Roman";
}
</style>
<script>
function printDiv(divID) {
//Get the HTML of div
var divElements = document.getElementById(divID).innerHTML;
//Get the HTML of whole page
var oldPage = document.body.innerHTML;
//Reset the page's HTML with div's HTML only
document.body.innerHTML =
"<nav>" +
divElements + "</nav>";
//Print Page
window.print();
//*Restore orignal HTML
// document.body.innerHTML = oldPage;
// window.location='print.php';
}
</script>
</head>
<!-- BODY -->
<body>
<div id="container">
<?php
if(!isset($_SESSION['username']))
{
?>
</br></br></br></br></br></br></br></br></br></br>
<center>
<font color="black"> <h2 class="form-signin-heading"> Please Login <i class="fa fa-sign-in"> </i></h2> </font>
</br></br>
<form action="authenticate.php" class="form-signin" method="POST">
<div class="input-group" style="margin-left:42%">
<span class="input-group-addon" id="basic-addon1">Username:</span>
<input type="text" name="username" class="form-control" style="width:23%; height: 40px;" required><br />
</div>
</br>
<div class="input-group" style="margin-left:42%">
<span class="input-group-addon" id="basic-addon1" >Password:</span>
<input type="password" name="password" id="inputPassword" class="form-control" placeholder="Enter Your Password" style="width:23%; height:40px;"required>
</div>
<br /> </br>
<button class="btn btn-lg btn-primary btn-block" type="submit" style="width:25%;"> Login <i class="fa fa-sign-in"> </i> </button>
</center>
</form>
<?php
if(isset($_GET["feedback"]))
echo $_GET["feedback"];
}
?>
<!-- NEXT PAGE -->
<?php
if(isset($_SESSION['username']))
{
$profileUsersData = getUsersData(mysql_real_escape_string($_GET['id']));
?>
<div id="menu">
<a class="button" href="logout.php">Logout</a>
</div>
<?php if(userExists(mysql_real_escape_string($_GET['id']))){ ?>
<!--Button print -->
<button class="btn btn-default" onclick="javascript:printDiv('printablediv')" class = "btn btn-success" ><i class="fa fa-print"> </i> <b> Print the fees</b></button>
<!-- End -->
<!--PRINT -->
<div class="" id="printablediv">
<p><img src="clsimages/STATEMENT.png"></p>
<div align="right">
<script>
var y = new Date();
var currentyear = y.getFullYear();
var nextyear= y.getFullYear() +1;
document.write("<p class='navbar-text pull-right'><font style = 'Impact' color = 'black'><h3> SY:<font color='blue'> "+ currentyear +"-"+ nextyear +" </h3></font></font></p>");
</script> </th>
</div>
<br>
<!-- Table -->
<table border='1' style='border-collapse:collapse; width:100%; border-bottom: hidden;'>
<col style='width:50%;'>
<tr>
<td>
<ul>
<p><font size='2%' face='Arial'> <b>
</br>
<?php
if(isset($_SESSION['username']))
{
$profileUsersData = getUsersData(mysql_real_escape_string($_GET['id']));
?>
<?php if(userExists(mysql_real_escape_string($_GET['id']))){ ?>
<div id="header">
<?php echo 'STUDENT NAME: '. $profileUsersData['LastName'].", ".$profileUsersData['FirstName']. " ".$profileUsersData['MiddleName'].""; ?>
</br></br>
<?php echo ' </br> LEVEL: '. $profileUsersData['Level'].""; ?>
</b>
</ul>
</td>
<td>
<ul>
<p><font size="2%" face="Arial"><b> TELEPHONE: (63 2) 834-2915
</br></br>
EMAIL: christianloveschool#yahoo.com
</p>
</b>
</ul>
</table>
<table border="1" style="border-collapse:collapse; width:100%;">
<col style="width:50%;">
<tr>
<td>
<ul>
<font size="2%" face="Arial">
<b>
<?php echo ' </br> DATE: '. $profileUsersData['TuitionDate'].""; ?>
<b>
</br>
<?php echo ' </br> TUITION FEE: '. $profileUsersData['Tuition'].""; ?>
</br> </br>
<?php echo ' </br> BOOKS: '. $profileUsersData['Books'].""; ?>
</br> </br>
<?php echo ' </br> SCHOOL/ PE UNIFORM: '. $profileUsersData['Uniform'].""; ?>
</br> </br>
<?php echo ' </br> OLD ACCOUNT: '. $profileUsersData['OldAcct'].""; ?>
</br>
</b>
</ul>
</td>
</font>
<td>
<font size="2%" face="Arial">
<ul>
<b>
<?php echo ' </br> BALANCE: '. $profileUsersData['Balance'].""; ?>
</b>
</ul>
</td>
</font>
</tr>
</table>
<?php } else echo "Invalid ID"; ?>
<?php } ?>
<!-- RULES OF PAYMENT -->
<table border="1" style="border-collapse:collapse; width:100%; border-top:hidden;">
<tr>
<td>
<font size="3%" face="Arial">
<ul>
<b><u>RULES ON PAYMENT:</u></b>
</font>
</br></br>
<font size="2%" face="Arial">
1. Tuition fee payment must be made every 5th day of the scheduled payment scheme. </br></br>
2.Payments should be made on time in order to take the exam needed. </br></br>
3. Reservations and Miscellaneous fees are non-refundable. </br></br>
4.A student who withdraws before the start of the school year shall be charged 50% on miscellaneous fee. </br></br>
5. A student who transfers or otherswise withdraws within two weeks after the beginning of classes and has already paid the
pertinent and other school fees in full may be charged to pay the whole amount of miscellaneous fees and the amount supposed tp be paid pertaining to tuition fee. </br></br>
6. A student who transfers or withdraws within two weeks after the beginning of classes and has not yet paid the pertinent
and other school fees shall be charged to pay the whole amount of miscellaneous fees in full and the amount supposed to be paid pertaining to tuition fee. </br></br>
7. A student who withdraws any time after the second week of classes, full payment of tuition and miscellaneous fees shall be charged. </br></br>
8. Discounts shall only be applied at the last payment. </br></br>
9. Any discounts granted will be forfeited if the payment is delayed. </br></br>
10. All fees should be paid in full before the end of the school year.
</font>
</br></br>
<hr></hr>
<br>
<table>
<font size="3%">
Any discount granted will be <b> forfeited </b> if the payment is delayed.
<br>
<u> <font color="red"> <b>
<br>
Bring this notice upon payment and have the Examination Permit validated from the office.
</font> </u>
</table>
</br></br>
<font color="blue" size="3%">
Contact the school if payment has been made, thank you.
</u> </font> </b>
</ul>
</table>
</td>
</tr>
</div>
</div>
</body>
</html>
The brackets of following if loops is not closed
if(isset($_SESSION['username'])){
<?php if(userExists(mysql_real_escape_string($_GET['id']))){ ?>
quote I think i already closed the braces - no you didn't.
your code contains 12 instances of { but only 10 instances of }. looks like 1 of the problems is that the brace on line 171 isn't closed, and there's probably 1 more somewhere
I have this code:
<?php require_once("config.inc.php"); ?>
<?
ob_start();
session_start();
if(isset($_SESSION['myusername'])) {
// do nothing here
} else { ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>Live chat</title>
</head>
<body bgcolor="#000000">
<font color="white" size="+3"><b>You are not logged in! <br />
Log in and start chatting!</b></font>
</body>
</html>
<?php exit(); }
ob_flush();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="description" content="<?php echo $meta_description ?>" />
<meta name="keywords" content="<?php echo $meta_keywords ?>" />
<title><?php echo $site_name; ?> | Live chat</title>
<link rel="icon" type="image/gif" href="favicon.png" >
<link href="style.css" rel="stylesheet" type="text/css" />
<style>
body { margin:0;padding:0; background-image:url(images/background.jpg); }
</style>
<script src="http://code.jquery.com/jquery-latest.js"></script>
<script>
$(document).ready(function() {
$("#lolmesazhet").load("mesazhetnechat.php");
var refreshId = setInterval(function() {
$("#lolmesazhet").load("mesazhetnechat.php");
}, 1000);
$.ajaxSetup({ cache: false });
});
</script>
</head>
<body>
<table width="100%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="500px" bgcolor="#000000" >
<?php include 'headerchat.inc.php'; ?>
</td>
</tr>
<tr>
<td width="500px" align="left" valign="top" style="padding:20px 5px 20px;">
<?php
if($_POST['submit654']) {
$result128 = mysqli_query($con,"SELECT id FROM users WHERE email = '$_SESSION[myusername]'");
$row128 = mysqli_fetch_array($result128);
date_default_timezone_set("Europe/Tirane");
$todaydate3 = date("Y-m-d H:i:s");
mysqli_query($con,"INSERT INTO chat (id, derguesi, dhoma, mesazhi, ora) VALUES (NULL, '$row128[id]', 'Main room', '$_POST[mesazhi]', '$todaydate3')");
}
?>
<table width="470px" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="50px" valign="middle" colspan="2" style="border-bottom:1px solid #FFFFFF;"> </td>
</tr>
<tr>
<td width="320" height="339px" valign="top" style="padding:3px;">
<div style="width:320px; height:339px; overflow-y:auto;">
<?php
$result73 = mysqli_query($con,"SELECT * FROM chat WHERE dhoma = 'Main room' ORDER BY id DESC");
while($row73 = mysqli_fetch_array($result73))
{
$result127 = mysqli_query($con,"SELECT username FROM users WHERE id = '$row73[derguesi]'");
$row127 = mysqli_fetch_array($result127);
?>
<table width="320px" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="150" align="left"><font color="white" size="4"><b><?php echo $row127['username']; ?></b></font></td>
<td width="170" align="right"><?php echo $row73['ora']; ?></td>
</tr>
<tr>
<td colspan="2">
<font color="white"><?php echo $row73['mesazhi']; ?></font>
</td>
</tr>
</table>
<?php } ?>
</div>
</td>
<td width="150" height="450px" rowspan="2" valign="top" style=" padding:3px; border-left:1px solid #FFFFFF;">
<div style="width:150px; height:450px; overflow-y:auto;">
<font color="#FFFFFF" size="+2"><b>Online users:</b></font><br /><br />
<?php
$result = mysqli_query($con,"SELECT username FROM users WHERE verifikuar='po' AND online = 'po'");
while($row = mysqli_fetch_array($result))
{ ?>
<font color="#FFFFFF"><b><?php echo $row['username']; ?></b></font> <br />
<?php }
?>
</div>
</td>
</tr>
<tr>
<td height="50px" valign="middle" style="border-top:1px solid #FFFFFF; padding:3px; border-right:1px solid #FFFFFF;">
<form action="" method="post" name="comesazh">
<textarea name="mesazhi" cols="35" rows="4" required="required"></textarea>
<br /><input type="submit" name="submit654" id="submit654" value="Send" style="border-radius:0px; border-size:1px; border-style:solid; border-color:#ffffff; border-width:thin; background-color:#000000; color:#ffffff; height:26px; width:60px; font-size:16px;" />
</form>
</td></tr>
</table>
</body>
</html>
I would like to know if it is possible to reload that page using ajax in order to create a live chat and if yes, how to do it.
I tried many ways like reloading just a part of it using $.load function but it does not work. Then I tried to $.load all the page, but still did not work. After a lot of silly efforts, I gave up.
Here is what you can do to have the chat box update without reloading the page.
Chat page that you have:
<script>
window.setInterval(function(){
{
var xmlhttp;
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.onreadystatechange=function()
{
if (xmlhttp.readyState==4 && xmlhttp.status==200)
{
document.getElementById("myDiv").innerHTML=xmlhttp.responseText;
}
}
xmlhttp.open("GET","response.php",true);
xmlhttp.send();
}, 5000);
</script>
<div id="myDiv"><h2>This should be your chat box</h2></div>
Response.php
<?php
//do the while loop for the amount of chat you want to see
//example
for ($i = 1; $i <= 10; $i++) {
echo $i.'<br/>'; // Print out $i
}
?>
This will update the chat box every 5 seconds with the most recent chats. Give it a shot
If no element is matched by the selector — in this case, if the document does not contain an element with id="result" — the Ajax request will not be sent.
From jQuery.load manual. I can't see element with ID "lolmesazhet" in your code. Or I'm missing something.
A few days ago, I asked a question regarding folding div ([link text][fold-unfold div]). The answers I got allowed me to make good progress in my coding effort. However, my requirements have changed.
Being a newbie with all this web stuff, I though that wrapping the divs with a table and table headers would be easy. Boy, was I wrong.
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Animate my Div</title>
<style type="text/css" media="screen">
a {text-decoration: none; color: black; }
#expand {background-color: #fff;}
.description {display: none; }
.entry {margin: 0; padding: 0px;}
</style>
<script src="jquery-1.3.2.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$(".entry a").click(function() {
$(this).parents('.entry').find('.description').slideToggle(1000);
});
});
</script>
</head>
<body>
<?php
$con = mysql_connect("korg", "joe", "bob");
if (!$con) {
die('Could not connect: ' . mysql_error());
}
mysql_select_db("wfr11", $con);
$result = mysql_query("
select title,description from webcases");
?>
<table border="1">
<thead>
<tr>
<th>title</th>
</tr>
</thead>
<?php
while ($row = mysql_fetch_array($result)) {
?><div class="entry"><tr>
<td>
<?php echo htmlentities($row['title']); ?>
<div class="description"><?php echo htmlentities($row['description']); ?></div>
</td>
</tr></div>
<?php
}
mysql_close($con);
?>
</table>
</body>
</html>
Now, a click on a ticket title does not work. I remove all the code for the table, it works fine: click on a title and the description unfolds
I should be able to fold my div (expand & description) into my table, right? What am I missing?
Chris, have a look here: http://jsfiddle.net/neopreneur/kdFHP/
Your HTML needs to look like this:
<table border="1">
<thead>
<tr>
<th>title</th>
</tr>
</thead>
<tbody>
<tr>
<td class="entry">
Title Text (click here)
<div class="description">Description Text</div>
</td>
</tr>
</tbody>
</table>