Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to display the contents of a table in a database in form of string in PHP?

This is what I have tried. I displayed the results in form of a table. I want the results to display like a single line for which I can apply a marquee. My instructor advised to put the results in a string and then display them. How to implement that?

<?    
mysql_connect("localhost", "root", "qwerty") or die(mysql_error());
mysql_select_db("ups_status") or die(mysql_error());

$value = $_POST[input] ;
$order3 = "SELECT * FROM ups_status1 WHERE (ups_temp > 45)and(Ipaddress LIKE '%".$value."%')";
$results3 = mysql_query($order3) or die('Invalid query: ' .mysql_error());

echo"<div id=ups_sty ><h4>Temperature Status</h4></div>";
if(mysql_num_rows($results3)>0)
{
echo "<div id=ups_sty2><marquee behavior=alternate>Temperature of one or more UPS is high!!</marquee></div>";   
echo "<table border='0' width='200' cellpadding='2' cellspacing='2'>";

echo "<tr align='center' bgcolor='#002C40' style='color:#FFF'>
<td height='35px' width='500px'>IP ADDRESS</td> 
</tr>"; 

  while($result5 = mysql_fetch_row($results3))
 {
   echo "<tr align='center' bgcolor='#f0f0f0'>
<td height='25px'>".$result5[1]."</td>
</tr>" ;
 }
echo "</table>";
/*Instead of displaying them in a tabular way, I want to display them consecutively...*/
?>
like image 457
Katherine Avatar asked Jun 23 '15 04:06

Katherine


People also ask

How display all data from database in PHP table?

php $connect=mysql_connect('localhost', 'root', 'password'); mysql_select_db("name"); //here u select the data you want to retrieve from the db $query="select * from tablename"; $result= mysql_query($query); //here you check to see if any data has been found and you define the width of the table If($result){ echo "< ...

How do you display data from a table?

Show or hide a data table. Select a chart and then select the plus sign to the top right. To show a data table, point to Data Table and select the arrow next to it, and then select a display option. To hide the data table, uncheck the Data Table option.

How do you display data in a database?

To display the table data it is best to use HTML, which upon filling in some data on the page invokes a PHP script which will update the MySQL table. The above HTML code will show the user 5 text fields, in which the user can input data and a Submit button.


1 Answers

use this(Complete Code)

?>
<div id=ups_sty2>
    <marquee behavior=alternate>Temperature of one or more UPS is high!!</marquee>
</div> 

    <?php
        while ($raw = mysql_fetch_array($results3))
            {
                <p><?php echo $raw["tbale_field name1"]; ?></p>
            }
    ?>
like image 56
Abdulla Nilam Avatar answered Oct 16 '22 09:10

Abdulla Nilam