Help, Im really sick of using this lots of nbsps in my results page. Im just a beginner. Can you recommend me some techniques so that I will not be copy pasting this lots of nbsp just to get the space and line breaks I need.
while($row = mysql_fetch_array($result))
{
echo "Patient #:". " ". " ". " ". " ". $row['PNUM'];
echo "<B>"."Hospital #:"."</B>". " ". " ". " ". " ". $row['HOSPNUM']." "." "." ";
echo "<B>"."Room:". " ". " ". " ". " ". $row['ROOMNUM'];
echo "<B>"."Lastname:". " ". " ". " ". " ". $row['LASTNAME'];
echo "<B>"."Firstname:". " ". " ". " ". " ". $row['FIRSTNAME'];
echo "<B>"."Middlename:". " ". " ". " ". " ". $row['MIDNAME'];
echo "<B>"."Admission Date:". " ". " ". " ". " ". $row['ADATE'];
echo "<B>"."Admission Time:". " ". " ". " ". " ". $row['ADTIME'];
echo "<B>"."Patient #:". " ". " ". " ". " ". $row['PNUM'];
}
Use a HTML table tag.
Does it have to be plain text or can you display this in a table?
<table>
<tr>
<th>Patient #</th>
<th>Hospital #</th>
<th>Room</th>
<!-- etc. -->
</tr>
while($row = mysql_fetch_array($result))
{
echo "<tr>";
echo "<td>$row['PNUM']</td>";
echo "<td>$row['HOSPNUM']</td>";
echo "<td>$row['ROOMNUM']</td>";
// etc.
echo "</tr>";
}
</table>
Consider tables or definition lists
if your output is mainly for debugging, you can output your results in pre tag, pre tag, preserve space and line breaks
if not, you should learn some html (and css), a few possibilities are lists, tables, or custom markup with css style
Related
So I have multiple links as posted below, 1 of them goes to: localhost:8080/index.php (wrong one). The others work and goes to the correct url. All of them worked for a week without any problems. They should both navigate to localhost:8080/opdracht_4.2/index.php. Which they all did.
I tried:
<a class='add-product-link' href='../index.php?page=admin'>Add product</a>
<a class='add-product-link' href='./index.php?page=admin'>Add product</a>
<a class='add-product-link' href='opdracht_4.2/index.php?page=admin'>Add product</a>
Funny enough, the last link I tried (href='opdracht_4.2/index.php?) navigated to localhost:8080/opdracht_4.2/opdracht_4.2/index.php.
content function in view:
protected function mainContent() {
if ($this->shopModel->allowedToAddOrEdit) {
echo "<a class='add-product-link' href='index.php?page=admin'>Add product</a>";
}
foreach($this->shopModel->products as $product) {
echo "<div class='shop-item'>";
echo "<a href='index.php?page=details&product=" . $product['productId'] . "' class='product-name'>" . $product['productName'] . "</a><br>";
echo "<img src='" . $product['imgUrl'] . "' alt='" . $product['productName'] . "' height='100' width='100' class='product_img'> <br>";
echo "<span class='price'> € " . $product['price'] . "</span>";
if ($this->shopModel->allowedToBuy) {
echo "<a href='index.php?addedItem=" . $product['productId'] . "&page=shop'><button class='add-to-basket'>Add to cart</button></a><br><br>";
}
if ($this->shopModel->allowedToAddOrEdit) {
echo "<a href='index.php?page=admin&product=".$product['productId']."' class='add-product-link'>Edit</a>";
}
echo "</div>";
}
}
I fail to understand this and have not ever encountered this issue.
I have a div layer with a voting script, how can I print it out in a row echo?
SELECT `image`,`Name`,`item`, (`totalrate` / `nrrates`) AS `rank` FROM `rtgitems` WHERE item
REGEXP 'Total'
ORDER BY (`totalrate` / `nrrates`)
echo "<td align='center' width='200'>" . $row['Name'] . "</td>";
echo "<td align='center' width='200'>" . "<img src=\"{$row['image']}\">" . "</td>";
echo "<td align='center' width='200'>" . $row['rank'] . "</td>";
echo "<td align='center' width='200'>" . <div class="srtgs" id="$row['item']"></div> . "</td>";
The variable srtgs is called in the <script src="../ratingfiles/ratings.js" type="text/javascript"></script> in the head
What am I missing?
Your div needs to be echoed as a literal, just like the tds.
echo "<td align='center' width='200'><div class='srtgs' id=" . $row['item'] . "></div</td>";
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;
So, I have been working on my own on something for a week now and am getting nowhere. I am taking a very advance CIS class that I have done well in so far but towards the end I am working with stuff that I haven't learned yet. I should have waited a couple of semesters to talk this class because I am unprepared for what I am doing now. My main problem is not knowing HTML (I haven't ever had a reason to learn it).
Any ways I have a nawk script template that I have figured out that I need to use. It is derived from a color generator script and is the following:
#!/bin/nawk -f
#-----------------------------------------------------------------------------
#YOUR COMMENTS HERE
#-----------------------------------------------------------------------------
BEGIN {
print "<html>"
print "<body>"
print " <table border=2>"
print " <tr>"
print " <th>$first $last</th>" ###Change this
print " <th>$username</th>" ###Change this
print " <th>Color</th>" ###Change this
print " </tr>"
}
{
print " <tr>"
print " <td>" $1 "</td>" ###Change this
print " <td>" $2 "</td>" ###Change this
print " <td>" $3 "</td>" ###Change this
print " </tr>"
}
END {
print "</table>"
print "</body>"
print "</html>"
}
As you can see on the 12th and 13th line I have added $first $last, and $username respectively. Am I doing this right. Because I don't know HTML, every time I look at it, it is confusing the !##$ out of me.
The following is supposed to be the output:
<html>
<body>
<table border=2>
<tr><th>Name</th><th>Username</th><th>Email</th></tr>
<tr>
<td>Michael Raby</td>
<td>mraby</td>
<td>mike1071#yahoo.com</td>
</tr>
<tr>
<td>Hajar Alaoui</td>
<td>halaoui</td>
<td>hajar6#hotmail.com</td>
</tr>
<tr>
<td>Anne Lemar</td>
<td>alemar</td>
<td>anne.lemar#asu.edu</td>
</tr>
<tr>
<td>Russell Crotts</td>
<td>rcrotts</td>
<td>Russell.Crotts#asu.edu</td>
</tr>
<tr>
<td>Dan Mazzola</td>
<td>dmazzola</td>
<td>dan.mazzola#sun.com</td>
</tr>
<tr>
<td>Bill Boyton</td>
<td>bboyton</td>
<td>boytonb#earthlink.net</td>
</tr>
</table>
</body>
</html>
The following is a sample of what the HTML table is supposed to look like:
Raby Michael mike1071#yahoo.com
Alaoui Hajar hajar6#hotmail.com
Lemar Anne anne.lemar#asu.edu
Crotts Russell Russell.Crotts#asu.edu
Mazzola Dan dan.mazzola#sun.com
Boyton Bill boytonb#earthlink.net
Can someone PLEASE help me? I've been trying to figure out this on my own for a week now.
It looks like the following will do what you want:
#!/bin/nawk -f
#-----------------------------------------------------------------------------
#YOUR COMMENTS HERE
#-----------------------------------------------------------------------------
BEGIN {
print "<html>"
print "<body>"
print " <table border=2>"
print " <tr>"
print " <th>Name</th>" ###Change this
print " <th>Username</th>" ###Change this
print " <th>Email</th>" ###Change this
print " </tr>"
}
{
print " <tr>"
print " <td>" $1 "</td>" ###Change this
print " <td>" $2 "</td>" ###Change this
print " <td>" $3 "</td>" ###Change this
print " </tr>"
}
END {
print "</table>"
print "</body>"
print "</html>"
}
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'].">";