This topic is locked
[SOLVED]

 Adding static pages

10/29/2012 2:10:41 PM
PHPRunner General questions
khalil author

Hello All!

I just purchased PHPRunner and I'm trying to understand how things work! so excuse me if my question sound silly!
So far I'm totally impressed with PHPRunner, I can't believe the amount of work it's reducing !
I have a question though, I'm trying to create a test website, and I'm stuck somewhere: what would be the best way to add a static page?

For example, let's say the landing page of the site, I want to display some news from the news table, newest users from the users table, a few static texts from Pages table etc...

I tried to custom views, but they're all depending on a table, is there a way to create a static page? even if it's not within the application, I can code what I need, but I need some guidelines.
Thanks in advance !
Khalil

W
wildwally 10/29/2012

From the sounds of what your wanting to do this will require hand coding.
If your using 6.2 in the visual editor at the bottom of the menu is a section called custom files. you can create the page outside of PHPRunner and import or you can write you code within the confines of the editor. Then create a custom link or navigation to the newely created page.

khalil author 10/29/2012

Thank you wildwally ! that was very helpful, I was just wondering what the "Custom Files" are for, I'll give it a shot now!
Cheers

khalil author 10/29/2012



From the sounds of what your wanting to do this will require hand coding.
If your using 6.2 in the visual editor at the bottom of the menu is a section called custom files. you can create the page outside of PHPRunner and import or you can write you code within the confines of the editor. Then create a custom link or navigation to the newely created page.


Doesn't work the way I want actually, I need the content of the page to be dynamically loaded from multiple tables, the custom pages are dummy pages, you can't add anything to them from within the app, this can work for simple pages with none dynamic content obviously

Admin 10/29/2012

I guess you need to rephrase your question then. You specifically asked about adding static pages.

khalil author 10/29/2012



I guess you need to rephrase your question then. You specifically asked about adding static pages.



Yes I meant not dynamic pages like the crud pages, static pages that display latest news, latest users etc... that's what I meant <img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=reply&id=68326&image=1&table=forumreplies' class='bbc_emoticon' alt=':)' />

S
scoobysteve 10/29/2012



Hello All!

I just purchased PHPRunner and I'm trying to understand how things work! so excuse me if my question sound silly!
So far I'm totally impressed with PHPRunner, I can't believe the amount of work it's reducing !
I have a question though, I'm trying to create a test website, and I'm stuck somewhere: what would be the best way to add a static page?

For example, let's say the landing page of the site, I want to display some news from the news table, newest users from the users table, a few static texts from Pages table etc...

I tried to custom views, but they're all depending on a table, is there a way to create a static page? even if it's not within the application, I can code what I need, but I need some guidelines.
Thanks in advance !
Khalil


Khalil,
I have used this php code on my home page which is outside of PHPR, I use these snippets for each field I want the latest entry to be seen as. This is assuming your using a MySQL database. Steve
<?php

$con = mysql_connect("");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

mysql_select_db("[color="#8B0000"]DatabaseName", $con);

$result = mysql_query("SELECT * FROM DESC");

while($row = mysql_fetch_array($result))

{

echo $row['[color="#8B0000"]LatestNews'];

}

mysql_close($con);

?>

khalil author 10/29/2012



Khalil,
I have used this php code on my home page which is outside of PHPR, I use these snippets for each field I want the latest entry to be seen as. This is assuming your using a MySQL database. Steve
<?php

$con = mysql_connect("");

if (!$con)

{

die('Could not connect: ' . mysql_error());

}

mysql_select_db("[color="#8B0000"]DatabaseName", $con);

$result = mysql_query("SELECT * FROM DESC");

while($row = mysql_fetch_array($result))

{

echo $row['[color="#8B0000"]LatestNews'];

}

mysql_close($con);

?>


Thank you so much Steve! I thought of doing that, but was wondering if there was any easier method that I can use to keep the code tight and use the DB Class of phpRunner!
But I guess I'll go with your suggestion!

Thanks alot
Khalil

khalil author 10/29/2012

Hello!
To all those who are wondering about adding dashboards or landing pages that connect to multiple pages here's the solution I came up with, same concept as Steve's method but this one keeps the code tighter without opening an extra connection to MySQL.
(PHPRunner 6.2)
1- In the custom files under Editor, insert a new file or create a new file from the application editor

2- Make sure the design you want is there in HTML as a first step and make sure the extension of the file is PHP

3- on top of the file add the following code: <?php include("include/dbcommon.php"); ?> now we have the db class present and ready for us to use.

4- Execute any Query using the DB Class object, below is an example:
<?php

$sql = "select * from users";

$rs = CustomQuery($sql);

$data = db_fetch_array($rs);

print_r($data);

?>
If anybody knows any easier way to establish that feel free to correct me!
Cheers and thank you all for your help !

S
scoobysteve 10/31/2012



Hello!
To all those who are wondering about adding dashboards or landing pages that connect to multiple pages here's the solution I came up with, same concept as Steve's method but this one keeps the code tighter without opening an extra connection to MySQL.
(PHPRunner 6.2)
1- In the custom files under Editor, insert a new file or create a new file from the application editor

2- Make sure the design you want is there in HTML as a first step and make sure the extension of the file is PHP

3- on top of the file add the following code: <?php include("include/dbcommon.php"); ?> now we have the db class present and ready for us to use.

4- Execute any Query using the DB Class object, below is an example:
<?php

$sql = "select * from users";

$rs = CustomQuery($sql);

$data = db_fetch_array($rs);

print_r($data);

?>
If anybody knows any easier way to establish that feel free to correct me!
Cheers and thank you all for your help !


Khalil,
Nice one, I like it,

I have a question for you if I only wanted to display 1 value from one field called ScreenName how do I change the code below to show just that instead of the whole sql data. Thanks Steve
<?php

$sql = "select * from users";

$rs = CustomQuery($sql);

$data = db_fetch_array($rs);

print_r($data);

?>

khalil author 10/31/2012



Khalil,
Nice one, I like it,

I have a question for you if I only wanted to display 1 value from one field called ScreenName how do I change the code below to show just that instead of the whole sql data. Thanks Steve
<?php

$sql = "select * from users";

$rs = CustomQuery($sql);

$data = db_fetch_array($rs);

print_r($data);

?>


Hello Steve,
If you want to select a specific field in the table row, you can simply replace "" with the field name, like below:
SELECT username FROM users;
If you want to select a specific row from the table, you need to provide its ID, for example, if you want to display a user with the ID of 1, you can use this:
$sql = "SELECT
FROM users WHERE users.id = 1";
You can always add "LIMIT" to your sql statement to limit the results... in the code you provided it would be:
$sql = "select * from users limit 1";
Hope this helps!
Cheers
Khalil

S
scoobysteve 10/31/2012



Hello Steve,
If you want to select a specific field in the table row, you can simply replace "" with the field name, like below:
SELECT username FROM users;
If you want to select a specific row from the table, you need to provide its ID, for example, if you want to display a user with the ID of 1, you can use this:
$sql = "SELECT
FROM users WHERE users.id = 1";
You can always add "LIMIT" to your sql statement to limit the results... in the code you provided it would be:
$sql = "select * from users limit 1";
Hope this helps!
Cheers
Khalil


Thanks man, nice one. Just working on the custom files now, I did it the other way because of a earlier version of PHPR just transferring over now and got a bit confused thanks again.