The code below works all fine and dandy. However, I would like to put a space of maybe 16 pixels / one row height between each row pair shown below. How can I do this? I think this might be a CSS issue.
while ($row = mysql_fetch_array($result)) {
echo '<tr>';
echo '<td class="sitename1">'.$row["title"].'</td>';
echo '</tr>';
echo '<tr>';
echo '<td class="sitename2">'.$row["loginid"].'</td>';
echo '</tr>';
}
echo "</table>";
Thanks in advance,
John
You can add padding to the tds in question:
.sitename1 {padding-bottom:16px}
Related
I have a MySql database online for transcriptions of document images. Those images are located on another website. I want to include the link to the actual image in the database so that the person researching can click the link and go directly to the image.
I have done the following:
Created a column named IMAGE
In my excel spreadsheet that will be uploaded via ODBC to PhpMyAdmin for my datbase, i have included the IMAGE
When the file is uploaded via ODBC, I can see the link in the Table on PhpMyAdmin for my database.
I have also included the IMAGE column to be shown on my results page and the column does appear.
But the hyperlink does NOT appear at all on the results page for any entry that has a link in the Image column so there is nothing to click on to go directly to the image
What am I doing wrong?
I wrote this up quickly to try and help you out. You will need to change DBHOST, DBUSERNAME, yourtablename etc to your databases information.
<?php
$con=mysqli_connect("DBHOST","DBUSERNAME","DBPASSWORD","DBNAME");
$result = mysqli_query($con,"SELECT * FROM 'yourtablename'");
echo "<table border='1'>
<tr>
<th>Notes</th>
<th>Image</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['NOTES'] . "</td>";
echo "<td>" . $row['IMAGE'] . "</td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
Edit: Here is an alternate solution that will put the link formatting in for you.
I wrote this up quickly to try and help you out. You will need to change DBHOST, DBUSERNAME, yourtablename etc to your databases information.
<?php
$con=mysqli_connect("DBHOST","DBUSERNAME","DBPASSWORD","DBNAME");
$result = mysqli_query($con,"SELECT * FROM 'yourtablename'");
echo "<table border='1'>
<tr>
<th>Notes</th>
<th>Image</th>
</tr>";
while($row = mysqli_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['NOTES'] . "</td>";
echo "<td><a href='" . $row['IMAGE'] . "'>Link</a></td>";
echo "</tr>";
}
echo "</table>";
mysqli_close($con);
?>
In the following HTML table snippet, I will like to add footnotes (or simple comments) for columns "stat 1", "stat 2" and "stat 3" to explain each of the stats in more detail. Preferably, want the comments/details to appear right below the table with each comment correctly referring to the right column. Any suggestion on how to achieve this? Thanks.
if(!empty($output))
{
echo '<table cellpadding="0" cellspacing="0" class="imagetable">';
echo '<caption>Table 1</caption>';
echo '<tr><th>Date</th><th>Stat 1</th><th>Stat 2</th><th>Stat 3</th><th></tr>';
foreach ($output as $result)
{
$temp = explode(" ",$result);
echo '<tr>';
for($i=0;$i<count($temp);$i++){
echo '<td>',$temp[$i],'</td>';
}
echo '</tr>';
}
echo '</table><br />';
}
You could use tfoot (http://www.w3schools.com/tags/tag_tfoot.asp)
if(!empty($output))
{
echo '<table cellpadding="0" cellspacing="0" class="imagetable">';
echo '<caption>Table 1</caption>';
echo '<thead><tr><th>Date</th><th>Stat 1</th><th>Stat 2</th><th>Stat 3</th></tr></thead>';
echo '<tfoot><tr><td> </td><td>*note 1</td><td>*note 2</td><td>*note 3</td></tr></tfoot>';
foreach ($output as $result)
{
$temp = explode(" ",$result);
echo '<tr>';
for($i=0;$i<count($temp);$i++){
echo '<td>',$temp[$i],'</td>';
}
echo '</tr>';
}
echo '</table><br />';
}
I have a problem regarding the width in a bootstrap table, it goes way to the side of the website, screenshot under
http://i.stack.imgur.com/FLZwD.png
EDIT:
<div class="container">
<h1>URL Stats <small>Shortened URL's with their full stats.</small></h1>
<table class="table table-striped table-bordered" id="statstable">
<thead>
<tr>
<th>URL ID</th><th>URL Unique ID</th><th>Short Link</th><th>Redirect Link</th><th>Date Created</th><th>End Date</th><th>Days Left</th>
</tr>
</thead>
<hr>
<tbody>
<?php
$result = mysql_query("SELECT * FROM links WHERE shortlinkid='$shortlinkid'") or die(mysql_error());
while ($row = mysql_fetch_array($result)) {
$now = date("Y-m-d");
$start = $row['date_created'];
$end = $row['end_date'];
$diff = (strtotime($end) - strtotime($now))/24/3600;
echo "<tr>";
echo "<td>".$row['id']."</td>";
echo "<td>".$row['shortlinkid']."</td>";
echo "<td><a href='http://".$row['fullurl']."'>".$row['fullurl']."</a></td>";
echo "<td><a href='".$row['redirect']."'>".$row['redirect']."</a></td>";
echo "<td>".$row['date_created']."</td>";
echo "<td>".$row['end_date']."</td>";
echo "<td>".$diff."</td>";
echo "</tr>";
}
?>
</tbody>
</table>
</div>
This has not been an issue before, and it works fine in other browsers other than Chrome
Change this:
echo "<td><a href='http://".$row['fullurl']."'>".$row['fullurl']."</a></td>";
echo "<td><a href='".$row['redirect']."'>".$row['redirect']."</a></td>";
To this:
echo "<td><a href='http://".$row['fullurl']."'>Full URL</a></td>";
echo "<td><a href='".$row['redirect']."'>Redirect</a></td>";
Instead of echoing the entire URL for the link label, use some descriptive text to click on. Change labels as needed.
need some help with HTML. Have table and where is image is empty place, I dont want that it will be empty.
it Looks like this
and Code:
echo "<table border=2 >";
echo "<tr><td>Telefono pavadinimas</td><td>Nuotrauka <td>Kaina</td><td>Parduotuve</td><td>Nuoroda</td></tr>";
for($i=0;$i<$num;$i++)
{
$row=mysql_fetch_row($fetch);
echo "<tr>";
echo"<td>$row[1]</td>";
echo "<td><img src=\"{$row[5]}\" width=60% height=60% /></td>";
echo"<td>$row[2] LT</td>";
echo"<td>$row[3]</td>";
echo "<td><img src=\"".base_url()."images/parduotuve.png\" /></td>";
echo"</tr>";
}
echo"</table>";
}
Tried
echo "<td width=height60% width=60%><img src=\"{$row[5]}\" width=60% height=60% /></td>";
Also
echo"<td width=80><img src=\"{$row[5]}\" width=60% height=60% /></td>";
but in this use changed and my photo size and column size
So how to detele empty place where is photo?
Assign the "td" width just "1%". So that it will take only the image size.
View image: http://i.stack.imgur.com/yxE4u.jpg
Although this is in PHP, I'm trying to (with HTML) get two words (which use the same class) to push next to each other without calling the class seperately or using the two words in the same if/if else function. I'm sure it's just a simple HTML element.
<?php
if (something){
echo "<p class='message'>hello</p>";
}
if (somethingelse){
echo "<p class='message'>world</p>";
}
?>
As the comments aren't what I'm after, I'll show what I'm using:
<?php
if (!empty($message)){
echo "<p class='message'>" . $message . "</p>";
}
if (!empty($errors)){
echo "<p class='message'>";
foreach ($errors as $error){
echo " - " . $error . "<br />";
}
echo "</p>";
}
?>
One statement or both at the same time may prove true. Hopefully you can see why I can't wrap it all around an HTML tag.
i think you want to do this
<p class="messasge"> <?php echo $message; ?> </p>
RE-FIXED according to updated specifications :
<?php
if (!empty($message)){
echo "<p class='message'>" . $message;
}
if (!empty($errors)){
if (empty($message) echo "<p class='message'>";
foreach ($errors as $error){
echo " - " . $error . "<br />";
}
}
if ((!empty($message))||(!empty($errors))) echo "</p>";
?>
if JUST message is true it'll print <p class='message'>MESSAGE</p>
if JUST errors is true, it'll print <p class='message'>ERRORS</p>
if BOTH are true, it'll print <p class='message'>MESSAGEERRORS</p>
I think you probably want some variant on the following code:
<?php
$output = '';
if (something)
$output .= 'hello';
if (somethingelse)
$output .= 'world';
if ($output)
echo "<p class='message'>$output</p>";
?>
For your example, you could replace all of the echos in the first two conditions with appending to $message, then only output if there is something to output. There are numerous options but I think this is the most flexible / elegant.
In your case it can be simplified to,
<?php
$output = $message;
if (!empty($errors))
foreach ($errors as $error)
$output .= " - $error<br />";
if (!empty($output))
echo "<p class='message'>$output</p>";
?>
Maybe the dl list is useful
<?php
if (!empty($message)){
echo "<dl class='message'><dt>" . $message . "</dt>";
}
if (!empty($errors)){
foreach ($errors as $error){
echo "<dd> - " . $error . "</dd>";
}
echo "</dl>";
}
?>
<?php
$message = "";
if (something) $message = "hello";
if (somethingelse) $message += " world";
echo "<p class='message'>".$message."</p>";
?>