Rephrased Question:
I'm updating a web app from a stand alone PHP page to something that is database driven and has admin controls (old page: uoflclimbingclub.com/everestchallenge/elevationcounter/).
I'm using a form on two different pages: an admin page, and a display page. The form sends the value of a hidden input into a variable on the display page that defines a field name in an sql statement.
The returned row of data is used on the display page with a combination of CSS and PHP to display a graph. The display page is also where the data is meant to be updated.
The code executes and displays the page successfully when executed from the admin page, but fails to display the page when executed from the same page, even though the data is successfully updated in the database. Can anyone tell me what I'm doing wrong? I've searched everything I can think of and read PHP documentation to find a solution but no luck so far, I'm still looking for a solution, any help would be much appreciated.
My Code
The admin page that links to the display page: http://shemsimmons.com/uoflclimbingclub/everestchallenge/admin
Here is the code for the display page: setteam.php
<?php
ob_start();
include $_SERVER["DOCUMENT_ROOT"].'/uoflclimbingclub/everestchallenge/inc/conn/ulcc_user.php';
$team = mysqli_real_escape_string($con, $_POST['teamname']);
$increment = "/uoflclimbingclub/images/icons/favicon.png";
$getElevation = "SELECT * FROM everest2014 WHERE team= '$team'";
$result = mysqli_query($con, $getElevation);
echo "The Team Name is:";
echo $team;
while($climbs = mysqli_fetch_assoc($result)){
if(isset($_POST['update'])){
foreach ($_POST as $key => $value){
$$key=$value;
}
$updateElevation = "UPDATE everest2014
SET
rope1=$rope1Climbs,
rope2=$rope2Climbs,
rope3=$rope3Climbs,
rope4=$rope4Climbs,
rope5=$rope5Climbs,
rope6=$rope6Climbs,
rope7=$rope7Climbs,
rope8=$rope8Climbs,
rope9=$rope9Climbs,
rope10=$rope10Climbs,
rope11=$rope11Climbs,
rope12=$rope12Climbs,
rope13=$rope13Climbs
WHERE team='$team'";
$retval = mysqli_query($con, $updateElevation);
if(! $retval ){
die('Could not update data: ' . mysqli_error());
}
header('Location: '.$_SERVER['PHP_SELF']);
mysqli_close($conn);
} else {
?>
<!DOCTYPE html>
<html>
<head>
<title>TEAM <?php echo $team; ?> Counter</title>
<link rel="icon" type="image/png" href="/uoflclimbingclub/images/icons/favicon.png">
<link rel="stylesheet" type="text/css" href="/uoflclimbingclub/everestchallenge/css/elevationstyle.php" />
<script type="text/javascript" src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script type="text/javascript" src="/uoflclimbingclub/everestchallenge/js/adder.js"></script>
<script type="text/javascript" src="/uoflclimbingclub/everestchallenge/js/jscolor/jscolor.js"></script>
<style>
.point {
border-bottom: 25px solid <?php echo $climbs["colour"]; ?>;
}
.shaft, #teambg{
background: <?php echo $climbs["colour"]; ?>;
}
</style>
</head>
<body>
<?php
include $_SERVER["DOCUMENT_ROOT"].'/uoflclimbingclub/everestchallenge/inc/everestVar.php';
include $_SERVER["DOCUMENT_ROOT"].'/uoflclimbingclub/everestchallenge/inc/set_elevation_inc.php';
?>
</body>
</html>
<?php
}
}
mysqli_free_result($result);
?>
The everestVar.php include is just a bunch of simple arithmetic that makes the styles look pretty (div heights, convert number of rope climbs into total metres climbed, etc...)
The other include is the body html:
<!-- Graphic of Everest -->
<img src="/uoflclimbingclub/everestchallenge/img/summit.png">
<div id="everestwrapper"><div id="everestwrap">
<div id="everest"><img src="/uoflclimbingclub/everestchallenge/img/elevationmetre.png"><div id="metres" style="bottom:<?php echo $elevation; ?>%;"><span id="elevation"><?php echo $elevationClimbed; ?></span><img src="/uoflclimbingclub/everestchallenge/img/metres.png"></div></div>
<div id="lightbg"></div>
<div id="teambg" class="everestfill" style="height:<?php echo $elevation; ?>%;"></div>
</div></div>
<img src="/uoflclimbingclub/everestchallenge/img/eventname.png">
<!-- Growing Rope Arrows -->
<div id="ACC">
<form id="climbsInput" action="/uoflclimbingclub/everestchallenge/setteam.php" method="post">
<div id="medWall" class="medWall">
<div id="rope1" style="height:<?php echo $rope1Up; ?>%;">
<div class="point"><?php echo $rope1 ?>m</div>
<div class="shaft">1</div>
<div class="climbCounter ropeInput"><img src="<?php echo $increment; ?>" class="addClimb" /><input type="text" class="climbs" name="rope1Climbs" value="<?php echo $climbs["rope1"]; ?>" /></div></div>
<div id="rope2" style="height:<?php echo $rope2Up; ?>%;">
<div class="point"><?php echo $rope2 ?>m</div>
<div class="shaft">2</div>
<div class="climbCounter ropeInput"><img src="<?php echo $increment; ?>" class="addClimb" /><input type="text" class="climbs" name="rope2Climbs" value="<?php echo $climbs["rope2"]; ?>" /></div></div>
<div id="rope3" style="height:<?php echo $rope3Up; ?>%;">
<div class="point"><?php echo $rope3 ?>m</div>
<div class="shaft">3</div>
<div class="climbCounter ropeInput"><img src="<?php echo $increment; ?>" class="addClimb" /><input type="text" class="climbs" name="rope3Climbs" value="<?php echo $climbs["rope3"]; ?>" /></div></div>
<div id="rope4" style="height:<?php echo $rope4Up; ?>%;">
<div class="point"><?php echo $rope4 ?>m</div>
<div class="shaft">4</div>
<div class="climbCounter ropeInput"><img src="<?php echo $increment; ?>" class="addClimb" /><input type="text" class="climbs" name="rope4Climbs" value="<?php echo $climbs["rope4"]; ?>" /></div></div>
<div id="rope5" style="height:<?php echo $rope5Up; ?>%;">
<div class="point"><?php echo $rope5 ?>m</div>
<div class="shaft">5</div>
<div class="climbCounter ropeInput"><img src="<?php echo $increment; ?>" class="addClimb" /><input type="text" class="climbs" name="rope5Climbs" value="<?php echo $climbs["rope5"]; ?>" /></div></div>
</div>
<div id="longWall" class="tallWall">
<div id="rope6" style="height:<?php echo $rope6Up; ?>%;">
<div class="point"><?php echo $rope6 ?>m</div>
<div class="shaft">6</div>
<div class="climbCounter ropeInput"><img src="<?php echo $increment; ?>" class="addClimb" /><input type="text" class="climbs" name="rope6Climbs" value="<?php echo $climbs["rope6"]; ?>" /></div></div>
<div id="rope7" style="height:<?php echo $rope7Up; ?>%;">
<div class="point"><?php echo $rope7 ?>m</div>
<div class="shaft">7</div>
<div class="climbCounter ropeInput"><img src="<?php echo $increment; ?>" class="addClimb" /><input type="text" class="climbs" name="rope7Climbs" value="<?php echo $climbs["rope7"]; ?>" /></div></div>
<div id="rope8" style="height:<?php echo $rope8Up; ?>%;">
<div class="point"><?php echo $rope8 ?>m</div>
<div class="shaft">8</div>
<div class="climbCounter ropeInput"><img src="<?php echo $increment; ?>" class="addClimb" /><input type="text" class="climbs" name="rope8Climbs" value="<?php echo $climbs["rope8"]; ?>" /></div></div>
</div>
<div id="shortWall" class="shortWall">
<div id="rope9" style="height:<?php echo $rope9Up; ?>%;">
<div class="point"><?php echo $rope9 ?>m</div>
<div class="shaft">9</div>
<div class="climbCounter ropeInput"><img src="<?php echo $increment; ?>" class="addClimb" /><input type="text" class="climbs" name="rope9Climbs" value="<?php echo $climbs["rope9"]; ?>" /></div></div>
<div id="rope10" style="height:<?php echo $rope10Up; ?>%;">
<div class="point"><?php echo $rope10 ?>m</div>
<div class="shaft">10</div>
<div class="climbCounter ropeInput"><img src="<?php echo $increment; ?>" class="addClimb" /><input type="text" class="climbs" name="rope10Climbs" value="<?php echo $climbs["rope10"]; ?>" /></div></div>
<div id="rope11" style="height:<?php echo $rope11Up; ?>%;">
<div class="point"><?php echo $rope11 ?>m</div>
<div class="shaft">11</div>
<div class="climbCounter ropeInput"><img src="<?php echo $increment; ?>" class="addClimb" /><input type="text" class="climbs" name="rope11Climbs" value="<?php echo $climbs["rope11"]; ?>" /></div></div>
<div id="rope12" style="height:<?php echo $rope12Up; ?>%;">
<div class="point"><?php echo $rope12 ?>m</div>
<div class="shaft">12</div>
<div class="climbCounter ropeInput"><img src="<?php echo $increment; ?>" class="addClimb" /><input type="text" class="climbs" name="rope12Climbs" value="<?php echo $climbs["rope12"]; ?>" /></div></div>
<div id="rope13" style="height:<?php echo $rope13Up; ?>%;">
<div class="point"><?php echo $rope13 ?>m</div>
<div class="shaft">13</div>
<div class="climbCounter ropeInput"><img src="<?php echo $increment; ?>" class="addClimb" /><input type="text" class="climbs" name="rope13Climbs" value="<?php echo $climbs["rope13"]; ?>" /></div></div>
</div>
<?php echo "<input type='hidden' name='teamname' value='" . $climbs['team'] . "' />"; ?>
<div style="clear:both;padding-top:80px;"><input name="update" type="submit" value="Update Elevation"/></div>
</form>
</div><!-- End ACC -->
Original Question:
I have some code that works and doesn't work. It works when executed from an external page, but doesn't work when executed from the same page.
<input type='hidden' name='name' value='value' />
The input above is passing a value to a PHP page that loads data from an SQL database. The value is stored in a variable that is used in a couple SQL statements.
$name = mysqli_real_escape_string($con, $_POST['name']);
$select = "SELECT * FROM table WHERE `name`= '$name'";
$update = "UPDATE table SET (multiple fields) WHERE `name`='$name'";
It works perfect from the external page, but when I try to update the data from the same page, using the same input field then strange things happen. The value does not appear to be being passed, but somehow the database is successfully updating.
When I say it doesn't appear to be being passed I mean I've put echo statements all over my code to find where it's breaking and no where does that variable have a value, the page loads blank as if the variable had no value, the page is not displaying (content and styles depend on the database), but for some reason the data is successfully being sent. I can hit the back button on my browser and refresh the page and the data refreshes to show the updates.
I can't wrap my head around why the variable would work for the outgoing data, but not for the incoming data, and show no value. Does anyone have any initial clues as to what might be going on?
If the page refreshes to show the updates when you hit the back button, then refreshing the page would be the solution.
To refresh the page, the following PHP code should work:
header('Location: currentURL');
Check the action atributte in the form element. Make sure it is set to the name of the file you are working on.
The page is blank because there is an internal error with your php script. Until you fix the problem, nothing is going to be displayed.
Try this..
if ($_POST['submit']){
... code to update database here...
}
Related
I have a PhP shopping cart for autoparts and I need to be able to enlarge the retrieved image upon clicking on it. The problem is I can't manually assign an ID to every picture because I'm echoing them from the database.
I've tried assigning one ID/class to all the pictures that get retrieved and enlarge them on click using the JS function but can't get it working.
$items_array = $db_controller->runQuery("SELECT * FROM mystuff ORDER BY ID ASC");
if (!empty($items_array)) {
foreach($items_array as $key=>$value){
?>
<div class="DisplayCartItems">
<form method="post" action="?action=add&mscode=<?php echo $product_array[$key]["mscode"]; ?>">
<img src="<?php echo $product_array[$key]["msimage"]; ?>" class="imgcartdisplay" align="alignnone"/> /* Right here I need some help */
<div class="lif"><strong>Category:</strong> <?php echo $product_array[$key]["mscategory"]; ?></div>
<div class="lif"><strong>Category №:</strong> <?php echo $product_array[$key]["mscatnum"]; ?></div>
<div class="lif"><strong>Stock №:</strong> <?php echo $product_array[$key]["msnomer"]; ?></div>
<div class="lif"><strong>Mark:</strong> <?php echo $product_array[$key]["msmark"]; ?></div>
<div class="lif"><strong>Model:</strong> <?php echo $product_array[$key]["msmodel"]; ?></div>
<div class="lif"><strong>Year:</strong> <?php echo $product_array[$key]["msyear"]; ?></div>
<div class="lif"><strong>Price:</strong> <?php echo "$".$product_array[$key]["msprice"]; ?></div>
<div style="text-align:center"><input type="number" name="oap" placeholder="Offer a price:"></div>
<br class="">
<div class="cartan">
Quantity: <input type="text" class="product-quantity" name="quantity" value="1" size="2" />
<br class="">
<input type="submit" onclick="AddCartAlert()" value="Add to cart" /></div>
</form>
</div>
<?php
}
}
?>```
I think if I can somehow assign an ID or class name for every picture that get displayed from the MySql and onclick change it's width/height, that'd do the job.
If I have correctly understood:
you should replace this:
<img src="<?php echo $product_array[$key]["msimage"]; ?>" class="imgcartdisplay" align="alignnone"/> /* Right here I need some help */
with:
<a target="_blank" href="<?php echo $product_array[$key]["msimage"]; ?>"><img src="<?php echo $product_array[$key]["msimage"]; ?>" class="imgcartdisplay" align="alignnone"/></a>
for opening the image in another tab.
Or... if you mean something like this https://lokeshdhakar.com/projects/lightbox2/#examples you have to use javascript (for example: Image #1)
In your case something like this: (of course you need to add lightbox script: https://lokeshdhakar.com/projects/lightbox2/#getting-started)
<a data-lightbox="image-1" data-title="My caption" href="<?php echo $product_array[$key]["msimage"]; ?>"><img src="<?php echo $product_array[$key]["msimage"]; ?>" class="imgcartdisplay" align="alignnone"/></a>
I am trying to figure out how to change the photo without the page refreshing. I have seen some of the example but just cannot figure out how to implement it in to my working page.
This is what I have right now:
<div id="propertyDetailsImage">
<img class="image photo" src="<?php echo $property->photos->photo[$mainPhoto - 1]->url; ?>" width="<?php echo $property->mainPhotoWidth * 0.77 ?>" height="<?php echo $property->mainPhotoHeight * 0.77 ?>" alt="<?php echo $property->address->full; ?>"/>
</div>
<div class="photoPosition">
<?php
$previousPhoto = $mainPhoto - 1;
if($previousPhoto == 0) {
$previousPhoto = $property->totalPhotos;
}
$nextPhoto = $mainPhoto + 1;
if ($nextPhoto > $property->totalPhotos) {
$nextPhoto = intval(1);
}
?>
<img src="images/previous.png" alt="Previous photo" height="12" width="13" border="none"/>
<span id="photoPosition"><?php echo $mainPhoto; ?></span> of <?php echo $property>totalPhotos; ?>
<img src="images/next.png" alt="Next photo" height="12" width="13" border="none" />
</div>
</div>
<div class="col-md-6">
<div id="thumbnails">
<h3 class="additional">Photos</h3>
<?php
// Iterate throught the list of photos
foreach($property->photos->photo as $photo) {
?>
<script type="text/javascript">
addPhoto(
<?php echo $photo->id; ?>,
<?php echo $photo->width; ?>,
<?php echo $photo->height; ?>,
"<?php echo $photo->caption; ?>");
</script>
<img src="<?php echo $photo->url; ?>" width="<?php echo $photo->widthSmall; ?>" height="<?php echo $photo->heightSmall; ?>" class="image photo" id="photo<?php echo $photo->position; ?>" alt="Additional Photo of <?php echo $photo->address->advertising; ?>" onclick="return showPhoto(<?php echo $photo->position; ?>)" />
<?php }
?>
Any help is appreciated. Cheers
Dima
You should use ajax to get like this results.
you should go here,
The image slider shown in this demo is for free.
For detailed instructions, please visit online
http://www.menucool.com/slider/javascript-image-slider-demo1
Here is my code, it basically grabs $banners and displays them out, there are 2 at the moment, however , it stops after the first one and displays out the html div id="footerNews... etc and carries on again after that. This is correct...
<?php if ($banners) { $i = 1; ?>
<div id="footerBanners">
<?php foreach ($banners as $banner) { ?>
<img src="<?php echo $banner['image']; ?>" alt="<?php echo $banner['title']; ?>" />
<?php if ($i == 1) { ?>
<div id="footerNewsletter">
<p>Newsletter Sign Up</p>
Go
<input type="text" name="email" placeholder="Email address" />
</div>
<div id="footerEvents"><?php echo $text_events; ?></div>
<?php } ?>
<?php $i++; } ?>
</div>
<?php } ?>
The problem is that some of variables in $banners dont actually have a link. To get around this, I attempted to put an if statement in to not display <a href> if there is no link. however this messes up the order that of the content, its important that I keep the content in the correct order as above ^. Here was my attempt.
<?php if ($banners) { $i = 1; ?>
<div id="footerBanners">
<?php foreach ($banners as $banner) { ?>
<?php if ($banner['link'] == '') { ?>
<img src="<?php echo $banner['image']; ?>" alt="<?php echo $banner['title']; ?>" /><?php }
else { ?>
<img src="<?php echo $banner['image']; ?>" alt="<?php echo $banner['title']; ?>" /><?php } ?>
<?php } ?>
<?php if ($i == 1) { ?>
<div id="footerNewsletter">
<p>Newsletter Sign Up</p>
Go
<input type="text" name="email" placeholder="Email address" />
</div>
<div id="footerEvents"><?php echo $text_events; ?></div>
<?php } ?>
<?php $i++; } ?>
</div>
While the code does what it says its supposed to do, its not displaying the correct order anymore, its displaying the 1 linkable $banner then the html, and THEN the image(ie the second $banner with no link. However I need it to display in the same layout as the first bit of code.
Here is the outputted html code, although the image is appearing last on the site.
<div id="footerBanners">
<img src="http://mysite.com/image/data/banner4.jpg" alt="Free Delivery" />
<img src="http://mysite.com/image/data/banner5.jpg" alt="Gift Vouchers" /> <div id="footerNewsletter">
<p>Newsletter Sign Up</p>
Go
<input type="text" name="email" placeholder="Email address" />
</div>
<div id="footerEvents">EVENTS</div>
</div>
Any pointers?
<?php if ($banners) {
echo '<div id="footerBanners">';
foreach ($banners as $banner) {
if ($banner['link'] == '') {
echo '<img src="'.$banner['image'].'" alt="'.$banner['title'].'" />';
}
else {
echo '<img src="'.$banner['image'].'" alt="'.$banner['title'].'" />';
}
if ($first_banner != 'displayed') {
echo '<div id="footerNewsletter">
<p>Newsletter Sign Up</p>
Go
<input type="text" name="email" placeholder="Email address" />
</div>
<div id="footerEvents">'.$text_events.'</div>';
$first_banner = 'displayed';
}
}
echo '</div>';
}
?>
Is there a way to echo the short description foreach related product?
I've tried to use this code but it doesn't display the description of each product:
<?php echo nl2br($this->getProduct()->getDescription()) ?>
also
<?php echo $_helper->productAttribute($_item, nl2br($_item->getShortDescription()), 'short_description') ?>
Is there a way to do this for related products? If anyone knows please point me in the right direction.
<?php if($this->getItems()->getSize()): ?>
<div class="block block-related">
<div class="block-title">
<strong><span><?php echo $this->__('Related Products') ?></span></strong>
</div>
<div class="block-content">
<p class="block-subtitle"><?php echo $this->__('Check items to add to the cart or add to your wishlist') ?> <br /></p>
<div class="form-horizontal">
<?php foreach($this->getItems() as $_item): ?>
<div class="control-group">
<label for="related-checkbox<?php echo $_item->getId() ?>" class="control-label">
<a class="fancybox static-thumbs pull-left" href="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(500, 450); ?>" title="<?php echo $this->htmlEscape($_item->getName()) ?>" ><img src="<?php echo $this->helper('catalog/image')->init($_item, 'small_image')->resize(135, 135) ?>" width="135" height="135" alt="<?php echo $this->htmlEscape($_item->getName()) ?>" /></a>
</label>
<div class="controls">
<label class="checkbox">
<?php if(!$_item->isComposite() && $_item->isSaleable()): ?>
<?php if (!$_item->getRequiredOptions()): ?>
<input type="checkbox" class="checkbox related-checkbox" id="related-checkbox<?php echo $_item->getId() ?>" name="related_products[]" value="<?php echo $_item->getId() ?>" />
<?php endif; ?>
<?php endif; ?>
<?php if ($this->helper('wishlist')->isAllow()) : ?>
<span class="icon-check"></span>
<p class="product-name span6">
<?php echo $this->htmlEscape($_item->getName()) ?>
<br />
<?php echo nl2br($this->getProduct($_item)->getDescription()) ?>
</p>
<form action="<?php echo $this->getAddToCartUrl($_item) ?>" method="post">
<fieldset>
<label class="product-name"><?php echo $this->__('Quantity:'); ?></label>
<select name="qty" class="span1">
<?php $i = 1 ?>
<?php do { ?>
<option value="<?php echo $i?>">
<?php echo $i?>
<?php $i++ ?>
</option>
<?php } while ($i <= (int)Mage::getModel('cataloginventory/stock_item')->loadByProduct($_item)->getMaxSaleQty()) ?>
</select>
<div class="clearfix"></div>
<button class="btn btn-danger" data-loading-text="PLease wait..."><span><?php echo $this->__('Add to Cart') ?></span></button>
<span id='ajax_loader' style='display:none'><img src='<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif')?>'/></span>
</fieldset>
</form>
<?php endif; ?>
<?php echo $this->getPriceHtml($_item, true, '-related') ?>
</label>
</div>
</div>
<hr />
<?php endforeach ?>
</div>
</div>
Have you tried nl2br($this->getProduct($_item)->getShortDescription()) ?
It might be that the value for short description isn't loaded for related products by default. You could try to do a $_item->load($_item->getId()) and then use $_item->getShortDescription().
after TRYING $_item->load($_item->getId()) and echoing the shortDescription, you should look for the Collection where the related products are loaded. In this collection the attribute short_description is not loaded with.
If you load every product, you make a lot of queries to the database which will cost a lot of performance. This is not needed. The alternative is:
$relatedProductCollection->addAttributeToSelect('short_description');
The question is to find the $relatedProductCollection.
UPDATE:
I dug into the code (Reference is v. 1.7.0.2):
// app/code/core/Mage/Catalog/Block/Product/List/Related.php:61
$this->_addProductAttributesAndPrices($this->_itemCollection);
// app/code/core/Mage/Catalog/Block/Product/Abstract.php:410
$collection
->addAttributeToSelect(Mage::getSingleton('catalog/config')->getProductAttributes())
// app/code/core/Mage/Catalog/Model/Config.php:260
$this->getAttributesUsedInProductListing()
This should be interpreted as: When the "related products" are loaded, all attributes are loaded, which are used in the product listing as well. The problem might be: short_desciption is loaded by default. So remove the load() call and check, wether the attribute short_description is "Used in Product Listing". If this is set to yes, My interpretation is wrong.
None the less, the solution by loading every product is crap.
EDIT:
I have added the following line to Related.php
$this->_itemCollection = $product->getRelatedProductCollection()
->addAttributeToSelect('required_options')
->addAttributeToSelect('short_description')
->setPositionOrder()
->addStoreFilter()
And using this line does echo a descrtiption foreach product but it is the Same description getProduct()->getDescription()) ?>
You need to <?php echo ($this->getProduct()->getShortDescription()) ?>
But editing the core code is a bad way to change the magento behaviour as well. Here is described how to rewrite a block, but I don't think this is necessary. http://prattski.com/2010/06/24/magento-overriding-core-files-blocks-models-resources-controllers/
I have box for dynamic images and desc slider using nivoslider. Now I have big problem -> my PHP code is:
<div id="slider" class="nivoSlider">
<?php
$featured = mysql_query("SELECT * FROM featured WHERE order > 0 ORDER BY order ASC");
$count_featured = mysql_num_rows($featured);
if ($count_featured < 1) { echo "error data" }
while ($swcms = mysql_fetch_assoc($featured)) { ?>
<img width="500" height="170" src="<?php echo "$swcms[image]"; ?>" title="#<?PHP echo "$swcms[id]"; ?>" alt="" border="" />
<div id="<?PHP echo "$swcms[id]"; ?>" class="nivo-html-caption"><?PHP echo "$swcms[desc]"; ?> </div>
<?php $c++; }?>
</div>
This Worked 100% But in firebug I see many GET undefined request after each slide:
I found the problem; nivoslider worked with this method for show images/desc (caption):
<div id="slider" class="nivoSlider">
<img src="..." title="#id" />
</div>
<div id="id" class="nivo-html-caption"></div>
And my PHP loop is:
<div id="slider" class="nivoSlider">
<img src="..." title="#id" />
<div id="id" class="nivo-html-caption"></div>
</div>
How do I fix this PHP code for nivoslider loop?
<div id="slider" class="nivoSlider">
<?php
$featured = mysql_query("SELECT * FROM featured WHERE order > 0 ORDER BY order ASC");
$count_featured = mysql_num_rows($featured);
$captions = '';
if ($count_featured < 1) { echo "error data" }
while ($swcms = mysql_fetch_assoc($featured)) { ?>
<img width="500" height="170" src="<?php echo "$swcms[image]"; ?>" title="#<?PHP echo "$swcms[id]"; ?>" alt="" border="" />
<?php $captions .= '<div id="' . $swcms[id] .'" class="nivo-html-caption"' . $swcms[desc] .'</div>'; ?>
<?php $c++; }?>
</div>
<?php echo $captions; ?>