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
Related
I have a table with horizontal scrolling, but I dont like the scrollbar, so I want to change it to a dot.
I tried using flickity but I have some problems.
Code:
<head>
<script src="https://unpkg.com/flickity#2/dist/flickity.pkgd.min.js"></script>
<link rel="stylesheet" href="https://unpkg.com/flickity#2/dist/flickity.min.css">
<link rel="stylesheet"
href=
"https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<body>
<style>
.scrollme {
overflow-x: auto;
}
::-webkit-scrollbar {
width: 2px;
height:5px;
}
}
</style>
<div class="container" >
<?php
require 'db.php';
$sql = "SELECT * FROM clelist order by clelist_id DESC";
$result = mysqli_query($db, $sql );
echo "<div class='carousel scrollme' style='' data-flickity="" data-js='carousel'>
<table class='table table-bordered text-center table-responsive '>
<tr class='table-active '>
<th class='text-center align-middle carousel-cell' style=' white-space:nowrap;' > num </th>
<th class='text-center align-middle carousel-cell 'style=' white-space:nowrap;' > car_num</th>
<!--more.....-->
</tr>";
while ($row = mysqli_fetch_array($result)) {
$tmp=explode(":",$row['cle_date']);
echo '
<tbody id="searchTable">
<tr>
<td class="text-center align-middle carousel-cell" >
'.$row["DlistNO"].'<br>'.$row["cle_no"].'
</td>
<td class="text-center align-middle carousel-cell" >
'.$row["cle_date"].'<br>
'.$row["c_cle_car_no_head"].'<br>
'.$row["c_cle_car_no_tail"].'
</td>
<!--more.....-->
';
?>
<tr>
<?php
}
?></tbody>
</table></div>
</div>
</body>
</html>
Output:
Does this answer your question: https://tympanus.net/codrops/2014/01/21/dot-navigation-styles/
Also, you can check out different types of scroll dots here
I have created a sales-form in which the date and place of sale of products are selected:
After clicking on the "Szukaj" button, which means "search" or "filter"
the data from the database is extracted using PHP and MSQL queries. After the results of sale are displayed
I want to use the jQuery DATATABLES plug-in to export the data to EXCEL, PDF, etc. The problem is that it does not work and it only copies and exports the first line
Why?here is the admin.php file in which the sale is displayed with a script at the bottom that runs datatable:
<?php
session_start();
if (!isset($_SESSION['zalogowany']))
{
header('Location: index.php');
exit();
}
$connect = new PDO("mysql:host=localhost;dbname=bukowski2", "root", "");
function fill_unit_select_box2($connect)
{
$output = '';
$query = "SELECT * FROM users WHERE user_id!=7";
$statement = $connect->prepare($query);
$statement->execute();
$result = $statement->fetchAll();
foreach($result as $row)
{
$output .= '<option value="'.$row["user"].'">'.$row["user"].'</option>';
}
return $output;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="jquery-3.5.1.min.js" a></script>
<script src="https://kit.fontawesome.com/b99e675b6e.js"></script>
<script src="js2.js" async></script>
<link rel="stylesheet" href="bootstrap.min.css" />
<script src="jquery-ui.js" defer></script>
<link rel="stylesheet" href="style2.css">
<link rel="stylesheet" href="jquery-ui.css"/>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.6.2/css/buttons.dataTables.min.css">
<script src="buttons\datatables.min.js" defer></script>
<script src="buttons\dataTables.buttons.min.js" defer></script>
<script src="buttons\buttons.flash.min.js" defer></script>
<script src="buttons\jszip.min.js" defer></script>
<script src="buttons\pdfmake.min.js" defer></script>
<script src="buttons\buttons.print.min.js" defer></script>
<script src="buttons\buttons.html5.min.js" defer></script>
<script src="buttons\vfs_fonts.js" defer></script>
<script src="buttons\js.js" defer></script>
</head>
<body>
<?php
$_SESSION['sales_date']=date('Y-m-d');
echo '<p class="logged">Zalogowany: '.$_SESSION['user'].' | '.$_SESSION['sales_date'].' | [ Wyloguj się ]</p>';
?>
<div class="wrapper">
<div class="tabs">
<ul>
<li class="active">
<span class="text">TABELA</span>
</li>
<li>
<span class="text">DODAJ/USUŃ</span>
</li>
<li>
<span class="text">3</span>
</li>
<li>
<span class="text">4</span>
</li>
</ul>
</div>
<div class="content">
<div class="tab_wrap" style="display: block;">
<div class="title"></div>
<div class="tab_content">
<div class="container" style="width:100%;">
<h3 align="center">Wyszukiwanie danych sprzedaży</h3><br /> <br /> <br />
<div class="col-md-3" style="float:left;">
<input type="text" name="date" id="date" class="form-control" placeholder="Wybierz datę" />
</div>
<div class="col-md-3" style="float:left;">
<select required name="item_from" id="item_from" class="form-control item_from"><option value="">
<?php echo fill_unit_select_box2($connect); ?>
</option></select>
</div>
<div class="col-md-5" style="float:left;">
<input type="button" name="filter" id="filter" value="Szukaj" class="btn btn-info" />
</div>
<div style="clear:both"></div>
<br />
<div id="order_table">
<table class="table table-bordered" id="example">
<thead>
<tr>
<th width="30%">Nazwa i kolor produktu</th>
<th width="10%" style="text-align:center">Rozmiar</th>
<th width="10%" style="text-align:center">Cena PLN</th>
<th width="10%" style="text-align:center">KARTA PLN</th>
<th width="10%" style="text-align:center">Inna waluta1</th>
<th width="10%" style="text-align:center">Inna waluta2</th>
<th width="10%" style="text-align:center">Od</th>
</tr>
</thead>
<tbody>
</tbody>
<tfoot>
<tr>
<th width="30%">Nazwa i kolor produktu</th>
<th width="10%" style="text-align:center">Rozmiar</th>
<th width="10%" style="text-align:center">Cena PLN</th>
<th width="10%" style="text-align:center">KARTA PLN</th>
<th width="10%" style="text-align:center">Inna waluta1</th>
<th width="10%" style="text-align:center">Inna waluta2</th>
<th width="10%" style="text-align:center">Od</th>
</tr>
</tfoot>
</table>
</div>
</div>
</div>
</div>
<div class="tab_wrap" style="display: none;">
<div class="title"></div>
<div class="tab_content">
<p>CONTENT 2</p>
</div>
</div>
<div class="tab_wrap" style="display: none;">
<div class="title"></div>
<div class="tab_content">
<p>CONTENT 3</p>
</div>
</div>
<div class="tab_wrap" style="display: none;">
<div class="title"></div>
<div class="tab_content">
<p>CONTENT 4</p>
</div>
</div>
</div>
</div>
</body>
</html>
<script>
$(document).ready(function(){
$.datepicker.setDefaults({
dateFormat: 'yy-mm-dd'
});
$(function(){
$("#date").datepicker();
});
$('#filter').click(function(){
var date = $('#date').val();
var item_from=$('#item_from').val();
if(date != '')
{
$.ajax({
url:"filter.php",
method:"POST",
data:{date:date,item_from:item_from},
success:function(data)
{
$('#order_table').html(data);
}
});
}
else
{
alert("Please Select Date");
}
});
});
</script>
and below is the filter.php file which uses PHP and a MySQL query to extract data from the database, which I want to export using the DATATABLE plug-in buttons:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="jquery-3.5.1.min.js" a></script>
<script src="https://kit.fontawesome.com/b99e675b6e.js"></script>
<script src="js2.js" async></script>
<link rel="stylesheet" href="bootstrap.min.css" />
<script src="jquery-ui.js" defer></script>
<link rel="stylesheet" href="style2.css">
<link rel="stylesheet" href="jquery-ui.css"/>
<link rel="stylesheet" href="https://cdn.datatables.net/1.10.21/css/jquery.dataTables.min.css">
<link rel="stylesheet" type="text/css" href="https://cdn.datatables.net/buttons/1.6.2/css/buttons.dataTables.min.css">
<script src="buttons\datatables.min.js" defer></script>
<script src="buttons\dataTables.buttons.min.js" defer></script>
<script src="buttons\buttons.flash.min.js" defer></script>
<script src="buttons\jszip.min.js" defer></script>
<script src="buttons\pdfmake.min.js" defer></script>
<script src="buttons\buttons.print.min.js" defer></script>
<script src="buttons\buttons.html5.min.js" defer></script>
<script src="buttons\vfs_fonts.js" defer></script>
<script src="buttons\js.js" defer></script>
</head>
<body>
<?php
//filter.php
if(isset($_POST["date"])) {
//ustanawiamy połącznie z bazą danych
$connect = mysqli_connect("localhost", "root", "", "bukowski2");
if($_POST["item_from"]==""){
$query = "SELECT item_name.item_name,sizes.sizes,sales_table.total_pln,sales_table.total_cart_payment,sales_table.total_oc1,currencies.currency,users.user FROM item_name,sales_table,sizes,currencies,users WHERE sizes.size_id=sales_table.size_id AND item_name.id=sales_table.item_name_color AND currencies.id=sales_table.total_oc2 AND users.user_id=sales_table.user_id AND sales_date='".$_POST["date"]."' ORDER BY sales_id";
}else{
$query0="SELECT user_id FROM users WHERE user='".$_POST["item_from"]."'";
$result = mysqli_query($connect, $query0);
while($row = mysqli_fetch_assoc($result))
{
$e= $row['user_id']."<br>";
}
$user_id = (int)$e;
$query = "SELECT item_name.item_name,sizes.sizes,sales_table.total_pln,sales_table.total_cart_payment,sales_table.total_oc1,currencies.currency,users.user FROM item_name,sales_table,sizes,currencies,users WHERE sizes.size_id=sales_table.size_id AND item_name.id=sales_table.item_name_color AND currencies.id=sales_table.total_oc2 AND users.user_id=sales_table.user_id AND sales_date='".$_POST["date"]."' AND sales_table.user_id=".$user_id." ORDER BY sales_id";
}
$output='';
$result = mysqli_query($connect, $query);
$output .= '
<table class="table table-bordered" id="example">
<thead>
<tr>
<th width="30%">Nazwa i kolor produktu</th>
<th width="10%" style="text-align: center">Rozmiar</th>
<th width="10%" style="text-align: center">Cena PLN</th>
<th width="10%" style="text-align: center">KARTA PLN</th>
<th width="10%" style="text-align: center">Inna waluta1</th>
<th width="10%" style="text-align: center">Inna waluta2</th>
<th width="10%" style="text-align: center">Od</th>
</tr>
</thead>
';
if(mysqli_num_rows($result) > 0)
{
while($row = mysqli_fetch_array($result))
{
$output .= '
<tbody>
<tr>
<td>'. $row["item_name"] .'</td>
<td style="text-align: center">'. $row["sizes"] .'</td>
<td style="text-align: center">'. $row["total_pln"] .'</td>
<td style="text-align: center">'. $row["total_cart_payment"] .'</td>
<td style="text-align: center">'. $row["total_oc1"] .'</td>
<td style="text-align: center">'. $row["currency"] .'</td>
<td style="text-align: center">'. $row["user"] .'</td>
</tr>
</tbody>
';
}
}
else
{
$output .= '
<tr>
<td colspan="5">Brak danych</td>
</tr>
';
}
$output .= '</table>';
echo $output;
//zamykamy połączenie z bazą danych
mysqli_close($connect);
}
?>
</body>
The js code to initialize the table has been included in the buttons\js.js script file. Here is the code:
$(document).ready(function() {
$('#example').DataTable( {
dom: 'Bfrtip',
buttons: [
'copy',
'csv',
'excel',
'pdf',
'print'
]
} );
} );
ok i solved. It was enough to remove the tag from the loop that printed the results because the tag was inserted each time a row of data was inserted. Closed
<?php
set_time_limit(5000);
ob_start();
session_start();
include('connection_config.php');
?>
<!DOCTYPE html>
<html>
<title>mi Adda Portal</title>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="sidenav.js"></script>
<link rel="stylesheet" href="headings.css">
<link rel="stylesheet" href="https://www.w3schools.com/lib/w3.css">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Tangerine">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Rancho&effect=shadow-multiple">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
<div class="w3-white w3-content" style="max-width:1600px">
<header>
<div class="w3-container w3-red w3-center">
<a href="home.php" style="text-decoration:none;"><h2 style="text-align:left; float:center;font-family:Times New Roman;">WAP Portal</h2>
</div>
</header>
<!-- !PAGE CONTENT! -->
<body>
<div class="bgimage">
<div class="w3-main bgimage" style="margin:auto;text-align:center">
<h4 class="w3-Rancho font-effect-shadow-multiple" style="text-align:center;margin: auto; padding-top:auto;">Fashion Wallpapers</h4>
<hr style="display: block; margin:0.5em 0.5em auto auto; border-style: inset;border-width: 1px;"><br>
<div>
<table width="100%" align="center" cellpadding="15" cellspacing="20">
<tr>
<td align="center" valign="middle">
<a href="">
<img style="border: 2px solid;border-radius: 5px; border-color:black;" src="./WAPContent/fashion/fashionwallpapers/500x500/kkf_in_fng004.gif" height="135" width="135">
</a>
</td>
<td align="center" valign="middle">
<a href="#">
<img style="border: 2px solid;border-radius: 5px; border-color:black;" src="./WAPContent/fashion/fashionwallpapers/500x500/kk_in_fng002.gif" height="135" width="135">
</a></td>
<tr>
<td align="center" valign="middle">
<a href="#">
<img style="border: 2px solid;border-radius: 5px; border-color:black;" src="./WAPContent/fashion/fashionwallpapers/500x500/ss_in_fng015.gif" height="135" width="135">
</a>
</td>
<td align="center" valign="middle">
<a href="#">
<img style="border: 2px solid;border-radius: 5px; border-color:black;" src="./WAPContent/fashion/fashionwallpapers/500x500/uk_in_fng001.gif" height="135" width="135">
</a></td>
<tr>
<td align="center" valign="middle">
<a href="#">
<img style="border: 2px solid;border-radius: 5px; border-color:black;" src="./WAPContent/fashion/fashionwallpapers/500x500/uk_in_fng003.gif" height="135" width="135">
</a>
</td>
<td align="center" valign="middle">
<a href="#">
<img style="border: 2px solid;border-radius: 5px; border-color:black;" src="./WAPContent/fashion/fashionwallpapers/500x500/uk_in_fng005.gif" height="135" width="135">
</a>
</td>
</tr>
</table>
</div>
<br/>
<?php
$connect_error = 'Sorry, we\'re experiencing connection issues.';
$con=mysqli_connect("localhost", "root", "12345","miadda") or die("Can not connect to database: ".mysql_error());
mysqli_select_db($con,"miadda") or die("Can not select the database: ".mysql_error());
$sql = "select * from miadda";
// the result of the query
$result = mysqli_query($con,$sql) or die("Invalid query: " .mysqli_error($connect_error));
// Header for the image
while ($row = mysqli_fetch_array($result))
{
//$image=$row ['CONTENT_PATH'];
echo '<img src="/WAPContent/fashion/fashionwallpapers/500x500/'.$row['CONTENT_PATH'].'" width="100" height="100">';
}
?>
</div>
<!-- Pagination -->
<div class="w3-center w3-padding-32">
<div class="w3-bar">
1
2
3
</div>
</div>
<!--end of pagination-->
<style>
.w3-bar a.active
{
background-color: #4CAF50;
color: white;
}
..w3-bar a:hover:not(.active) {
background-color: #ddd;
}
.bgimage {
background-attachment: fixed;
background-position: center;
background-repeat: no-repeat;
background-size: cover;
}
/* First image (Logo. Full height) */
.bgimage {
background-image: url('bg.jpg');
min-height: 100%;
opacity:1;
}
</style>
</body>
<!--Footer-->
<footer>
<div class="w3-red w3-center" style="margin-bottom:-15px;margin-top:15px;padding-top:8px;padding-bottom:8px;">
| Home |
</div>
</footer>
</div>
<!-- End page content -->
</html>
<?php
ob_flush();
?>
Can someone please help me where am I going wrong in this part of code:
<?php
$connect_error = 'Sorry, we\'re experiencing connection issues.';
$con=mysqli_connect("localhost", "root", "12345","miadda") or die("Can not connect to database: ".mysql_error());
mysqli_select_db($con,"miadda") or die("Can not select the database: ".mysql_error());
$sql = "select * from miadda";
// the result of the query
$result = mysqli_query($con,$sql) or die("Invalid query: " .mysqli_error($connect_error));
// Header for the image
while ($row = mysqli_fetch_array($result))
{
//$image=$row ['CONTENT_PATH'];
echo '<img src="/WAPContent/fashion/fashionwallpapers/500x500/'.$row['CONTENT_PATH'].'" width="100" height="100">';
}
?>
upon running the web portal, It doesn't show any error. But images are not displayed. Image border displays for all images, but displays like unavailable or broken image.
Here's the screenshot of how it displays:
enter image description here
Images are should be retrieved from image path provided in database:
"/WAPContent/fashion/fashionwallpapers/" under column CONTENT_PATH
and the full path is: /WAPContent/fashion/fashionwallpapers/500x500/
attached is the screenshot of MySQL table from which I am working on fashion category:
fashion category
Please help me out...Thanks in advance.
The content path in the database is really that: the content path. The image name is in the field content_name.
<?php
$connect_error = 'Sorry, we\'re experiencing connection issues.';
$con=mysqli_connect("localhost", "root", "12345","miadda") or die("Can not connect to database: ".mysql_error());
mysqli_select_db($con,"miadda") or die("Can not select the database: ".mysql_error());
$sql = "select * from miadda where CONTENT_PATH<>'NA'";
// the result of the query
$result = mysqli_query($con,$sql) or die("Invalid query: " .mysqli_error($connect_error));
// Header for the image
while ($row = mysqli_fetch_array($result))
{
$image=$row ['CONTENT_PATH'].$row['CONTENT_NAME'];
//use a relative path
if(0 === strpos($image,"/")) $image = substr($image, 1);
$image = mb_substr($image, 0, mb_strlen($image)-2) + "/";
echo '<img src="'.$image.'" width="100" height="100">';
}
?>
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'));
I keep getting a
"Parse error: syntax error, unexpected ':', expecting ')' in /home/jobkill/public_html/process.php on line 8"
when processing inputs from a page that redirects here. I dont know what to fix,
Here's the code:
<?
$aff = $_GET['aff'] ;
$click_id = $_GET['click_id'] ;
$zipcode = #$_GET['zip'];
$state = #$_GET['custom_state'];
$subid = $_GET['subid'] ;
$urls = array(
“http://consumerheadlinesdaily.com/debt/direct_2de89f.php?
cdb=23&zip=<?print $zipcode?>”,
“http://consumerheadlinesdaily.com/debt/direct_2de89f.php?
cdb=80&zip=<?print $zipcode?>”,
“http://consumerheadlinesdaily.com/debt/direct_2de89f.php?
cdb=46&zip=<?print $zipcode?>”,
“http://consumerheadlinesdaily.com/debt/direct_2de89f.php?
cdb=37&zip=<?print $zipcode?>”,
“http://consumerheadlinesdaily.com/debt/direct_2de89f.php?
cdb=55&zip=<?print $zipcode?>”,
“http://consumerheadlinesdaily.com/debt/direct_2de89f.php?
cdb=71&zip=<?print $zipcode?>”);
$url = $urls[array_rand($urls)];
echo “<meta http-equiv=\"refresh\" content=3; url='$url'>”;
?>
<html>
<HEAD>
<LINK href="./index_files/style2.css" rel="stylesheet" type="text/css">
<STYLE>
#middlename
{
display:none;
visibility:hidden;
}
</STYLE>
<SCRIPT type="text/javascript" src="./index_files/scripts.js"></SCRIPT>
<SCRIPT type="text/javascript"
src="./index_files/functions.js"></SCRIPT>
<script language="JavaScript"
src="http://j.maxmind.com/app/geoip.js"></script>
</HEAD><BODY>
<DIV id="form_complete">
<!-- OPEN MAIN TABLE -->
<TABLE width="100%" height="850" border="0" align="center"
cellpadding="0" cellspacing="0" class="tablebg2">
<TBODY>
<TR>
<TD valign="top" align="center">
<!-- OPEN PLACEMENT TABLE -->
<table width="1010" height="500" border="0" cellspacing="0"
cellpadding="0">
<tr><td height="220" colspan="3"> </td></tr>
<tr>
<td width="51%"><div align="center"><img
src="index_files/blank.gif" border="0" width="425" height="344"
/></div></td>
<td
width="10%">  
; </td
>
<td width="39%" align="left">
<br /><br /><br />
<div id="super-container0">
<div id="wrapper">
<span style="color:#000000;font-weight:bold;font-
size:24px;color:#898;">Now Searching...</span><br /><span
style="color:#000000;font-weight:bold;font-size:32px;"><script
language="Javascript">document.write(geoip_city());</script>, <script
language="Javascript">document.write(geoip_region());</script></span>
<!-- <h2>for <span style="color:#000000;font-weight:bold">30-
34</span> Year Old <span style="color:#000000;font-
weight:bold">Male</span> Drivers</h2> -->
<div id="block"></div>
<div id="progress-bar"><img src="index_files/progress.gif"></div>
</div>
</div>
</DIV>
</td>
</tr>
<tr>
<td height="350" colspan="3"> </td>
</tr>
<tr>
<td colspan="3">
<DIV class="Privacy" style="width: 1000px; margin: 0 auto;">
<P style="font-family:Arial, Helvetica, sans-serif; font-
size:11px; margin: 0px; padding: 0px;">All personal information and
email addresses are kept confidential. By
submitting your expression of interest you are consenting to receive
telephone calls from our participating partners even if you have been
previously listed on a state or federal Do-Not-Call List.
</P><P style="width: 1000px; text-align: center; margin-top: 0px;
padding-top: 0px;"><A href="#" onclick="MM_openBrWindow
('privacy.htm','','scrollbars=yes,width=500,height=
400')" target="_blank" style="font-family:Arial, Helvetica, sans-
serif; font-size:10px; color:#03C">Privacy Policy</A></P>
</DIV></td>
</tr>
</table> <!-- CLOSE PLACEMENT TABLE -->
</TD></TR></TABLE> <!-- CLOSE MAIN TABLE -->
<DIV id="processing" style="display:none">
<br /><br /><br /><br />
<CENTER><img src="./index_files/logo2.gif" /><br /><br />
<H2>Searching for a specialist now ...<BR>Thank you for giving us an
opportunity to assist you today.</H2><STRONG>(Please do not Refresh
page as that will result in an error in the system.)</STRONG><BR>
<IMG src="./index_files/ajax-loader.gif" width="220" height="19"
alt="Processing">
</CENTER>
</DIV>
</BODY></html>
The problem in your code are the quotes.
This character:
“
Is not recognised as a quotation in PHP, you need to use
'
Or
"
Here is the updated code
<?
$aff = $_GET['aff'] ;
$click_id = $_GET['click_id'] ;
$subid = $_GET['subid'];
$zipcode = '';
if (isset($_GET['zip']) {
$zipcode = $_GET['zip'];
}
$state = '';
if (isset($_GET['custom_state']) {
$state = $_GET['custom_state'];
}
$urls = array(
'http://consumerheadlinesdaily.com/debt/direct_2de89f.php?cdb=23&zip=' . $zipcode,
'http://consumerheadlinesdaily.com/debt/direct_2de89f.php?cdb=80&zip=' . $zipcode,
'http://consumerheadlinesdaily.com/debt/direct_2de89f.php?cdb=46&zip=' . $zipcode,
'http://consumerheadlinesdaily.com/debt/direct_2de89f.php?cdb=37&zip=' . $zipcode,
'http://consumerheadlinesdaily.com/debt/direct_2de89f.php?cdb=55&zip=' . $zipcode,
'http://consumerheadlinesdaily.com/debt/direct_2de89f.php?cdb=71&zip=' . $zipcode);
$url = $urls[array_rand($urls)];
?>
<html>
<head>
<meta http-equiv="refresh" content=3; url='<? echo $url ?>'>
<link href="./index_files/style2.css" rel="stylesheet" type="text/css">
<style>
#middlename
{
display:none;
visibility:hidden;
}
</style>
<script type="text/javascript" src="./index_files/scripts.js"></script>
<script type="text/javascript" src="./index_files/functions.js"></script>
<script type="text/javascript" src="http://j.maxmind.com/app/geoip.js"></script>
</head>
<body>
<div id="form_complete">
<!-- OPEN MAIN TABLE -->
<table width="100%" height="850" border="0" align="center" cellpadding="0" cellspacing="0" class="tablebg2">
<tbody>
<tr>
<td valign="top" align="center">
<!-- OPEN PLACEMENT TABLE -->
<table width="1010" height="500" border="0" cellspacing="0" cellpadding="0">
<tr>
<td height="220" colspan="3"> </td>
</tr>
<tr>
<td width="51%">
<div align="center">
<img src="index_files/blank.gif" border="0" width="425" height="344" />
</div>
</td>
<td width="10%">
</td>
<td width="39%" align="left">
<br /><br /><br />
<div id="super-container0">
<div id="wrapper">
<span style="color:#000000;font-weight:bold;font-size:24px;color:#898;">Now Searching...</span><br />
<span style="color:#000000;font-weight:bold;font-size:32px;">
<script type="text/javascript">document.write(geoip_city());</script>,
<script type="text/javascript">document.write(geoip_region());</script>
</span>
<!-- <h2>for <span style="color:#000000;font-weight:bold">30-34</span> Year Old
<span style="color:#000000;font-weight:bold">Male</span> Drivers</h2> -->
<div id="block"></div>
<div id="progress-bar"><img src="index_files/progress.gif"></div>
</div>
</div>
</td>
</tr>
<tr>
<td height="350" colspan="3"> </td>
</tr>
<tr>
<td colspan="3">
<div class="Privacy" style="width: 1000px; margin: 0 auto;">
<p style="font-family:Arial, Helvetica, sans-serif; font-size:11px; margin: 0px; padding: 0px;">All personal information and
email addresses are kept confidential. By submitting your expression of interest you are consenting to receive
telephone calls from our participating partners even if you have been
previously listed on a state or federal Do-Not-Call List.</p>
<p style="width: 1000px; text-align: center; margin-top: 0px; padding-top: 0px;">Privacy Policy</p>
</div>
</td>
</tr>
</table> <!-- CLOSE PLACEMENT TABLE -->
</td>
</tr>
</tbody>
</table> <!-- CLOSE MAIN TABLE -->
</div>
<div id="processing" style="display:none">
<br /><br /><br /><br />
<center>
<img src="./index_files/logo2.gif" /><br /><br />
<H2>Searching for a specialist now ...<BR>Thank you for giving us an opportunity to assist you today.</h2>
<strong>(Please do not Refresh page as that will result in an error in the system.)</strong><br>
<img src="./index_files/ajax-loader.gif" width="220" height="19" alt="Processing">
</center>
</div>
</body>
</html>
I have also...
Fixed a couple of HTML errors, with missing closing tags or bad nesting
Rather than using error suppression in PHP (#$_GET['mightnotexist']) I have performed an isset($_GET['mightnotexist']) check
I have normalised the script tags
But I haven't...
Removed the tables being used for layout
Moved the inline styles into the stylesheet
UPDATE:
added whole code, tested and working
replace <?print $zipcode?> with $zipcode
i.e. “http://consumerheadlinesdaily.com/debt/direct_2de89f.php?cdb=23&zip=<?print $zipcode?>”,
into “http://consumerheadlinesdaily.com/debt/direct_2de89f.php?cdb=23&zip=$zipcode”,
and replace quotation marks (“”) to normal ones ("")
basically your code should look like this:
<?php
$aff = $_GET['aff'] ;
$click_id = $_GET['click_id'] ;
$zipcode = #$_GET['zip'];
$state = #$_GET['custom_state'];
$subid = $_GET['subid'] ;
$urls = array(
"http://consumerheadlinesdaily.com/debt/direct_2de89f.php?cdb=23&zip=$zipcode",
"http://consumerheadlinesdaily.com/debt/direct_2de89f.php?cdb=80&zip=$zipcode",
"http://consumerheadlinesdaily.com/debt/direct_2de89f.php?cdb=46&zip=$zipcode",
"http://consumerheadlinesdaily.com/debt/direct_2de89f.php?cdb=37&zip=$zipcode",
"http://consumerheadlinesdaily.com/debt/direct_2de89f.php?cdb=55&zip=$zipcode",
"http://consumerheadlinesdaily.com/debt/direct_2de89f.php?cdb=71&zip=$zipcode");
$url = $urls[array_rand($urls)];
?>
<html>
<HEAD>
<LINK href="./index_files/style2.css" rel="stylesheet" type="text/css">
<STYLE>
#middlename
{
display:none;
visibility:hidden;
}
</STYLE>
<SCRIPT type="text/javascript" src="./index_files/scripts.js"></SCRIPT>
<SCRIPT type="text/javascript"
src="./index_files/functions.js"></SCRIPT>
<script language="JavaScript"
src="http://j.maxmind.com/app/geoip.js"></script>
<meta http-equiv="refresh" content="3;url=<?php echo $url; ?>">
</HEAD><BODY>
<DIV id="form_complete">
<!-- OPEN MAIN TABLE -->
<TABLE width="100%" height="850" border="0" align="center"
cellpadding="0" cellspacing="0" class="tablebg2">
<TBODY>
<TR>
<TD valign="top" align="center">
<!-- OPEN PLACEMENT TABLE -->
<table width="1010" height="500" border="0" cellspacing="0"
cellpadding="0">
<tr><td height="220" colspan="3"> </td></tr>
<tr>
<td width="51%"><div align="center"><img
src="index_files/blank.gif" border="0" width="425" height="344"
/></div></td>
<td
width="10%">  
; </td
>
<td width="39%" align="left">
<br /><br /><br />
<div id="super-container0">
<div id="wrapper">
<span style="color:#000000;font-weight:bold;font-
size:24px;color:#898;">Now Searching...</span><br /><span
style="color:#000000;font-weight:bold;font-size:32px;"><script
language="Javascript">document.write(geoip_city());</script>, <script
language="Javascript">document.write(geoip_region());</script></span>
<!-- <h2>for <span style="color:#000000;font-weight:bold">30-
34</span> Year Old <span style="color:#000000;font-
weight:bold">Male</span> Drivers</h2> -->
<div id="block"></div>
<div id="progress-bar"><img src="index_files/progress.gif"></div>
</div>
</div>
</DIV>
</td>
</tr>
<tr>
<td height="350" colspan="3"> </td>
</tr>
<tr>
<td colspan="3">
<DIV class="Privacy" style="width: 1000px; margin: 0 auto;">
<P style="font-family:Arial, Helvetica, sans-serif; font-
size:11px; margin: 0px; padding: 0px;">All personal information and
email addresses are kept confidential. By
submitting your expression of interest you are consenting to receive
telephone calls from our participating partners even if you have been
previously listed on a state or federal Do-Not-Call List.
</P><P style="width: 1000px; text-align: center; margin-top: 0px;
padding-top: 0px;"><A href="#" onclick="MM_openBrWindow
('privacy.htm','','scrollbars=yes,width=500,height=
400')" target="_blank" style="font-family:Arial, Helvetica, sans-
serif; font-size:10px; color:#03C">Privacy Policy</A></P>
</DIV></td>
</tr>
</table> <!-- CLOSE PLACEMENT TABLE -->
</TD></TR></TABLE> <!-- CLOSE MAIN TABLE -->
<DIV id="processing" style="display:none">
<br /><br /><br /><br />
<CENTER><img src="./index_files/logo2.gif" /><br /><br />
<H2>Searching for a specialist now ...<BR>Thank you for giving us an
opportunity to assist you today.</H2><STRONG>(Please do not Refresh
page as that will result in an error in the system.)</STRONG><BR>
<IMG src="./index_files/ajax-loader.gif" width="220" height="19"
alt="Processing">
</CENTER>
</DIV>
</BODY></html>
replace "refresh" in your echo with \"refresh\"
and
<?print $zipcode?>
in array with
$zipcode
Update:
Checked your code and was able to reproduce your error. You're not using double quotes but some other obscure quotes that is not supported by PHP.
Proper double quotes are literally ". You can learn about the details in the PHP manual.
You probably made an error while copy and pasting code from somewhere else in the internet that was changing code's quote's on the fly for styling and display reason.
Take care. The other problems in your code still stand (see other answers as well).
Try
echo "<meta http-equiv=\"refresh\" content=\"3; url='$url'\">";
instead of the similar but different line in your screenshot (it's no text, so I can't quote it and highlight the places you made errors in there, so sorry 'bout that).
This does not create the syntax error you're asking about however.