Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
How to build my own CMS
Old 07-01-2006, 07:35 AM How to build my own CMS
Average Talker

Posts: 24
Trades: 0
Hi Guys

I know i am probably trying to invent a wheel ! However, the only way i can learn the language is to try and build something with it. What better way than to build my CMS whereby i can use it in future.

Already created my database and am tryin to build a dynamic me.

The menu should pick up the title and url of the file from my database.

The address of the url is showing fine and i am struggling to put the title in that url. Below is my code:

<?php
require('testconnection.php');

// Request to pick up the menu title
$sql="SELECT * from content";
$cmd=mysql_query($sql);
if (!$cmd) {
exit('<p>Error performing query' .
'at this time.</p>');
}
while ($row=mysql_fetch_array($cmd))
{
$menu=$row['menu'];
$filename=$row['filename'];

echo '<p>' . '<a href="'. $_SERVER['PHP_SELF'].
'?showmenu='. $filename. '">'.
'$menu </a></p>';
}
?>

And the result i get on the browser is this:
$menu
$menu
$menu
$menu
$menu
$menu
$menu
Pls enlighten. Will keep trying even while i posted this. Thanks a million.
__________________

Please login or register to view this content. Registration is FREE
- Content is King! Let others’ see and hear you.
ngsp23 is offline
Reply With Quote
View Public Profile Visit ngsp23's homepage!
 
 
Register now for full access!
Old 07-01-2006, 08:18 AM Re: How to build my own CMS
Ultra Talker

Posts: 251
Location: Belgium, Antwerp, Zoersel
Trades: 0
Change:
PHP Code:
'$menu </a></p>'
to:
PHP Code:
"$menu </a></p>"
Php only parses variables in strings when using double quotes.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
Orodreth is offline
Reply With Quote
View Public Profile Visit Orodreth's homepage!
 
Old 07-01-2006, 09:37 AM Re: How to build my own CMS
techwench's Avatar
Code Monkey

Posts: 1,449
Name: Danalyn
Location: Dallas, TX
Trades: 0
No, single quotes is correct because of the double quotes in the html echo, just move the variable outside the quote.
PHP Code:
echo '<p>' '<a href="'$_SERVER['PHP_SELF'] . '?showmenu='$filename'">' $menu '</a></p>'
EDIT: DOH! READ the whole string, techwench. Edit code above for variable. :P
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by techwench; 07-01-2006 at 09:40 AM..
techwench is offline
Reply With Quote
View Public Profile
 
Old 07-02-2006, 11:17 AM Re: How to build my own CMS
Webmaster Talker

Posts: 626
Trades: 0
Why don't you just use this... It would be much easier:

Code:
<?php 
$phpself = $_SERVER['PHP_SELF'];
require('testconnection.php'); 
// Request to pick up the menu title 
$sql="SELECT * FROM content"; 
$cmd=mysql_query($sql) or die('Error performing query: '.mysql_error());
 
while ($row=mysql_fetch_array($cmd)) 
{ 
extract($row);
echo "<p><a href=$phpself?showmenu=$filename\\$menu</a></p>"; 
} 
?>
That should do the trick... The extract() call basically turns all the variables in $row['varname'] and makes them just $varname - It saves a ton of typing.

Last edited by jim.thornton; 07-02-2006 at 02:05 PM..
jim.thornton is offline
Reply With Quote
View Public Profile
 
Old 07-02-2006, 12:05 PM Re: How to build my own CMS
Ultra Talker

Posts: 251
Location: Belgium, Antwerp, Zoersel
Trades: 0
Quote:
Originally Posted by techwench
No, single quotes is correct because of the double quotes in the html echo, just move the variable outside the quote.
PHP Code:
echo '<p>' '<a href="'$_SERVER['PHP_SELF'] . '?showmenu='$filename'">' $menu '</a></p>'
EDIT: DOH! READ the whole string, techwench. Edit code above for variable. :P
Sure, but that doesn't mean you can't use double quotes and escape those inside the string, both ways are good.
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

Last edited by Orodreth; 07-02-2006 at 12:06 PM..
Orodreth is offline
Reply With Quote
View Public Profile Visit Orodreth's homepage!
 
Old 07-14-2006, 10:45 AM Re: How to build my own CMS
Average Talker

Posts: 24
Trades: 0
Hi Guys

Tks for the help.

Implemented wht techwench taught and its working fine.

Am now trying to control the data. Its seems with my abv code, the main page is displaying all the article at one go without any control.

Will try to figure out myself and hopefully my answer is wht yu guys might provide. Seriously i am wondering if i shud re-invent the wheel agn since there are so many free cms in mkt!

Haha....
__________________

Please login or register to view this content. Registration is FREE
- Content is King! Let others’ see and hear you.
ngsp23 is offline
Reply With Quote
View Public Profile Visit ngsp23's homepage!
 
Reply     « Reply to How to build my own CMS
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.24727 seconds with 12 queries