After clicking the VIEW button and nothing happening, I started to wonder what's wrong?
GALLERIES NAME POST EDIT DELETE
Slideshow VIEW
SERVICES POST VIEW
Code:
<?php foreach ($gallery as $gallery_item): ?>
<tr>
<td><?php echo $gallery_item['galleries_name']; ?></td>
<td>
<?php if( $gallery_item['galleries_post_type'] == 'post') { echo "#"; }?>
</td>
<td>
<button type="button" class="edit" onclick="location.href = '
<?php
if( $gallery_item['galleries_post_type'] == 'post') {
echo site_url('cpages/galleries/'.$gallery_item['galleries_id']);
} else {
echo site_url('cpages/viewpictures/'.$gallery_item['galleries_id']);
}
?>
';">VIEW</button>
</td>
I think you should use links and describe them as button (role, type, whatsoever) and decore them with CSS. That is:
<?php
$id = $gallery_item['galleries_id']);
?>
<td>
<?php if ($gallery_item['galleries_post_type'] === 'post'): ?>
<a href="<?= site_url('cpages/galleries/'.$id); ?>" class="edit">
<?php elseif (): ?>
<a href="<?= site_url('cpages/viewpictures/'.$id); ?>" class="edit">
<?php endif; ?>
</td>
By searching for a better solution, I found an answer from BalusC that, I think, should solve your problem and help you understand how/what/when questions about buttons, links and so one.
Related
I'm planning to create a header navigate bar for both user & admin with different content. If it is the user, so they will only see the Log out button. If it is the Admin, they will see button "Usermanagement" and "Logout" using php. For now I didn't to manage to ensure that the php read the status of current user. 'roles' = 'Y' is consider as admin, i store it inside mssql. Below is my code.
<?php if( isset($_SESSION['username']) && !empty($_SESSION['username']))
{ ?>
<a class="right" href="logout.php">Log Out</a>
<?php if( isset($_SESSION['roles']) && $_SESSION['roles']===['Y']) ?>
<a class="right" href="userManagement.php">User Profile</a>
<?php }else{ ?>
<a class="right" href="login.php">Login</a>
<a class="right" href="register.php">Register</a>
<?php } ?>
any help would highly appreciated, i've been searching and applying many code since last 4 days, none of the code working.
I'm not sure if you want this or not.
<?php if (isset($_SESSION['username']) && !empty($_SESSION['username'])) { ?>
<a class="right" href="logout.php">Log Out</a>
<?php if ($_SESSION['roles'] === "Y") { ?>
<a class="right" href="userManagement.php">User Profile</a>
<?php } ?>
<?php } else { ?>
<a class="right" href="login.php">Login</a>
<a class="right" href="register.php">Register</a>
<?php } ?>
To conditionally output HTML code you need to echo it from PHP. Here's what I think you want. I have kept your formatting
<?php
if( isset($_SESSION['username']) && !empty($_SESSION['username']))
{echo '<a class="right" href="logout.php">Log Out</a>';}
if( isset($_SESSION['roles']) && $_SESSION['roles']===['Y'])
{echo '<a class="right" href="userManagement.php">User Profile</a>';}
else
{echo '<a class="right" href="login.php">Login</a>';
echo '<a class="right" href="register.php">Register</a>';}
?>
I have some working PHP code and I have recently added a button that allows the user to download the image form the root directory, in the database we put the file name e.g. example.png / example.jpeg and when the user clicks download it opens the image in a new tab
what we need is: if the [proof] is= NULL , the download button disables, otherwise it will be enabled and they can click the button
<?php
// output data of each row
while($row=mysqli_fetch_assoc($designresult)) {
?>
<div class="card mb-4 box-shadow"><div class="card-header">
<h4 class="my-0 font-weight-normal">Job Reference: <?php echo $row["jobRef"]; ?></h4>
</div>
<div class="card-body">
<p><b>Company Name:</b><br> <?php echo $row["companyName"]; ?> </p>
<p><b>Requested:</b><br> <?php echo $row["dateReq"]; ?> </p>
<p><b>Request By:</b><br> <?php echo $row["yourName"]; ?> </p>
<p><b>Graphic Type:</b><br> <?php echo $row["graphicType"]; ?> </p>
<p><b>Double Sided:</b><br> <?php echo $row["doubleS"]; ?> </p>
<p><b>Design Info:</b><br> <?php echo $row["info"]; ?> </p>
<p><b>Purpose:</b><br> <?php echo $row["purpose"]; ?> </p>
<p><b>Proof:</b><br> <?php echo $row["approved"]; ?> </p>
<p><b>Proof Date:</b><br> <?php echo $row["appDate"]; ?> </p>
<a class="btn btn-success" target="_blank" href="<?php echo IMAGE_DIR . $row['proof']; ?>">Download</a>
</div>
</div>
<?php
}
?>
To my knowledge the link tag does not have a "disabled" attribute. But you can "disable" the link by removing the href attribute.
Something like this: It checks if $row['proof'] has some value (by negating the empty), then it prints out the href if result is true.
<a class="btn btn-success" target="_blank" <?php if(!empty($row['proof'])): ?> href="<?php echo IMAGE_DIR . $row['proof']; ?>" <?php endif; ?> >Download</a>
Or maybe better: Check if variable is empty and give the user a hint that it's not available. I think this is the better solution, because then your users will know what's going on.
<?php if(empty($row['proof'])): ?>
<span>No proof available</span>
<?php else: ?>
<a class="btn btn-success" target="_blank" href="<?php echo IMAGE_DIR . $row['proof']; ?>">
Download
</a>
<?php endif; ?>
<a
class="btn btn-success"
target="_blank"
<?php if(empty($row['proof'])) echo "disabled"; ?>
href="<?php if(!empty($row['proof'])) echo IMAGE_DIR . $row['proof']; ?>">
Download
</a>
try above code. and add disabled class using this condition
<?php
$state = (empty($row['proof'])) ? "disabled='disabled'" : "";
$class = (empty($row['proof'])) ? "disabled" : "";
?>
<a class="btn btn-success <?php echo $class; ?>" target="_blank" href="<?php echo IMAGE_DIR . $row['proof']; ?>" <?php echo $state; ?>>Download</a>
To disabled the button, you need to use disabled HTML attribute. The code above checks $row['proof'] == NULL. If this statement is true it prints disabled = "disabled" in the button element and it isn't true, it prints nothing.
Assuming that you are using bootstrap, .disabled will grayed out the button.
I have a section of extra information for the product. In the config you can add a link. This is showing the text of the link, but we want to have a word as a link and not the url to be seen.
For the product additional information there is now 1 working link. (a word that is the link instead of showing the url)
Now for a second field (second link), I want to do the same. When this field is filled with an url, the word "second link" must be the link, but not showing the url. The word "second link" is the link
I tried to change the attributes.phtml but I get lost changing the php code.
<?php foreach ($_additional as $_data): ?>
<tr class="<?php if ($_data['value'] == "No" or $_data['value']== "Nee" or $_data['value'] == "N/A" or $_data['value'] == "Nvt" ){?>no-data-value<?php } ?>">
<th class="label"><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
<td class="data">
<?php if($_data['code'] == 'link'){?>
<?php echo $this->__('Product page manufacturer')?>
<?php }else{?>
<?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?>
<?php }?>
</td>
</tr>
<?php endforeach; ?>
I am trying to do the same for the second field. How do I change this in the php? I tried several things but ends up in a loop showing it twice or i get an error in the syntax.
You may try the code below:
<?php
$links = array('link' => 'Product page manufacturer',
'YOUR_CODE_OF_SECOND_LINK' => 'TEXT_FOR_SECOND_LINK');
foreach ($_additional as $_data): ?>
<tr class="<?php if ($_data['value'] == "No" or $_data['value']== "Nee" or $_data['value'] == "N/A" or $_data['value'] == "Nvt" ){?>no-data-value<?php } ?>">
<th class="label"><?php echo $this->escapeHtml($this->__($_data['label'])) ?></th>
<td class="data">
<?php if(array_key_exists($_data['code'], $links)){
$code = $_data['code']; ?>
<?php echo $this->__($links[$code])?>
<?php }else{?>
<?php echo $_helper->productAttribute($_product, $_data['value'], $_data['code']) ?>
<?php }?>
</td>
</tr>
<?php endforeach; ?>
You will be able to add links' codes and texts to the $links array. It's not very good to edit template files by this way, but it should work.
Here is one <td> tag that has the link to go to marks/details/index/someId,
<td>
<a href="<?php
echo $this->url('marks/details',array('action'=>'index','id'=>$item['studentAcademicId']))
?>">
<?php
if(($item['marksObtained'])!= Null )
{
echo $item['marksObtained'];
}
else {echo 'Add Marks'; };
?>
</td>
I want to add another link, in this same <td> after else {echo 'Add Marks'; } which would go to another link e.g Marks/details/addfromsession/someId
anchor tag is not closed after this you can add anchor. like as below
<td>
<a href="
<?php echo $this->url(
'marks/details',array('action'=>'index','id'=>$item['studentAcademicId']))?>">
<?php if(($item['marksObtained'])!= Null )
{ echo
$item['marksObtained'];}
else {echo 'Add Marks'; };?> </a>
SOME TEXT
</td>
This is the correct way to pass two links in one HTML <td> tag.
<?php foreach ($this->data as $item): ?>
<tr>
<td>
<?php if(isset( $item['marksObtained']) && $item['marksObtained'] > 0){?>
<a href="<?=$this->url( 'marks/details', array('action'=>'index', 'id'=>$item['studentAcademicId']))?>">
<?php echo $item['marksObtained']; ?></a>
<?php }else{ ?>
<a href="<?=$this->url( 'marks/details', array('action'=>'add', 'id'=>$item['studentAcademicId']))?>">
Add Marks</a>
<?php }?>
</td>
</tr>
<?php endforeach;?>
If condition is true, one link is passed, else the other link is passed, So now we have two tags that are working exactly to the question.
I am trying to display data from two different Mysql tables in the same html table. Do do that I have put a while loop inside another while loop. The problem is that in the table the data of the second loop is displayed only on the first raw of the html table. I really don't know what is wrong. Thanks for your help.
<?php
while($results = mysql_fetch_array($raw_results)){
echo '<td>';
echo '<a href="linkto.php?data='.ucfirst($results['song_name']).'" class="iframe"><img src="icons/1384070574_95.png"> ';
echo '<a href="'.ucfirst($results['song_name']).'" class="clapping">';
echo '<img src="icons/Hand-icon.png" id="songs'.$pictureid.'" onClick="action(\'songs'.$pictureid.'\')"/></a>';
echo '</td>';
echo '</tr>';
if (isset($userid)){
echo '<td>
<div id="cssmenu">
<ul>
li class="has-sub><span><img src="icons/1384074758_document_music_add.png"></span>
<ul>
<li class="has-sub"><span>Create a Playlist</span></li>';
while($playlist = mysql_fetch_array($raw_playlist)){
echo'<li class="has-sub"><span>'.ucfirst($playlist['title']).'</span></li>';
}
echo'</ul>
</li>
</ul>
</div>
</td>';
}
echo' </tr>
';
$pictureid = $pictureid + 1;
$songid= $songid + 1;
}
echo '</tbody>';
?>
As mentioned in the comments, you may have a problem with your nested data depending on what you're trying to show.
However, your HTML is a mess, missing some opening and closing tags, which may mean that some data is being sent to the browser but not being displayed. Have you looked at the source of the page in the browser to check the data is not there? Until you do, we cannot be sure whether the missing data is an HTML, SQL or PHP error.
You should try to limit the amount of HTML that you echo from PHP for this reason, and I've tidied it up a bit and added missing tags below. See if that helps at all.
<?php while ($results = mysql_fetch_array($raw_results)) : ?>
<tr>
<td>
<img src="icons/1384070574_95.png">
<img src="icons/Hand-icon.png" id="songs<?php echo $pictureid; ?>" onClick="action('songs<?php echo $pictureid; ?>')" />
</td>
</tr>
<?php if (isset($userid)) : ?>
<tr>
<td>
<div id="cssmenu">
<ul>
<li class="has-sub><span><img src="icons/1384074758_document_music_add.png"></span>
<ul>
<li class="has-sub"><span>Create a Playlist</span></li>
<?php while ($playlist = mysql_fetch_array($raw_playlist)) : ?>
<li class="has-sub"><span><?php echo ucfirst($playlist['title']); ?></span></li>
<?php endwhile; ?>
</ul>
</li>
</ul>
</div>
</td>
<?php endif; ?>
</tr>
<?php
$pictureid++;
$songid++;
endwhile;