im making a web page in php of creating random numbers on the screen from 0 to 99. and im storing it in database and then fetching it by slect distinct query because i dont wanna repeat the numbers.. The problem is that i wanna echo something or show a alert box when no distinct number is selected. and i cant figure it out.. Please someone help me..
<?php
$con=mysqli_connect('localhost','root','','bingo');
if(isset($_POST['btn1'])){
$sqli_del="DELETE FROM `numbers`";
$que=mysqli_query($con, $sqli_del);
if($que){
echo "ALL NUMBERS ARE DELETED!!!!";
}
else{
echo 'There is somethin wrong with the query...';
}
}
if(isset($_POST['btn'])){
$var=mt_rand(0,99);
$sql="INSERT INTO `numbers`(`number`) VALUES ('$var')";
$query=mysqli_query($con, $sql);
$sqli="SELECT DISTINCT number FROM `numbers`";
$res=mysqli_query($con, $sqli);
}
?>
<!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>Bingo</title>
<style>
.main{margin:0 auto;}
.form{ margin: auto;
width: 71%;}
.form input{width:90px;
height:50px;}
.spin{background-color:green; color:white; border-radius:10px;font-
weight:bold;}
.del{background-color:red; color:white; border-radius:10px;font-
weight:bold;}
.number{
width: 110px;
height: 107px;
font-size: 98px;
color: blue;
background-color: black;
padding-left: 22px;
margin-left: 25px;}
.left{float:left;}
.right{float:left;padding:250px;}
a{text-decoration:none;}
.back{text-align:left !important;float:left;color:blue;}
.button{float:left;padding-top:20px;}
</style>
</head>
<body>
<div class="main">
<div class="form">
<form method="POST" action="">
<div class="left">
<?php if(!empty($res)) {?>
<div class="back">
<?php
$count=mysqli_num_rows($res);
echo "(".$count.' '. 'numbers are printed..'.")"."<br>";
while($row=mysqli_fetch_assoc($res)){
$num=$row['number'];
echo $num."<br>";}
?>
</div>
<?php } ?>
</div>
<div class="right">
<?php if(!empty($num)) {?>
<div class="number">
<?php
echo $num ."<br>";?>
</div>
<?php } ?>
<div class="button">
<a href=""><input class="spin" type="submit" name="btn" value="Spin">
</a>
<a href=""><input class="del" type="submit" name="btn1" value="Delete
All"></a>
</div>
</div>
</form>
</div>
</div>
</body>
</html>
According to your code
<?php if(!empty($res)) {?>
<div class="back">
<?php
$count=mysqli_num_rows($res);
echo "(".$count.' '. 'numbers are printed..'.")"."<br>";
while($row=mysqli_fetch_assoc($res)){
$num=$row['number'];
echo $num."<br>";
}
?>
</div>
<?php
} else {//empty, $res is false
if(isset($_POST['btn'])){ //check whether post request
echo "<span>no number</span>";
}
}
mysqli query
if ( false === $res) {
} else {
}
Related
my problem is that i cant seem to call any kind of information that is stored in my database. I want to call everything in the order that it is in the database(name of the product, image and price. Here is the code for my index.php
Here you can view how my webpage looks so far:
Here you can view the data that is in my database:
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Add to Cart</title>
<?php
$mysqli = new mysqli("localhost", "id3764036_alan", "agro12345", "id3764036_agrotienda");
?>
<link rel="stylesheet" href="style.css" type="text/css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.6.3/css/font-awesome.min.css">
<link href="https://fonts.googleapis.com/css?family=Roboto+Condensed|Rubik" rel="stylesheet">
<style>
a{text-decoration:none; color:inherit}
#undr{width:100%; height:580px; position:absolute; top:75px; left:0px;}
.bdimg{width:100%; height:100%}
#lowrbdy{ position:absolute; top:90px; left:0px;width:100%; height:100px}
.outer{width:270px; height:270px; background:rgba(255,255,255,0.8); float:left; margin-left:55px; margin-bottom:10px}
.imgdv{width:100px;height:140px;margin:10px auto;}
.imgdv img{width:100%; height:100%}
.pname{ text-align:center; width:100%; height:20px; font-size:15px; margin-top:-14px; margin-bottom:10px}
.prs{ text-align:center; font-size:24px; margin:0px}
.butndv{width:140px; height:40px; margin:auto; margin-top:-10px}
.butn{width:100%; height:100%; background:rgba(78,172,240,1.00); border:none; color:#fff; font-size:18px; border-radius:6px}
.outer:hover{ background:#fff}
.outer:hover .butn{ background:#4A7FDC; transition:all 0.2s ease-in-out; cursor:pointer}
</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
</head>
<body>
<header>
<?php
include('head.php');
?>
</header>
<div id="undr">
<img class="bdimg" src="bg.jpg">
</div>
<div id="lowrbdy">
<?php
$select_query="";
$sql = mysqli_query($mysqli,'SELECT * FROM `product`');
while ($row = $sql->fetch_row())
{
?>
<a href="view.php?product=<?=$row["id"]?>">
<div class="outer">
<div class="imgdv"><img src="carrillo/imeg/<?=$row["pro_image"]?>"/></div>
</div>
</a>
<?php
}
?>
</div>
</body>
</html>
Change fetch_row() to fetch_assoc(). If you use fetch_row(), the $row variable will contain array with numerical indexes. With fetch_assoc(), the $row variable will store an associative array with column names as the indexes.
Try Using prepared statement
<?php
$select_query="";
// $sql = mysqli_query($mysqli,'SELECT * FROM `product`');
$sql="SELECT id, pro_image,name,price FROM product";
if ($stmt = $conn->prepare($sql)) {
$stmt->execute();
$stmt->bind_result($id, $pro_image, $name);
while ($stmt->fetch()) {
?>
<a href="view.php?product=<?php echo $id;?>">
<div class="outer">
<div class="imgdv"><img src="carrillo/imeg/<?php echo $p_image;?>"/></div>
</div>
</a>
<?php
}
}?>
You can also try with MySQLi Procedural
You have to use mysqli_fetch_assoc instated of fetch_row
$sql = "SELECT * FROM `products`";
$result = mysqli_query($conn, $sql);
if (mysqli_num_rows($result) > 0) {
while($row = mysqli_fetch_assoc($result)) {
?>
<a href="view.php?product=<?php echo $row["id"];?>">
<div class="outer">
<div class="imgdv"><img src="carrillo/imeg/<?php echo $row["pro_image"];?>"/></div>
</div>
</a>
<?php
}
}
else {
echo "0 results";
}
mysqli_close($conn);
?>
This part of the code works fine:
<div id="Vraag">
<?php
while($row = mysqli_fetch_assoc($rows))
{
echo $row["vraag"];
}
?>
</div>
But this part does not work:
<div id="antAA">
<?php
while($row = mysqli_fetch_assoc($rows))
{
echo $row["AntwA"];
}
?>
<!-- Antwoord A -->
</div>
And I have no idea why it is not working. It is the same code. The database works fine because if I run this code all the way in the the top of my code it echoes all of them fine:
while($row = mysqli_fetch_assoc($rows))
{
echo $row["id"];
echo $row["vraag"];
echo $row["AntwA"];
echo $row["AntwB"];
echo $row["AntwC"];
echo $row["AntwD"];
}
But in the div it just does not work.
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="se.css">
<title>Lotto</title>
</head>
<body>
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "lotto";
$db = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$query = "SELECT id, vraag, AntwA, AntwB, AntwC, AntwD,id FROM vraag1";
$rows = mysqli_query($db, $query);
// while($row = mysqli_fetch_assoc($rows))
// {
// echo $row["id"];
// echo $row["vraag"];
// echo $row["AntwA"];
// echo $row["AntwB"];
// echo $row["AntwC"];
// echo $row["AntwD"];
// }
?>
<div id="headerbg"></div>
<center>
<h1>Vraag 1</h1>
</center>
<center>
<div>
<img src="antw.png" id="img6">
</div>
<div id="Vraag">
<?php
while($row = mysqli_fetch_assoc($rows))
{
echo $row["vraag"];
}
?>
</div>
<div id="plaatje">
<img id="img1" src="wip.jpg">
</div>
<div id="BGantA">
<img id="img2" src="antw.png">
</div>
<div id="antAA">
<?php
while($row = mysqli_fetch_assoc($rows))
{
echo $row["vraag"];
}
?>
<!-- Antwoord A -->
</div>
<div>
<img src="antw.png" id="img3">
</div>
<div>
Antwoord B
</div>
<div>
<img src="antw.png" id="img4">
</div>
<div>
Antwoord C
</div>
<div>
<img src="antw.png" id="img5">
</div>
<div>
Antwoord D
</div>
</center>
</body>
</html>
CSS Code if needed:
body{
background-color: white;
overflow: hidden;
/*#ECECEC;*/
}
#headerbg{
display: block;
margin-top:-10px;
margin-left: -10px;
margin-right: -10px;
width: 102%;
height: 118px;
background-color: #333333;
/*#232323;*/
}
h1{
font-family: times;
display: block;
margin-left: -800px;
margin-top:-76px;
color: #979797;
}
#img2, #img3, #img4, #img5{
width:300px;
height:100px;
display: block;
}
img{
border:1px solid lightgray;
padding: 5px;
}
#img1{
margin-top: 50px;
}
#img2{
margin-top: -370px;
margin-left: -800px;
}
#img3{
margin-top:-67px;
margin-left:800px;
}
#img4{
margin-left:-800px;
margin-top: 150px;
}
#img5{
margin-left: 800px;
margin-top: -67px;
}
#img6{
display: block;
width: 800px;
height: 60px;
margin-top: 55px;
margin-left: ;
}
#antAA, #antBB, #antCC, #antDD{
display: block;
/*color: #979797;*/
color:red;
text-decoration:none;
}
#antAA, #antCC{
margin-top: -65px;
margin-right: 800px;
}
#antBB{
margin-top: -65px;
margin-left: 800px;
}
#antDD{
margin-left: 800px;
margin-top:-65px;
}
#Vraag{
display:block;
color: red;
margin-top: -44px;
}
#antAA:hover, #antBB:hover, #antCC:hover, #antDD:hover{
color:white;
}
Once you execute mysqli_fetch_assoc then it return false as last value has been fetched and has no further value.
If you want to use this for multiple times you can save its value in array and then use this array
<?php
$vraag_array=array();
while($row = mysqli_fetch_assoc($rows))
{
$vraag_array[] = $row["vraag"];
}
//to echo
// close
?>
<div id="Vraag">
<?php
foreach ($vraag_array as $vraag_value) {
echo vraag_value;
}
?>
</div>
<div id="plaatje">
<img id="img1" src="wip.jpg">
</div>
<div id="BGantA">
<img id="img2" src="antw.png">
</div>
<div id="antAA">
<?php
foreach ($vraag_array as $vraag_value) {
echo vraag_value;
}
?>
<!-- Antwoord A -->
</div>
Use:
mysqli_data_seek($rows, 0);
After every while loop.
This sets the counter back to 0
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="se.css">
<title>Lotto</title>
</head>
<body>
<?php
$dbhost = "localhost";
$dbuser = "root";
$dbpass = "";
$dbname = "lotto";
$db = mysqli_connect($dbhost, $dbuser, $dbpass, $dbname);
$query = "SELECT id, vraag, AntwA, AntwB, AntwC, AntwD,id FROM vraag1";
$rows = mysqli_query($db, $query);
// while($row = mysqli_fetch_assoc($rows))
// {
// echo $row["id"];
// echo $row["vraag"];
// echo $row["AntwA"];
// echo $row["AntwB"];
// echo $row["AntwC"];
// echo $row["AntwD"];
// }
?>
<div id="headerbg"></div>
<center>
<h1>Vraag 1</h1>
</center>
<center>
<div>
<img src="antw.png" id="img6">
</div>
<div id="Vraag">
<?php
while($row = mysqli_fetch_assoc($rows))
{
echo $row["vraag"];
}
mysqli_data_seek($rows, 0);
?>
</div>
<div id="plaatje">
<img id="img1" src="wip.jpg">
</div>
<div id="BGantA">
<img id="img2" src="antw.png">
</div>
<div id="antAA">
<?php
while($row = mysqli_fetch_assoc($rows))
{
echo $row["vraag"];
}
mysqli_data_seek($rows, 0);
?>
<!-- Antwoord A -->
</div>
<div>
<img src="antw.png" id="img3">
</div>
<div>
Antwoord B
</div>
<div>
<img src="antw.png" id="img4">
</div>
<div>
Antwoord C
</div>
<div>
<img src="antw.png" id="img5">
</div>
<div>
Antwoord D
</div>
</center>
</body>
</html>
It looks like you're iterating through and fetching all the rows, but only reading out the one that matches "vraag". When you execute a second time, you have already iterated through and exhausted all the rows.
That's why this bit works:
while($row = mysqli_fetch_assoc($rows))
{
echo $row["id"];
echo $row["vraag"];
echo $row["AntwA"];
echo $row["AntwB"];
echo $row["AntwC"];
echo $row["AntwD"];
}
Because you're using each row as it is being processed over.
I can't really understand why you're executing such code, which iterates over entire collections and reads out the same singular value each time, but if you want the second attempt to work, you will have to execute this line again:
$rows = mysqli_query($db, $query);
Definitely consider rethinking the entire structure though.
I'm not totally sure. But I think this is because in the first while loop it takes out the "vraag".
So in the second while loop, it may think its the same loop so there is no more data to display there. Try to put in the query again right above the second loop. With other variable names
$query2 = "SELECT id, vraag, AntwA, AntwB, AntwC, AntwD,id FROM vraag1";
$rows2 = mysqli_query($db, $query2);
while($row2 = mysqli_fetch_assoc($rows2))
Please try to use different variables for different values. Please try different variable name in next code which is not working, just like this:
<div id="antAA">
<?php
while($row_new = mysqli_fetch_assoc($rows))
{
echo $row_new["AntwA"];
}
?>
<!-- Antwoord A -->
</div>
I hope, this will solve your issue.
For example when the user is login, after login I want to automatic update a specific row from this actual user. How can I do for it?
Well when the user is login I want to update is row points, I want to add some points to it, for example 5 points.
I have try a few examples but it just add other row but not for this specific user
<?php
session_start();
include_once 'dbconnect.php';
if(!isset($_SESSION['user'])){
header("Location: index.php");
}
$res=mysql_query("SELECT * FROM users WHERE user_id=".$_SESSION['user']);
$userRow=mysql_fetch_array($res);
// Retrieve data from database
$sql="SELECT * FROM users ORDER BY user_points DESC LIMIT 10";
$result=mysql_query($sql);
$sql = mysql_query("INSERT INTO `users` (`user_points`) VALUES ('5');");
// Start looping rows in mysql database.
print "Top 10 Users! ";
while($rows=mysql_fetch_array($result)){
echo $rows['user_name'] . " * " . $rows['user_points'] . " * ";
// close while loop
}
// close MySQL connection
mysql_close();
$page = $_SERVER['PHP_SELF'];
$sec = "30";
?>
<!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 http-equiv="refresh" content="<?php echo $sec?>;URL='<?php echo $page?>'">
<link rel="stylesheet" href="style.css" type="text/css" />
</head>
<body bgcolor="#ffffff">
<div id="header">
<div id="left">
<label>Bitcoin Rotator</label>
</div>
<div id="right">
<div id="content">
hi' <?php echo $userRow['user_name']; ?> Sign Out
Welcome Back Your Points <?php echo $userRow['user_points']; ?>
Bitcoin Rotator<br /><br />
<style>
#main {
width: 70px;
height: 300px;
border: 1px solid #c3c3c3;
display: -webkit-flex;
display: flex;
-webkit-flex-wrap: wrap;
flex-wrap: wrap;
-webkit-align-content: center;
align-content: center;
}
#main div {
width: 70px;
height: 70px;
}
</style>
</div>
</div>
</div>
<div id="body">
<font color="FF00CC"; style="color: rgb(0,255,0)" >Click Here</font><font color="FF00CC"> to go on our faucet</font>
<br>
<br>
<font color="FF00CC"; style="color: rgb(0,255,0)" >Click Here</font><font color="FF00CC"> to see the top 10 users!</font>
<br>
<br>
<font color="FF00CC"; style="color: rgb(0,255,0)" >Make Your Rotator </font><font color="FF00CC">Click Here To Start!</font>
<br>
<br>
<font color="FF00CC"; style="color: rgb(0,255,0)" >All The Rotators From Our Website </font><font color="FF00CC">Click Here To Start!</font>
<div id="main">
<div style="background-color:coral;"></div>
<div style="background-color:lightblue;"></div>
<div style="background-color:pink;"></div>
</div>
</div>
</body>
</html>
you try to INSERT the value 5 every time the user logged on
what you want is UPDATE the content of row points
u can do this by this command sql
"UPDATE `users` SET points=`points`+5 WHERE user_id='".$_SESSION['user']."'"
The query you need is
$user_id = mysql_real_escape_string($_SESSION['user']);
$sql = mysql_query("UPDATE `users` SET user_points = user_points + 5 WHERE user_id = " . $user_id);
Please don't use mysql_ library because it was deprecated (use mysqli_ instead)
I am echoing records from the database which are wrapped with html tags and was trying to put some effect on the echoed data. When I click the edit link, the textfield should shake. It works on the first element but when I click the edit link of the next element, the first textfield still shakes and not the other one.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Wallpost</title>
<style>
.wallpost input[type="text"]{
width: 500px;
height: 20px;
}
.wallpost input[type="submit"]{
height: 26px;
}
.user{
font-weight: bold;
font-size: 20px;
}
.post{
font-family: Arial;
}
a{
text-decoration: none;
}
</style>
</head>
<body>
<?php
require_once 'dbconfig.php';
$user = $_SESSION['user'];;
echo '<form action="post.php" method="post" class="wallpost"><input
type="text" name="post" size="50"><input type="submit" name="wallpost"
value="Post"></form>';
$query = $con->query("SELECT * FROM statuspost ORDER BY id DESC");
while($i = $query->fetch_object()){
//echo $i->post.' '.$i->id.' <a href="wallpost.php?type=post&
id='.$i->id.'" >Remove</a>'.'<br/>';
echo '<span class="user">'.$i->user.'</span>'.'<br>'.'<span
class="post">'.$i->post.'</span>'.' <form action="editpost.php?type=post&
id='.$i->id.'" method="post"><span id="edit"><input type="text"
name="edit">
<br/><input type="submit" value="Edit"></span><a href="#"
onclick="showEdit();">Edit </a><a href="remove.php?type=post&
id='.$i->id.'" >Remove</a></form> '.'<br/><br/>';
//echo '<div id="post">'.$i->post.' '.$i->id.'<a href="#"
id="anchor" class="',$i->id,'" onclick="del();">Remove</a></div>
<br/>';
}
?>
<script src="https://ajax.googleapis.com/ajax/libs/prototype/1.7.2.0
/prototype.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/scriptaculous/1.9.0
/scriptaculous.js"></script>
<script>
function showEdit(){
Effect.Shake('edit');
}
</script>
</body>
</html>
Replace <span id="edit"> by something like <span id="edit'.$i->id.'"> to have different ids on each elements. Then of course, showEdit() must know which id it has to shake, so it has to take a parameter. Or even simpler: replace onclick="showEdit();" by onclick="Effect.Shake(\'edit'.$i->id.'\');"
Scriptaculous effects take either an ID or a JavaScript reference to a DOM element as their first argument, so if you add a classname to your multiple elements, you can shake all of them at once like this:
<span class="shake-me">...</span>
<span class="shake-me">...</span>
<span class="shake-me">...</span>
Inside an enumerator:
$$('.shake-me').each(function(elm){
Effect.Shake(elm);
});
I wonder whether someone may be able to help me please.
From some demos and tutorials I've found, I've put together this page which adds toggle panes to a page using values from a mySQL database to populate the fields.
The problem I'm having is that at each layer only the first out of multiple records is shown.
e.g. The screen currently shows 16/03/2012 as the only record, there should be one other record for the 23/02/2012.
Then within the 16/03/2012, the next level should show two items, whereas it is only showing one.
I've been working on this for a while now but I can't seem to find the solution of how to show the correct number of records.
I just wondered whether someone could perhaps have a look at this please and let me know where I'm going wrong.
I've added the full script below for reference.
<!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>Panel Test</title>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery(".content").hide();
//toggle the componenet with class msg_body
jQuery(".heading").click(function()
{
jQuery(this).next(".content").slideToggle(500);
});
});
</script>
<style type="text/css">
body {
margin: 20px auto;
font: 12px Verdana,Arial, Helvetica, sans-serif;
}
.layer1 {
margin: 0;
padding: 0;
width: 500px;
}
.heading {
margin: 1px;
color: #fff;
padding: 3px 10px;
cursor: pointer;
position: relative;
background-color:#c30;
}
.content {
padding: 5px 10px;
background-color:#fafafa;
}
p { padding: 5px 0; }
</style>
</head>
<?php
mysql_connect("hostname", "username", "password")or
die(mysql_error());
mysql_select_db("database");
$result = mysql_query("SELECT userdetails.userid, finds.dateoftrip, detectinglocations.locationname, finds.userid, finds.locationid, detectinglocations.locationid, finds.findname, finds.finddescription FROM userdetails, finds, detectinglocations WHERE finds.userid=userdetails.userid AND finds.locationid=detectinglocations.locationid AND finds.userid = 1 ORDER BY dateoftrip DESC");
if (mysql_num_rows($result) == 0)
// table is empty
echo 'There are currently no finds recorded for this location.';
else
{
while ($row = mysql_fetch_array($result))
{
$dateoftrip = $row['dateoftrip'];
$findname = $row['findname'];
{
}
}
}
?>
<body>
<div class="layer1">
<p class="heading"><input name="dateoftrip" id="dateoftrip" type="text" value="<?php echo $dateoftrip;?>" disabled="disabled"/></p>
<div class="content">
<input name="findname" id="findname" type="text" value="<?php echo $findname;?>" disabled="disabled"/>
</div>
</div>
</body>
</html>
Many thanks and kind regards
You are fetching all the records but using only the last one.
You should put this:
<div class="layer1">
<p class="heading"><input name="dateoftrip" id="dateoftrip" type="text" value="<?php echo $dateoftrip;?>" disabled="disabled"/></p>
<div class="content">
<input name="findname" id="findname" type="text" value="<?php echo $findname;?>" disabled="disabled"/>
</div>
</div>
in the while loop which fetch the data:
while ($row = mysql_fetch_array($result))
{
$dateoftrip = $row['dateoftrip'];
$findname = $row['findname'];
So it will look like this:
while ($row = mysql_fetch_array($result))
{
$dateoftrip = $row['dateoftrip'];
$findname = $row['findname'];
echo '<div class="layer1">
<p class="heading"><input name="dateoftrip" id="dateoftrip" type="text" value="'.$dateoftrip.'" disabled="disabled"/></p>
<div class="content">
<input name="findname" id="findname" type="text" value="'.$findname.'" disabled="disabled"/>
</div>
</div>';
}
You need to put your output inside your loop. Also you may have to modify your javascript to account for the multiple content ids.
You should also make the form controls into arrays so you'll be able to parse them if needed (see below).
For example, this is how to modify the form.
?>
<body>
<div class="layer1">
<?php
while ($row = mysql_fetch_array($result))
{
$dateoftrip = $row['dateoftrip'];
$findname = $row['findname'];
$i++;
?>
<p class="heading"><input name="dateoftrip[]" id="dateoftrip" type="text" value="<?php echo $dateoftrip;?>" disabled="disabled"/></p>
<div class="content">
<input name="findname[]" id="findname" type="text" value="<?php echo $findname;?>" disabled="disabled"/>
<?php
{
}
}
}
?>
</div>
</div>