Hello friends,
I've written a code in which one can upload images and these images show up in the homepage of my website as links to some page controlled by admin. The images either link to the url added in the admin section or if no url is added then it links to a page called details.php which has some text.
Now, my problem is that sometimes i need to images just as images and not to link to any page. For this, i've created a checkbox so that if it is checked, then it would be a link else it wud be just an image - not clickable.
My code for not clickable images is not wrkng. Pls go thorugh the code below and let me know, whr am i making a mistake.
Pls frends, i need u to help me with this, like the way u helped me for my other problems.
Here is my code:
$query = "SELECT * FROM promos ORDER BY promo_order";
$result = mysql_query($query);
while( $ltrs = mysql_fetch_array($result) )
{
$promo_id[] = $ltrs[0];
$title = $ltrs['title'];
$details[] = $ltrs[2];
$url[] = $ltrs[3];
$make_link = $ltrs['make_link'];
}
if( empty($ltrs) )
{
$nope = 1;
}
if( !empty( $_POST['promo_id'] ) )
{
$promoSelected = $_POST['promo_id'];
$promoKey = array_search($promoSelected, $promo_id);
$titleSelected = $title[$promoKey];
$detailsSelected = $details[$promoKey];
$urlSelected = $url[$promoKey];
}
else
{
$promoSelected = $promo_id[0]; // because of ORDER BY, most current newsletter is the first entered into array.
$titleSelected = $title[0];
$detailsSelected = $details[0];
$urlSelected = $url[0];
}
$nlDirBase = "img/";
$nlFileBase = "promo_id_";
foreach($promo_id as $fileid)
{
$testFileName = $nlDirBase . $nlFileBase . $fileid . "_";
if( file_exists($testFileName . ".jpg") )
{ $nlFilename[] = $testFileName . ".jpg"; }
elseif( file_exists($testFileName . ".png") )
{ $nlFilename[] = $testFileName . ".png"; }
elseif( file_exists($testFileName . ".gif") )
{ $nlFilename[] = $testFileName . ".gif"; }
}
clearstatcache();
for( $i = 0; $i < sizeof($promo_id); $i++ )
{
if($make_link!="on")
{
$archiveOutStr .= '<div class="contentdiv">';
$archiveOutStr .= '<a href="#" alt="' . $title[$i] . '" onclick="selectNewsletter(' . $promo_id[$i] . ')"/><img src='. $nlFilename[$i] . ' class="promophoto">';
$archiveOutStr .= '</div>';
}
else
{
$archiveOutStr .= '<div class="contentdiv">';
$archiveOutStr .= '<img src='. $nlFilename[$i] . ' class="promophoto"></a>';
$archiveOutStr .= '</div>';
}
}
?>
<form action="details1.php" method="post" />
<input type="hidden" id="promo_id" name="promo_id" value="0" />
</form>
Thank you.