how do i FORMAT OUTPUT from php-mysql database


HOME ยป Databases
Hi
i got a php code on internet that works fine. It retrieves
details of suppliers from a mysql table "suppliers". All column
headings are displayed horizontally.
It retrieves data and
displays as shown below:
ID | NAME | ADDRESS | PLACE |
PHONE | EMAIL />---------------------------------------------------------------- />1 | TOM | XYZ | ABC | 123 | FDS@FDSF.COM />However i would like to format the output to appear as shown below
in image file "desired-output.png":
DESIRED OUTPUT.PNG (4.46
KiB) Viewed 340 times

I want all my column
headings to appear in one colu
I would like to retrieve data from multiple tables and display them in
tabular format. Any ideas?
Databases
I simply want to out put a PHP code stored in the database into my
page. I've tried:
Syntax: [ Download ] [ Hide
]SXBB[id].writeCmd();Syntax: [ Download ] [ Show ]$sql = "SELECT
page_id, page_name, page_desc, page_content " .
 
                   
  "FROM pages WHERE page_id=" . $_GET['p']; />        $result = mysql_query($sql,
$conn);
        $row =
mysql_fetch_array($result);
       
$page_content = $row['page_content'];
   
  &nb
PHP
As I have been working on creating my own blog software I needed to
determine an way to convert MySQL's NOW() date/time format. />Functions are great because they are reusable so I decided since I
use different date/time formats why not pass the date and format as
parameters?
The function simply returns the value (you'll have to
echo the function where you need it). You call the function with two
variables: the first being the MySQL NOW() formatted date/time and the
second the format for the time stamp.
To construct a time stamp
to change date and time formatting (in example between 12, Dec, and
December) simply use http://php.net/date as a reference guide.
Development
Hi
i got a php code on internet that works fine. It retrieves
details of suppliers from a mysql table "suppliers". All column
headings are displayed horizontally.
It retrieves data and
displays as shown below:
ID | NAME | ADDRESS | PLACE |
PHONE | EMAIL />---------------------------------------------------------------- />1 | TOM | XYZ | ABC | 123 | FDS@FDSF.COM />However i would like to format the output to appear as shown below
in image file "desired-output.png":
DESIRED OUTPUT.PNG (4.46
KiB) Viewed 340 times

I want all my column
headings to appear in one colu
Databases

im trying to get difference of date/time from a field type datetime
to "right now" using php and mysql as database



this code is working fine, returns the output beautifully ok as
required



$datetime1 = new DateTime('mydate1');
$datetime2 = new DateTime();
$interval = $datetime1->diff($datetime2);
$elapsed = $interval->format('%d days %h hours %i minutes');


that is ok so far, no issues as this function is for php 5.3 and i
have it on server



my need is 4 small things actually



1) how to eliminate the need for days?
i want to have (25 hours 10 minutes) instead of (1 day 1 hours 10
minutes)



2) how i can make $elapsed be bold or colored if the
value is more than 5 hours for example!? simple IF logic will not work
as the output is not actually a predefined value...



3) if the days or hours are 0, then want to remove them!
- For example if showing (0 days 10 hours 40 mins) then no need to
display the (0 days), should show (10 hours 40 mins) that is enough
- Another example: 0 days 0 hours 45 minutes then to show only "45
minutes" no need for days and hours!



4) if output less than 5 minutes in total (0days 0 hours 1-5mins),
then wanna make it show like "a while ago" only no need for any days,
hours or minutes... then after 6 minutes.. go like "6 mins"



shortly something like facebook!?



okay, what i searched tried is different combination of workarounds
but never worked as you know this interval is for php 5.3 and still
seem not widely used?



any hint for one or more parts of this long question is
appreciated,



M, Derik

Web Development

I am trying to make a basic login system with PHP and MySQL, and it
is not working from my login form. Here is the code for the login
form.:



<!DOCTYPE html>
<html>
<head>
<title>Login</title>
</head>

<body>
<form method="POST" action="verify.php">
<br/>Username:<input type="text" name="username"/>
<br/>Password:<input type="password" name="password"/>
<br/><button type="submit">Submit</button>
</form>
</body>

</html>


Here is the code for verify.php:



<?php
$username = $_POST["username"];
$password = $_POST["password"]; //Not Doing anything with the
pass yet
$con=mysqli_connect("","root","mypassword","logins");
//now mySQL is connected, lets extract stuff from the database
$que = mysqli_query($con,"SELECT Pass FROM login WHERE User='"
. $username . "'");
$row = mysqli_fetch_array($que);
$myvar = $row[0];
//should echo Test
echo $myvar;
echo "If it returned Test, the mySQL works.";
mysqli_close($con);
?>


When I run this, the output is completly blank.
However, I can get the query directly from the MySQL console:



    mysql> SELECT Pass from login WHERE User='Logern';
+------+
| Pass |
+------+
| Test |
+------+
1 row in set (0.01 sec)
mysql>


I can also acsess it from PHP, with a hardcoded SQL Query:



$que = mysqli_query($con,"SELECT Pass FROM login WHERE
User='Logern'");


So why is this failing to work? My webserver is a Raspberry Pi with
Debian and lighttpd.

Web Development

- Technology - Languages
+ Webmasters
+ Development
+ Development Tools
+ Internet
+ Mobile Programming
+ Linux
+ Unix
+ Apple
+ Ubuntu
+ Mobile & Tablets
+ Databases
+ Android
+ Network & Servers
+ Operating Systems
+ Coding
+ Design Software
+ Web Development
+ Game Development
+ Access
+ Excel
+ Web Design
+ Web Hosting
+ Web Site Reviews
+ Domain Name
+ Information Security
+ Software
+ Computers
+ Electronics
+ Hardware
+ Windows
+ PHP
+ ASP/ASP.Net
+ C/C++/C#
+ VB/VB.Net
+ JAVA
+ Javascript
+ Programming
Privacy Policy - Copyrights Notice - Feedback - Report Violation 2018 © BigHow