I am trying to make all $_GET methods into $_POST on this page. I want php?produktid=0 to be invisible on the adress bar.
How can I solve this?
This is an application and I want it to run on its own.
//PREVIOUS BUTTON
$index = $_GET['produktid'];
echo "<td>";
if ($index > 0) {
echo ' <img style="margin-left: 77px;" src="bilder/prev.png"> ';
} else {
echo ' <img style="margin-left: 77px;" src="prev.png"> ';
}
echo "</td>";
//IF I AM ON PAGE ONE, ECHO THIS
if($_GET['produktid']==0){
echo "<p>Page One</p>";
}
//IF I AM ON PAGE TWO, ECHO THIS
if($_GET['produktid']==2){
echo "<p>Page Two</p>";
}
//IF I AM ON PAGE THREE, ECHO THIS
if($_GET['produktid']==3){
echo "<p>Page Three</p>";
}
//NEXT BUTTON
echo "<td>";
if ($index < count($array) - 1) {
echo ' <img style="margin-left: -70px;" src="bilder/next.png"> ';
} else {
echo ' <img style="margin-left: -70px;" src="next.png"> ';
}
echo "</td>";
echo "</table>";
echo "<div>";
?>
HERE IS HOW MY WHOLE PAGE LOOKS LIKE
<!DOCTYPE HTML>
<html lang="sv-SE"/>
<head>
<meta charset="UTF-8"/>
<title>Images</title>
<style media="screen" type="text/css">
tr {display: inline-block;}
td {width: 120px;
height: 90px;
box-sizing: border-box;}
#Latest_products {
height: 280px;
width: 670px;
background-color: grey;
margin-left: auto;
margin-right: auto;
text-align: center;
}
</style>
</head>
<body>
<div id="latest_products">
<?php
error_reporting(0);
echo "<p><h1>New Arrivals</h1></p>";
$mysqli = new mysqli('localhost', 'root', '', 'webshop');
mysql_set_charset("utf-8");
//Identify Photo Sequences
$array = array(
0 => "picture1.jpg",
1 => "picture2.jpg",
2 => "kalle3.jpg",
);
echo "<table>";
//PREV BUTTON
$index = $_GET['produktid'];
echo "<td>";
if ($index > 0) {
echo ' <img style="margin-left: 77px;" src="bilder/prev.png"> ';
} else {
echo ' <img style="margin-left: 77px;" src="bilder/prev.png"> ';
}
echo "</td>";
//FOR PAGE 1 SHOW THIS
if($_GET['produktid']==0){
$res = "SELECT * FROM produktlista ORDER BY produktankomst DESC LIMIT 0,3";
$result = $mysqli->query($res);
while($myRow = $result->fetch_array())
{
echo "<tr>";
echo "<td><a href='./item.php?produktid=".$myRow["produktid"]."'> <img src=".$myRow["produktbild"]." height='132' width='132'> </a> </td>";
echo "<td style='display: block;'><a href='./item.php?produktid=".$myRow["produktid"]."'> <h4>".$myRow["produktnamn"]."</h4></a> </td>";
echo "</tr>";
}
}
//FOR PAGE 2 SHOW THIS
if($_GET['produktid']==1){
$res = "SELECT * FROM produktlista ORDER BY produktankomst DESC LIMIT 1,3";
$result = $mysqli->query($res);
while($myRow = $result->fetch_array())
{
echo "<tr>";
echo "<td><a href='./item.php?produktid=".$myRow["produktid"]."'> <img src=".$myRow["produktbild"]." height='132' width='132'> </a> </td>";
echo "<td style='display: block;'><a href='./item.php?produktid=".$myRow["produktid"]."'> <h4>".$myRow["produktnamn"]."</h4></a> </td>";
echo "</tr>";
}
}
//FOR PAGE 3 SHOW THIS
if($_GET['produktid']==2){
$res = "SELECT * FROM produktlista ORDER BY produktankomst DESC LIMIT 2,3";
$result = $mysqli->query($res);
while($myRow = $result->fetch_array())
{
echo "<tr>";
echo "<td><a href='./item.php?produktid=".$myRow["produktid"]."'> <img src=".$myRow["produktbild"]." height='132' width='132'> </a> </td>";
echo "<td style='display: block;'><a href='./item.php?produktid=".$myRow["produktid"]."'> <h4>".$myRow["produktnamn"]."</h4></a> </td>";
echo "</tr>";
}
}
echo "<td>";
//NEXT BUTTON
if ($index < count($array) - 1) {
echo ' <img style="margin-left: -70px;" src="bilder/next.png"> ';
} else {
echo ' <img style="margin-left: -70px;" src="bilder/next.png"> ';
}
echo "</td>";
echo "</table>";
echo "<div>";
?>
</body>
</html>
After I change it looks like this now, and "PREV" "NEXT" links doesn't work now.
<!DOCTYPE HTML>
<html lang="sv-SE"/>
<head>
<meta charset="UTF-8"/>
<title>Images</title>
<style media="screen" type="text/css">
tr {display: inline-block;}
td {width: 120px;
height: 90px;
box-sizing: border-box;}
#senaste_produkter {
height: 280px;
width: 670px;
background-color: grey;
margin-left: auto;
margin-right: auto;
text-align: center;
}
</style>
</head>
<body>
<div id="senaste_produkter">
<?php
//Databasuppkoppling - Visa senaste produkter ifrån databasen
error_reporting(0);
echo "<p><h1>New Arrivals</h1></p>";
$mysqli = new mysqli('localhost', 'root', '', 'webshop');
mysql_set_charset("utf-8");
//Identify picture sequences
$array = array(
0 => "picture1.jpg",
1 => "picture2.jpg",
2 => "kalle3.jpg",
);
echo "<table>";
//BACK LINK
$index = $_GET['produktid'];
echo "<td>";
if ($index > 0) {
echo '<form action="newarrivals.php"><input type="hidden" name="produktid" value="' . ($index - 1) . '"><input style="margin-left: 77px;" src="bilder/prev.png"></form>';
} else {
echo '<form action="newarrivals.php"><input type="hidden" name="produktid" value="'. (count($array) - 1) . '"> <img style="margin-left: 77px;" src="bilder/prev.png"> </form>';
}
echo "</td>";
//IF I GO TO PAGE 3, SHOW THIS
if($_GET['produktid']==0){
$res = "SELECT * FROM produktlista ORDER BY produktankomst DESC LIMIT 0,3";
$result = $mysqli->query($res);
while($myRow = $result->fetch_array())
{
echo "<tr>";
echo "<td><a href='./item.php?produktid=".$myRow["produktid"]."'> <img src=".$myRow["produktbild"]." height='132' width='132'> </a> </td>";
echo "<td style='display: block;'><a href='./item.php?produktid=".$myRow["produktid"]."'> <h4>".$myRow["produktnamn"]."</h4></a> </td>";
echo "</tr>";
}
}
//IF I GO TO PAGE 2, SHOW THIS
if($_GET['produktid']==1){
$res = "SELECT * FROM produktlista ORDER BY produktankomst DESC LIMIT 1,3";
$result = $mysqli->query($res);
while($myRow = $result->fetch_array())
{
echo "<tr>";
echo "<td><a href='./item.php?produktid=".$myRow["produktid"]."'> <img src=".$myRow["produktbild"]." height='132' width='132'> </a> </td>";
echo "<td style='display: block;'><a href='./item.php?produktid=".$myRow["produktid"]."'> <h4>".$myRow["produktnamn"]."</h4></a> </td>";
echo "</tr>";
}
}
//IF I GO TO PAGE 3, SHOW THIS
if($_GET['produktid']==2){
$res = "SELECT * FROM produktlista ORDER BY produktankomst DESC LIMIT 2,3";
$result = $mysqli->query($res);
while($myRow = $result->fetch_array())
{
echo "<tr>";
echo "<td><a href='./item.php?produktid=".$myRow["produktid"]."'> <img src=".$myRow["produktbild"]." height='132' width='132'> </a> </td>";
echo "<td style='display: block;'><a href='./item.php?produktid=".$myRow["produktid"]."'> <h4>".$myRow["produktnamn"]."</h4></a> </td>";
echo "</tr>";
}
}
echo "<td>";
//NEXT PAGE
if ($index < count($array) - 1) {
echo '<form action="newarrivals.php"><input type="hidden" name="produktid" value="' . ($index + 1) . '"> <img style="margin-left: -70px;" src="bilder/next.png"> </a> ';
} else {
echo '<form action="newarrivals.php"> <img style="margin-left: -70px;" src="bilder/next.png"> </a>';
}
echo "</td>";
echo "</table>";
echo "<div>";
?>
</body>
</html>
You need to use forms instead of links, and put the parameters into hidden inputs. So change
echo ' <img style="margin-left: 77px;" src="bilder/prev.png"> ';
to:
echo '<form action="newarrivals.php" method="post"><input type="hidden" name="produktid" value="' . ($index - 1) . '"><input type="image" style="margin-left: 77px;" src="bilder/prev.png"></form>';
and change all the other links similarly.
Here's the whole rewritten script:
<!DOCTYPE HTML>
<html lang="sv-SE"/>
<head>
<meta charset="UTF-8"/>
<title>Images</title>
<style media="screen" type="text/css">
tr {display: inline-block;}
td {width: 120px;
height: 90px;
box-sizing: border-box;}
#senaste_produkter {
height: 280px;
width: 670px;
background-color: grey;
margin-left: auto;
margin-right: auto;
text-align: center;
}
</style>
</head>
<body>
<div id="senaste_produkter">
<?php
//Databasuppkoppling - Visa senaste produkter ifrån databasen
error_reporting(0);
echo "<p><h1>New Arrivals</h1></p>";
$mysqli = new mysqli('localhost', 'root', '', 'webshop');
mysql_set_charset("utf-8");
//Identify picture sequences
$array = array(
0 => "picture1.jpg",
1 => "picture2.jpg",
2 => "kalle3.jpg",
);
echo "<table>";
//BACK LINK
$index = $_GET['produktid'];
echo "<tr><td>";
if ($index > 0) {
echo '<form action="newarrivals.php" method="post"><input type="hidden" name="produktid" value="' . ($index - 1) . '"><input type="image" style="margin-left: 77px;" src="bilder/prev.png"></form>';
} else {
echo '<form action="newarrivals.php" method="post"><input type="hidden" name="produktid" value="'. (count($array) - 1) . '"> <input type="image" style="margin-left: 77px;" src="bilder/prev.png"> </form>';
}
echo "</td></tr>";
//IF I GO TO PAGE 3, SHOW THIS
if($_GET['produktid']==0){
$res = "SELECT * FROM produktlista ORDER BY produktankomst DESC LIMIT 0,3";
$result = $mysqli->query($res);
while($myRow = $result->fetch_array())
{
echo "<tr>";
echo "<td><a href='./item.php?produktid=".$myRow["produktid"]."'> <img src=".$myRow["produktbild"]." height='132' width='132'> </a> </td>";
echo "<td style='display: block;'><a href='./item.php?produktid=".$myRow["produktid"]."'> <h4>".$myRow["produktnamn"]."</h4></a> </td>";
echo "</tr>";
}
}
//IF I GO TO PAGE 2, SHOW THIS
if($_GET['produktid']==1){
$res = "SELECT * FROM produktlista ORDER BY produktankomst DESC LIMIT 1,3";
$result = $mysqli->query($res);
while($myRow = $result->fetch_array())
{
echo "<tr>";
echo "<td><a href='./item.php?produktid=".$myRow["produktid"]."'> <img src=".$myRow["produktbild"]." height='132' width='132'> </a> </td>";
echo "<td style='display: block;'><a href='./item.php?produktid=".$myRow["produktid"]."'> <h4>".$myRow["produktnamn"]."</h4></a> </td>";
echo "</tr>";
}
}
//IF I GO TO PAGE 3, SHOW THIS
if($_GET['produktid']==2){
$res = "SELECT * FROM produktlista ORDER BY produktankomst DESC LIMIT 2,3";
$result = $mysqli->query($res);
while($myRow = $result->fetch_array())
{
echo "<tr>";
echo "<td><a href='./item.php?produktid=".$myRow["produktid"]."'> <img src=".$myRow["produktbild"]." height='132' width='132'> </a> </td>";
echo "<td style='display: block;'><a href='./item.php?produktid=".$myRow["produktid"]."'> <h4>".$myRow["produktnamn"]."</h4></a> </td>";
echo "</tr>";
}
}
echo "<tr><td>";
//NEXT PAGE
if ($index < count($array) - 1) {
echo '<form action="newarrivals.php" method="post"><input type="hidden" name="produktid" value="' . ($index + 1) . '"> <input type="image" style="margin-left: -70px;" src="bilder/next.png">';
} else {
echo '<form action="newarrivals.php" method="post"> <input type="image" style="margin-left: -70px;" src="bilder/next.png">';
}
echo "</td></tr>";
echo "</table>";
echo "<div>";
?>
</body>
</html>
<?php
mysql_connect("localhost", "user", "pass") or die(mysql_error());
mysql_select_db("database") or die(mysql_error());
$data = mysql_query("SELECT * FROM something ORDER by date_sent DESC")
or die(mysql_error());
while($info = mysql_fetch_array( $data ))
{
Print "<table width='1200px' border='0' cellspacing='0' cellpadding='0'>";
Print "<tr id='data'>";
Print "<div class='border'>";
Print "<td width='80px'><div align='center'>".$info['case_number'] ."</div></td>";
Print "<td width='80px'><div align='center'>".$info['credit_number'] . "</div></td>";
Print "</tr>";
Print "</table>";
}
?>
I want to make case_number link to ID
I made: <td width='80px'><div align='center'> <a href='edit.php?id=".$info['id'] ."'> ".$info['case_number'] ." </a> </div></td>";
but it do not work.
Can you explain how can I make this work? Thank you
This is a clone site I make like www.teensnow.com. That works pretty good, but I don't wont open the target page.And this case is www.xhamster.com. So I wont open a page my and embed the movies in that page! Please take a look on the script ?>
<?php
$coneta = mysql_connect('localhost','root','') or die(mysql_error());
$banco = mysql_select_db('database');
?>
this layer is the target where the thumbs stay
<div align="center" id="box">
<div align="center" id="carrosel" style="width: 90%">
<?php // here is the pagination
$totalthumbsperpage = 64;
$page = (isset($_GET['pagina'])) ? (int)$_GET['pagina'] : 1;
$begin = ($totalthumbsperpage * $page) - $totalthumbsperpage;
$sql = "SELECT * FROM rowname ORDER BY thumb DESC LIMIT $begin, $totalthumbsperpage";
$qr = mysql_query($sql) or die(mysql_error());
while($ln = mysql_fetch_assoc($qr)){
?>
here is where the thumbs is showing on a page. But like you can see, I have the url open in a new page, that's good. But that urls is out of site my site and I want open the movie embedded on a page my.
<a href="<?php echo $ln['url'];?><img src="<?php echo $ln['thumb'];?></a>
<?php
}
?>
</div>
<div align="center">
<?php
$sqlTotal = "SELECT thumb FROM rowname";
$qrTotal = mysql_query($sqlTotal) or die(mysql_error());
$numTotal = mysql_num_rows($qrTotal);
$totalPagina= ceil($numTotal/$totalthumbsperpage);
for($i = 1; $i <= $totalPagina; $i++){
if($i == $pagina)
echo $i";}?>
</div><br><br>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.1/jquery.min.js" type="text/javascript"></script>
<script src="jquery.tablesorter.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function()
{
$("#csv_table").tablesorter();
}
);
</script>
</head>
<body>
<form action="<?php echo $_SERVER['PHP_SELF'];?>" method="post" enctype="multipart/form-data" name="import">
<label for="input_import_file">Umístění CSV souboru:</label>
<input name="import_csvfile" id="import_csvfile" type="file">
<input name="csvsubmit" id="csvsubmit" type="submit">
</form>
<?php
if($_FILES['import_csvfile']['tmp_name']){
echo '<table id="csv_table" width="100%" border="1" cellspacing="5" cellpadding="0">';
$handle = fopen($_FILES['import_csvfile']['tmp_name'], "r");
while (($data = fgetcsv($handle, 1000, ",")) !==FALSE) {
$num = count($data);
echo "<tr>";
for ($c=0; $c < $num; $c++) {
echo "<td> ".$data[$c]."</td>"."\n";
}
echo "</tr>";
}
fclose($handle);
echo "</table>";
}
?>
</body>
</html>
How can I setup and for this table generated from CSV file?
Table is generates using loop (for and while function) and I don't know how to setup first line as or if I should setup table static.
Please help me I am beginner.
Thanks in advance
If your headers are known, you can do as follows:
echo '<table id="csv_table" width="100%" border="1" cellspacing="5" cellpadding="0">';
echo '<tr><th>Header 1</th><th>Header 2</th><th>Header 3</th>...</tr>'
$handle = fopen($_FILES['import_csvfile']['tmp_name'], "r");
Otherwise if your headers come in the CSV file you can determine if you're in the first row using a counter variable:
$counter = 0;
while (($data = fgetcsv($handle, 1000, ",")) !==FALSE) {
$num = count($data);
echo "<tr>";
for ($c=0; $c < $num; $c++) {
if($counter == 0)
{
echo "<th> ".$data[$c]."</th>"."\n";
}else{
echo "<td> ".$data[$c]."</td>"."\n";
}
}
echo "</tr>";
counter++;
}
Note that replacing the while loop with a for loop will have the same benefit.
I have a document that uses PHP to generate a list from a DB
$q = "SELECT * FROM display ORDER BY diplay_order ASC";
$r = #mysqli_query ($dbc, $q);
echo "<ul id='categoryorder'>";
while ($item = mysqli_fetch_array($r)) {
echo "<li><div id='" . $item['ad_type'] . "_" . $item['unique_id'] . "'>
<form name='remove' action='saveable.php' method='get'>
<input type='submit' value='remove' />
<input type='hidden' name='id' value='" . $item['unique_id'] . "'>
</form>" .$item['unique_id'] . "</div></li>";
}
echo "</ul>";
I have then made these sortable which works fine but I can't get the serialize to work and it just creates an empty array.
$(document).ready(function() {
$('ul#categoryorder').sortable({
update: function() {
var order = $("ul#categoryorder").sortable("serialize");
alert(order);
}
});
});
Then the alert box just comes up empty. I am very new to this and any help would be much appreciated.
You need to add id to <li> tag. Change this part of PHP code,
echo "<li id='" . $item['ad_type'] . "_" . $item['unique_id'] . "'><div><form name='remove' action='saveable.php' method='get'><input type='submit' value='remove' /><input type='hidden' name='id' value='" . $item['unique_id'] . "'></form>" .$item['unique_id'] . "</div></li>";
Added id to <li>.