Table row width by image - html

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.

Related

Hyperlink in MySql Database

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);
?>

data not uploading properly due to >

Is there a way that i can escape >, I have a combo box which has an option below. I tried replacing > with > but it's still not uploading properly.
<select name="Category3" id="Category3">
<option value="Request |Running > 1 hour">Request |Running > 1 hour</option>
What it should upload is just Request |Running > 1 hour
but what is being uploaded is: Request |Running > 1 hour 1 hour' />
i dont know where its getting the other 1 hour' />
i tried removing the > and it just uploaded Request |Running 1 hour without the excess 1 hour' /> but i need it for consistency
here is the php code that im using to upload to db
<?php
error_reporting(0);
require 'include/DB_Open.php';
$Category3 = mysql_real_escape_string ($_POST['Category3']);
if (isset($ABC))
{
$sql="INSERT into XXX category_2
VALUES ('".$Category3."')";
$result=mysql_query($sql)or die(mysql_error());
}
?>
here is my code for retrieving the data
$sql="SELECT category_2
FROM XXX
WHERE resolved_date BETWEEN '" . $date . "' AND '" . $date1 . "'
ORDER BY resolved_date";
$myData = mysql_query($sql);
//to count if there are any results
$numrow = mysql_num_rows($myData);
if($numrow == 0)
{
echo "No results found.";
}
else
{
echo "$numrow";
}
{
echo "<table width='auto' cellpadding='1px' cellspacing='0px' border=1 align='center'>
<tr>
<th align='center'><strong>Category 3</strong></th>
</tr>";
while($info = mysql_fetch_array($myData))
{
echo "<form action='retrieve.php' method='post'>";
echo"<tr>";
echo "<td align='center'>" . $info['category_2'] . "<input type=hidden name=category_2 value=" . $info['category_2'] . "' /> </td>";
echo "</tr>";
echo "</form>";
}
}
echo "</table>";
Whenever you're displaying text that might include special HTML characters, you should use htmlentities() to encode it properly, so these characters don't cause the HTML to be misparsed (or worse, allow script injection).
$cat2 = htmlentities($info['category_2']);
echo "<td align='center'>" . $cat2 . "<input type='hidden' name='category_2[]' value='" . $cat2 . "' /> </td>";
You also were missing the ' after value=. I've added that (and quotes around all the other attributes).
Since you're creating multiple inputs with the same name, you need to give them an array-style name so that the server script can get all the values. $_POST['category_2'] will be an array.

how to have a vertical header and textarea

