While data is fetched add link with href to ID - hyperlink

<?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

Related

$_POST and $_GET

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>

How to open a embed movie from mydabase using PHP

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>

comment with no spaces will destroy my table comment

$display = mysql_query("SELECT * FROM table_comment WHERE blogid=$theID ORDER BY comment_id DESC")or die(mysql_error());
echo "<table border='0' align='center' width='900px' style='margin-bottom:20px;margin-top:-20px;background-color:brown;border-top-left-radius:50px;border-top-right-radius:15px;border-bottom-left-radius:15px;border-bottom-right-radius:50px;'>";
while($r = mysql_fetch_array($display))
{
echo "<tr>";
echo "<td align='left' style='font-size:15px;padding-left:25px;color:PowderBlue'><b style='color:LightGreen'><i>".$r['post_name']."</b></i> said:</td>";
echo "<td align='right' style='font-size:15px;padding-right:25px;'><b style='color:Yellow'>".$r['Time']."</b>&nbsp <b style='color:Orange'>".$r['Date']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td align='justify' style='color:White;font-size:20px;padding-left:25px;'> ".$r['comment_area']."</td>";
echo "</tr>";
echo "<tr>";
echo "<td colspan='2' align='center' style='padding-right:25px;color:Yellow'>_______________________________________________________________________________________________________</td>";
echo "</tr>";
}
echo "</table>";
echo "</div>";
I have this codes for my table comment, but when i try to comment spamming it over the opposite edge of the comment area, without spaces and when i hit the post button, there, some texts in my comment cannot be seen. my table is stretched far out of the original comment table. Someone can help me please?
You can use CSS to fix this problem.
HTML:
<div class="test">Thisisverylonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglonglongspamcomment</div>
CSS:
.test {
word-wrap: break-word;
overflow: hidden;
width:250px;}
Demo: http://jsfiddle.net/NkLuW/

JQuery Sortable\Serialize issue

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>.

How to get downloadable product links after successfull order

After a successfull order I would like to propose directly the downloadable URL for products buyer bought in the success.phtml file.
I wrote this piece of code to know product's values of the latest order:
// Get the latest Order ID
$order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
// Get every products on the latest order
$items = $order->getAllItems();
// Loop the products
foreach ($items as $item){
$product = Mage::getModel('catalog/product')->setStoreId($order->getStoreId())->load($item->getProductId());
// HERE I NEED FUNCTION TO GET DOWNLOADABLE URL LINK
}
I found a solution, here it is:
First, create a new .phtml file in template/downloadable/ , I called mine downloadablelist.phtml
Then copy all of template/downloadable/customer/products/list.phtml in our new downloadablelist.phtml
This will give us a copy of the customer account my downloadable products list.
Call our block in success page :
<?php echo $this->getLayout()->createBlock('downloadable/customer_products_list')->setTemplate('downloadable/checkout/downloadablelist.phtml')->toHtml(); ?>
Now I cleaned up what I don't need from the product list. I removed the table and added a ul instead.
Next is to show only the products that are made from the last order.
<?php
$_items = $this->getItems();
$orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId();
if(count($_items)):
$_group_id = Mage::helper('customer')->getCustomer()->getGroupId();
echo '<p><strong>'.$this->__('Downloadable products').' : </strong></p>'; ?>
<ul style="margin-left: 30px; list-style: disc;">
<?php foreach ($_items as $_item):
$itemOrderId = $_item->getPurchased()->getOrderIncrementId();
if($itemOrderId == $orderId) {?>
<li><?php echo $this->htmlEscape($_item->getPurchased()->getProductName()) ?> - <a href="<?php echo $this->getUrl('downloadable/download/link/', array('id' => $_item->getLinkHash(), '_secure' => true)) ?>" title="<?php echo Mage::helper('downloadable')->__('Start Download') ?>" <?php echo $this->getIsOpenInNewWindow()?'onclick="this.target=\'_blank\'"':''; ?>><?php echo $_item->getLinkTitle() ?></a></li>
<?php }
endforeach; ?>
</ul>
<?php endif; ?>
I changed the url the original downloadable file had to :
href="<?php echo $this->getUrl('downloadable/download/link/', array('id' => $_item->getLinkHash(), '_secure' => true)) ?>"
Thank you
This worked for me:
$links = Mage::getModel('downloadable/link_purchased_item')->getCollection()
->addFieldToFilter('order_item_id', $item->getId());
foreach ($links as $link) {
echo Mage::helper('downloadable')->__('download') .
$this->getUrl('downloadable/download/link',
array('id' => $link->getLinkHash(), '_store' => $order()->getStore(),
'_secure' => true, '_nosid' => true));
}

Resources