Display data from a MySQL database

Issues related to forms.
Post Reply
User avatar
frankus
 
 
Posts: 38
Joined: Sat Dec 05, 2009 10:04 pm

Display data from a MySQL database

Post by frankus »

I have login objects. I want to display any of user's data on the user's account page. I want to be able to display any data at any location on the page.
I'm aware of Dataviewer, Responsivedatatable, Mysqlconnector and Mysqltableeditor but they display data as list or table which I don't want.

Thanks.

Note: I use latest wwb version 14.3.1
User avatar
Pablo
 
Posts: 21583
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Display data from a MySQL database

Post by Pablo »

This requires a custom script.
User avatar
frankus
 
 
Posts: 38
Joined: Sat Dec 05, 2009 10:04 pm

Re: Display data from a MySQL database

Post by frankus »

Pablo wrote: Tue Jan 22, 2019 10:24 am This requires a custom script.
I wish you could have this as a paid extension.
User avatar
frankus
 
 
Posts: 38
Joined: Sat Dec 05, 2009 10:04 pm

Re: Display data from a MySQL database

Post by frankus »

I used to place below code on the account page with HTML object and use
'.$extra1.'
to display the data on page with Text object. But it stopped working after updating wwb to 14.

Code: Select all

<?php
error_reporting(0);
session_start();
if($_SESSION['username'] != '')
{

$mysql_server = 'localhost';
$mysql_username = 'username';
$mysql_password = 'password';
$mysql_database = 'databasename';
$mysql_table = 'tablename';

$db = mysql_connect($mysql_server, $mysql_username, $mysql_password);
mysql_select_db($mysql_database, $db);
$sql = "SELECT fullname, email, extra1, extra2, extra3, extra4, extra5, extra6, extra7, extra8, extra9, extra10, extra11, extra12, extra13, extra14, extra15 FROM ".$mysql_table." WHERE username = '".$_SESSION['username']."'";
$result = mysql_query($sql, $db);
if ($data = mysql_fetch_array($result))
{
extract ($data, EXTR_OVERWRITE);
$status = array("Pending", "Active");
$_SESSION['fullname'] = $fullname;
$_SESSION['email'] = $email;
$_SESSION['extra1'] = $extra1;
$_SESSION['extra2'] = $extra2;
$_SESSION['extra3'] = $extra3;
$_SESSION['extra4'] = $extra4;
$_SESSION['extra5'] = $extra5;
$_SESSION['extra6'] = $extra6;
$_SESSION['extra7'] = $extra7;
$_SESSION['extra8'] = $extra8;
$_SESSION['extra9'] = $extra9;
$_SESSION['extra10'] = $extra10;
$_SESSION['extra11'] = $extra11;
$_SESSION['extra12'] = $extra12;
$_SESSION['extra13'] = $extra13;
$_SESSION['extra14'] = $extra14;
$_SESSION['extra15'] = $extra15;

}
mysql_close($db);
}
else{
header("Location: login.php"); // change according to what your login page is.
exit;
}
?>
User avatar
Pablo
 
Posts: 21583
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Display data from a MySQL database

Post by Pablo »

I doubt that this has anything to do with WB14.
Maybe you have upgraded the PHP version on the server?
In that case you will need to use mySQLi functions instead of mySQL
User avatar
frankus
 
 
Posts: 38
Joined: Sat Dec 05, 2009 10:04 pm

Re: Display data from a MySQL database

Post by frankus »

Pablo wrote: Tue Jan 22, 2019 12:20 pm I doubt that this has anything to do with WB14.
Maybe you have upgraded the PHP version on the server?
In that case you will need to use mySQLi functions instead of mySQL
Does Login objects have mySQLi option? I see only mySQL and Flat file.
User avatar
Pablo
 
Posts: 21583
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Display data from a MySQL database

Post by Pablo »

If you set the PHP version in Page properties to "PHP5+" then all database function will use mysqli
User avatar
frankus
 
 
Posts: 38
Joined: Sat Dec 05, 2009 10:04 pm

Re: Display data from a MySQL database

Post by frankus »

Pablo wrote: Tue Jan 22, 2019 3:04 pm If you set the PHP version in Page properties to "PHP5+" then all database function will use mysqli
Ok, great. Thanks!
User avatar
frankus
 
 
Posts: 38
Joined: Sat Dec 05, 2009 10:04 pm

Re: Display data from a MySQL database

Post by frankus »

Unfortunately, the code still doesn't work. The presently chosen php version on my server is PHP 5.6 and has other options like PHP 7.0, PHP 7.1, PHP 7.2 and PHP 7.3.
User avatar
Pablo
 
Posts: 21583
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Display data from a MySQL database

Post by Pablo »

The option 'PHP5+' only affects built-in scripts, not custom code.
PHP5+ includes support for PHP7.x
User avatar
frankus
 
 
Posts: 38
Joined: Sat Dec 05, 2009 10:04 pm

Re: Display data from a MySQL database

Post by frankus »

Pablo wrote: Tue Jan 22, 2019 4:36 pm The option 'PHP5+' only affects built-in scripts, not custom code.
PHP5+ includes support for PHP7.x
Ok. I understand.
As I suggested earlier, it would be great to have a paid extension that has the functionality in question.
Thanks for your time.
User avatar
Pablo
 
Posts: 21583
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Display data from a MySQL database

Post by Pablo »

I will investigate if this this can be added in a future release.
User avatar
frankus
 
 
Posts: 38
Joined: Sat Dec 05, 2009 10:04 pm

Re: Display data from a MySQL database

Post by frankus »

Pablo wrote: Tue Jan 22, 2019 5:00 pm I will investigate if this this can be added in a future release.
Great! Thanks!
luputu
 
 
Posts: 36
Joined: Sun Feb 17, 2019 4:44 am

Re: Display data from a MySQL database

Post by luputu »

Pablo wrote: Tue Jan 22, 2019 5:00 pm I will investigate if this this can be added in a future release.
Now I have the latest version, is it possible to display data from a mysql database ? do you have an extension to do it easily ?
or please let me know what can I do ...
I want to display a MySQL table on a page.
what I want to have is : I want to display a table from MySQl database that connected to my reservation form so that we can view the information on a page.
could you help me to explain which extension or tools I can use to do that ???
User avatar
Pablo
 
Posts: 21583
Joined: Sun Mar 28, 2004 12:00 pm
Location: Europe
Contact:

Re: Display data from a MySQL database

Post by Pablo »

Maybe you can use this?
http://wysiwygwebbuilder.com/mysqlconnector.html

Otherwise you will need to implement a custom script.
Post Reply