I'm getting the web address of pictures on the internet from my database and displaying them back on the page, it is currently displaying the actual web address and not loading the actual picture, is it possible to get the actual picture to be loaded? (on the database the web address of the image is stored as a string)
<tr>
<!--<th>id</th>
<td><?php echo $row['id']; ?></td> -->
<th>Name</th>
<td><?php echo $row['hname']; ?></td>
<th>image</th>
<td><?php echo $row['himage']; ?></td>
<th>Description</th>
<td><?php echo $row['hdesc']; ?></td>
</tr>
What you're looking for is called an img tag. Something like this:
<td><img src="<?php echo $row['himage']; ?>" /></td>
If your image is stored for example in the root in the folder itages, then
<td><img src="/images/<?php echo $row['himage'];?>" /></td>
OR
<td><img src="/images/<?=$row['himage'];?>" /></td>
Related
I have some checkbox in a table that contains the id of that row item. I want to allow the user to select multiple rows. However, I can't seem to check the checkbox on Chrome. I loaded the site up on my mobile and it works. I have tried to insert an onclick but it doesn't seem like the checkbox is registering any clicks to it as well. Please help.
The table
<?php echo form_open_multipart('Events/Two/Search');?>
<table class="table">
<thead>
<tr class="text-left">
<td></td>
<td>Name</td>
<td>Email</td>
<td>Phone Number</td>
<td>Address</td>
</tr>
</thead>
<tbody>
<?php
if(!empty($datatable)){
foreach ($datatable as $data){
?>
<tr>
<td><input type="checkbox" name="id[]" value="<?php echo $data->id; ?>"/></td>
<td><?php echo $data->first_name." ".$data->last_name; ?></td>
<td><?php echo $data->email; ?></td>
<td><?php echo $data->phone_number; ?></td>
<td><?php echo $data->address;?></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
<?php echo form_close(); ?>
EDIT: I have cleared my cache and cookies as well. It works on the mobile but not on chrome for some reason.
EDIT 2 : It works on Safari
EDIT 3 : If I place a checkbox on another place, I can check it. Just not in the table
<tbody>
<?php
if(!empty($datatable)){
foreach ($datatable->result() as $data){
?>
<tr>
<td><input type="checkbox" name="id[]" value="<?php echo $data->id; ?>"/></td>
<td><?php echo $data->first_name." ".$data->last_name; ?></td>
<td><?php echo $data->email; ?></td>
<td><?php echo $data->phone_number; ?></td>
<td><?php echo $data->address;?></td>
</tr>
<?php
}
}
?>
</tbody>
</table>
First Your query is not working it seems so please preview this code the use jquery append to add more row if you need help on that code will be below
Jquery on click ADD/REMOVE ROW please Visit the link below
https://jsfiddle.net/susanadhikary/omngzss8/8/
i have a database named hotel_booking,it contains field named imglinks which stores the link of the images and i am only able to display single image in the site. i want to display a slide show of the images of the respective hotels.
<tr>
<th>NAME OF HOTELS</th>
<th>CATEGORY</th>
<th>DESCRIPTION</th>
<th>ADDRESS</th>
<th>GALLERY</th>
</tr>
<?php
while($row=mysql_fetch_array($query))
{
$f1=$row['name'];
$f2=$row['category'];
$f3=$row['description'];
$f4=$row['address'];
?>
<tr>
<td><?php echo $f1 ?></td>
<td><?php echo $f2 ?></td>
<td><?php echo $f3 ?></td>
<td><?php echo $f4 ?></td>
<td><img src="<?php echo $row['imglinks'];?>" height="200" width="55"></td>
link to image of what i want to achieve
You can use bootstrap to achieve this easily with a few lines of code.
http://getbootstrap.com/javascript/#carousel
Go through this link and if there is any problem let me know :)
I have a list of users that I'm reporting in a table. The first column contains the user_id, and I want to pass that to another page that displays the users details. I don't want to pass it through the URL with $_GET. How do I do this? I can use only HTML & PHP. One post I saw seemed like it was on the right track, but I can't get it to work. Here's what I have:
<h1>Maintain Users</h1>
<div id="ir-report">
<table class="table">
<tr class = "table tr">
<th class="table th">User Id</th>
<th>Username</th>
<th>Name</th>
<th>Email</th>
<th>Activated?</th>
<th>Type</th>
<th>Account Nbr</th>
</tr>
<?php while ($row = mysqli_fetch_assoc($query))
{?>
<tr class="table tr">
<td class ="table td" onclick="submit_id($row['user_id'])"><img src="images\editpensil.jpg" alt="UserId" width="25" height="25"></td>
<td><?php echo $row['username'] ?></td>
<td><?php echo $row['first_name'] ?></td>
<td><?php echo $row['email'] ?></td>
<td><?php echo $row['active'] ?></td>
<td><?php echo $row['type'] ?></td>
<td><?php echo $row['acct_nbr'] ?></td>
</tr>
<?php } ?>
</table>
</div>
What I was expecting to happen is that "on click" the function submit_id($var) would be called. To test that this is working, my function is very simple for the moment:
function submit_id($var) {
header('Location: index.php');
exit();
}
But nothing happens when I clime on the edit icon (editpensil.jpg). The application doesn't appear to try and execute anything. What am I missing? -- Thanks.
You can't call a PHP function from an onclick attribute, or any other on attribute. Those functions must be Javascript functions.
If you really need/want to not pass the id through GET, you can wrap the table in a <form> with the action set to the page you want to send it to, with a method of POST and a hidden input field. I know your question says you can only use HTML and PHP; without Javascript, the only way you can really do this is to add a button to the form/table. You could use CSS to style it so it looks like a link, or anything not-button like.
Example without Javascript:
<form action="index.php" method="post">
<tr class="table tr">
<td class ="table td">
<img src="images\editpensil.jpg" alt="UserId" width="25" height="25">
</td>
<td><?php echo $row['username'] ?></td>
<td><?php echo $row['first_name'] ?></td>
<td><?php echo $row['email'] ?></td>
<td><?php echo $row['active'] ?></td>
<td><?php echo $row['type'] ?></td>
<td><?php echo $row['acct_nbr'] ?></td>
<td><input type="submit" value="Link to" /></td>
</tr>
<input type="hidden" name="user_id" value="<?php echo $row['user_id'] ?>" />
</form>
When that button is clicked, the form will be posted to index.php and you can get to the id through $_POST['user_id']
If you are willing and able to use Javascript, you should be able to do the following HTML/PHP:
<form action="index.php" method="post" id="user_form_<?php echo $row['user_id'] ?>">
<tr class="table tr">
<td class ="table td user_id_link" data-userid="<?php echo $row['user_id'] ?>">
<img src="images\editpensil.jpg" alt="UserId" width="25" height="25">
</td>
<td><?php echo $row['username'] ?></td>
<td><?php echo $row['first_name'] ?></td>
<td><?php echo $row['email'] ?></td>
<td><?php echo $row['active'] ?></td>
<td><?php echo $row['type'] ?></td>
<td><?php echo $row['acct_nbr'] ?></td>
</tr>
<input type="hidden" name="user_id" value="<?php echo $row['user_id'] ?>" />
</form>
And the following Javascript, although this will only work in IE9+:
var links = document.getElementsByClassName('user_id_link');
for (link in links) {
link.addEventListener('click', function() {
var formId = 'user_form_' + this.userid;
document.getElementById(formId).submit();
}, false);
}
Or the much cleaner jQuery version, which has better browser compatibility and is really an invaluable toolkit for a web developer:
HTML/PHP:
<form action="index.php" method="post">
<tr class="table tr">
<td class ="table td user-id-link">
<img src="images\editpensil.jpg" alt="UserId" width="25" height="25">
</td>
<td><?php echo $row['username'] ?></td>
<td><?php echo $row['first_name'] ?></td>
<td><?php echo $row['email'] ?></td>
<td><?php echo $row['active'] ?></td>
<td><?php echo $row['type'] ?></td>
<td><?php echo $row['acct_nbr'] ?></td>
</tr>
<input type="hidden" name="user_id" value="<?php echo $row['user_id'] ?>" />
</form>
Javascript/jQuery:
$(function() {
$('.user-id-link').on('click', function() {
$(this).closest('form').submit();
});
});
You're mixing PHP and JS. The function called in an onclick handler must be JS, it cannot be php.
What's wrong with passing the id through the URL? That's quite obviously the only simple practical solution. Alternatives are:
using cookies, but that's a mess if a user opens multiple tabs/windows on your site, or wants to bookmark the page, or for a reopen after restart of the browser. And that really doesn't help much.
using some kind of other id that points to the user id, but that's just adding another layer for not much.
Unless you tell us exactly why you don't want to pass the id through the URL, it will be difficult to suggest anything.
I'm getting following error while fetching google analytics reports
"GAPI: Failed to request report data. Error: "GDatainsufficientPermissionsUser does not have sufficient permissions for this profile."
sample code is look like below.
<?php
define('ga_email','test#gmail.com');
define('ga_password','test');
define('ga_profile_id','999999999');
require 'gapi.class.php';
$ga = new gapi(ga_email,ga_password);
$ga->requestReportData(ga_profile_id,array('firefox','25.0.1'),array('pageviews','visits'));
?>
<table>
<tr>
<th>Browser & Browser Version</th>
<th>Pageviews</th>
<th>Visits</th>
</tr>
<?php
foreach($ga->getResults() as $result):
?>
<tr>
<td><?php echo $result ?></td>
<td><?php echo $result->getPageviews() ?></td>
<td><?php echo $result->getVisits() ?></td>
</tr>
<?php
endforeach
?>
</table>
<table>
<tr>
<th>Total Results</th>
<td><?php echo $ga->getTotalResults() ?></td>
</tr>
<tr>
<th>Total Pageviews</th>
<td><?php echo $ga->getPageviews() ?>
</tr>
<tr>
<th>Total Visits</th>
<td><?php echo $ga->getVisits() ?></td>
</tr>
<tr>
<th>Results Updated</th>
<td><?php echo $ga->getUpdated() ?></td>
</tr>
</table>
Your Profile ID might be wrong! Don't mess up between Profile ID and Account ID. Both are different!
Just login to your Analytics Account and go to settings by clicking "Admin" tab
and if you notice the URL Address. It will be like below
https://www.google.com/analytics/web/?hl=en#management/Settings/a46773936w11870770pxxxxxxxx/
After the letter "p" you will get the 8 digit number. That's your profile ID number.
Note : Since google interface and frameworks are changing too fast nowadays, this solution is for current interface only and i cannot guarantee that it will work on future.
The login and password you are using doesnt have access to the profile id that you have given. Check the profile id and login and password again to be sure they are all corect. Im assuming you didnt use the ones you posted.
define('ga_email','test#gmail.com');
define('ga_password','test');
define('ga_profile_id','999999999');
Using CodeIgniter, I am trying to place several images onto my view page as follows
...
<?php foreach($results_found as $item): ?>
<tr>
<td><?php echo base_url();?>images/$item->img.jpg</td>?
<td><?php echo $item->title ?></td>
</tr>
...
but all this displays is the url for the images.
I've stored the names of the images in my database, hence my attempt to use $item->img to get access the name. The images are located in my root directory (htdocs\website_name\images)
Any help would be really appreciated. Thanks in advance
You need an image tag. The CodeIgniter way to do it is:
<tr>
<td><img src="<?= base_url(); ?>images/<?= $item->img ?>.jpg" /></td>
<td><?php echo $item->title ?></td>
</tr>
Try it, and check View -> Source to make sure the syntax of the image element reads like this once its been rendered into html:
<img src="http://mysite.com/images/myimage.jpg" />
You need an image element!!! Im not sure what your $item object looks like but try this
<tr>
<td><img src="/images/<?php echo $item->img ?>.jpg"></td>
<td><?php echo $item->title ?></td>
</tr>