|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
How to combine 2 php pages into 1?
Hello All,
I am having some problems trying to make one php page instead of having 2 seperate ones. The first page simply connects to mysql and lists the article headlines. It also generates the topic and the link to the article on the second page, article_view.php?view=ID The article_view page has an IF statement and this is where I'm getting confused. At the end, I have an else statement which I want to show the article headlines by default, but it's not showing anything unless the url includes ?view. Example: if ($view != "") { .......... mysql stuff... else { .......... mysql stuff.. Show Article Headlines. } } ?> Not sure if I exaplained the well. The example above is what I am trying to get to work. I just need the else statement and the mysql code to display without the need for ?view. I would like the headlines to appear by just visiting articles.php. Thanks for your time, Chris |
|
#2
|
|||
|
|||
|
Finally i Found it :)
ok cbunting .. let's see what we need here ..
as you wrote ( or as i understand ) you want to make only one .php file that 1- connect to database 2- list articles headlines 3- view the articles .. i will not ask you why this pain .. but here is the answer ..1- you need to make a function to connect to database 2- make a page that list the headlines (on the fly ) 3- make a page of the article view and merger this 3 steps into one file let's see PHP Code:
first i made a function called connection() and added some things to connect to database second i made an if condition assuming that the id not selected so the id will be 0 .. and made a query to select all fields and add them to row and show the headline and ( click here link to the third option ) third .. the step 3 will take you to new on fly page and list the fields in new query as i did .. i used a premade database of me has only one table containg 3 fields only ( id . user . passwd ) .. use your mind to change the names of fileds and tables and the strings of database to be suitable for ur site or project .. don't forget to pray for me ![]() |
|
#3
|
|||
|
|||
|
Thanks aboyousif...
This is perfect and exactly what I was looking for. If you wondered why I was wanting to do this, basicly it's because I am trying to learn a few things and this code you provided gave me that plus alot more. I am interested in how the fuction something() works and now I see that as well. Thanks again, Chris |
|
#4
|
|||
|
|||
|
you are welcome ...
any time .. Advice : try to download the manual of php from the php.net site .. i use it to learn php ... it is very useful |
![]() |
| Viewing: Dev Articles Community Forums > Programming > PHP Development > How to combine 2 php pages into 1? |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|