i have a code...server side and cant seem to make it load wherein HEADER would be vertical, i have tried the code below,
<?php
require 'include/DB_Open.php';
$ea_name = $_POST['ea_name'];
$sql="SELECT * FROM ea_error WHERE ea_name = '" . $ea_name . "'";
$myData = mysql_query($sql) or die(mysql_error());
//to count if there are any results
$numrow = mysql_num_rows($myData) ;
if($numrow == 0)
{
echo "No results found.";
}
else
{
echo '<fieldset><legend><strong>Information</strong></legend>
<table width="auto" border="0" align="center">
<tr><th scope="row">Error</th></tr>
<tr><th scope="row">Resolution</th></tr>
<tr><th scope="row">Contact/s</th></tr>';
while($info = mysql_fetch_array($myData))
{
echo "<form action='retrieve.php' method='post'>";
echo "<td align='center'>" . "<textarea readonly=readonly name=error cols=75 rows=8> " . $info['error'] . "</textarea></td>";
echo "<td align='center'>" . "<textarea readonly=readonly name=resolution cols=75 rows=8> " . $info['resolution'] . "</textarea></td>";
echo "<td align='center'>" . "<textarea readonly=readonly name=contacts cols=75 rows=8> " . $info['contacts'] . "</textarea></td>";
echo "</form>";
echo "</table>";
}
}
echo "</fieldset>";
include 'include/DB_Close.php';
?>
whats showing with this code is like below
Error
Resolution
Contact/s
then i would have the three text areas here on a single row
what i want to happen is
Error - TEXTAREA
Resolution - TEXTAREA
Contact/s - TEXTAREA
pls help...i also tried using a css style to no avail
table, td, th {
border: 1px solid red;
}
thead {
float: left;
}
ive also tried to use the code below,
echo "<form action='retrieve.php' method='post'>";
echo "<tr>";
echo "<td align='center'>" . "<textarea readonly=readonly name=error cols=75 rows=8> " . $info['error'] . "</textarea></td>";
echo "</tr>";
echo "<tr>";
echo "<td align='center'>" . "<textarea readonly=readonly name=resolution cols=75 rows=8> " . $info['resolution'] . "</textarea></td>";
echo "</tr>";
echo "<tr>";
echo "<td align='center'>" . "<textarea readonly=readonly name=contacts cols=75 rows=8> " . $info['contacts'] . "</textarea></td>";
echo "</tr>";
but what i am getting is
Error
Resolution
Contact/s
TEXTAREA
TEXTAREA
TEXTAREA
If I understood the question correctly, this could be an answer (although I would TOTALLY avoid using tables for layout design and not just tabular data):
$myRes = "<form action='retrieve.php' method='post'>
<fieldset>
<legend><strong>Information</strong></legend>
<table width='auto' border='0' align='center'>
<tr>
<th scope='row'>Error</th>
<td align='center'><textarea readonly=readonly name=error cols=75 rows=8>" . $info['error'] . "</textarea></td>
</tr>
<tr>
<th scope='row'>Resolution</th>
<td align='center'><textarea readonly=readonly name=resolution cols=75 rows=8>" . $info['resolution'] . "</textarea></td>
</tr>
<tr>
<th scope='row'>Contact/s</th>
<td align='center'><textarea readonly=readonly name=contacts cols=75 rows=8>" . $info['contacts'] . "</textarea></td>
</tr>
</table>
</fieldset>
</form>";
echo $myRes;

fill textbox with mysql data

How do I fill an inputbox with mysql data. So that I can update the database?
I have this code that will show the table corresponding to the users request. But I don't know the syntax on how I can fill an inputbox with mysql data.
$result = mysql_query("SELECT * FROM t2 WHERE STAT='{$_POST["stat1"]}'");
echo "<table border='1'>
<tr>
<th>HospNum</th>
<th>RoomNum</th>
<th>LastName</th>
<th>FirstName</th>
<th>MidName</th>
<th>Address</th>
<th>TelNum</th>
<th>Status</th>
<th>Nurse</th>
</tr>";
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>" . $row['HOSPNUM'] . "</td>";
echo "<td>" . $row['ROOMNUM'] . "</td>";
echo "<td>" . $row['LASTNAME'] . "</td>";
echo "<td>" . $row['FIRSTNAME'] . "</td>";
echo "<td>" . $row['MIDNAME'] . "</td>";
echo "<td>" . $row['ADDRESS'] . "</td>";
echo "<td>" . $row['TELNUM'] . "</td>";
echo "<td>" . $row['STAT'] . "</td>";
echo "<td>" . $row['NURSE'] . "</td>";
echo "";
}
echo "";
And I want to display the corresponding records with this html form, by inputting a primary key. And clicking the search button, the record will appear on each box. Just like when you update mysql database through phpmyadmin. But this time using a custom html form.
<td width="168"><input name="hnum" type="text" id="hospnum"></td>
<td width="41"><font size="3">Room #</td>
<td width="3">:</td>
<td width="168"><input name="rnum" type="text" id="rnum"></td>
how can I do that?
<input name="hnum" type="text" id="hospnum" value="<?php echo $row['ROOMNUM']; ?>" />
In text field you have fill the value attribute with php fetched attribute value
echo "<input name='rnum' type='text' id='rnum' value =".$row['ROOMNUM'].">";

Increasing the spacing between table rows

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}