+ Reply to Thread
Results 1 to 4 of 4
Like Tree3Likes
  • 2 Post By disturbedart
  • 1 Post By misson

Thread: PHP Problem. only page id links

  1. #1
    disturbedart is offline x10 Lieutenant disturbedart is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    Swindon
    Posts
    458

    Thumbs up PHP Problem. only page id links

    Hello i have had a dumb moment and cant think how to do this, i have been creating a CMS at the moment and i want to be able to have pages with index.php?pid=xxx but also be able to list standard links so links to a different directory.

    Does anyone got any ideas? as my current method only allows index.php?pid=xxx links

    I was thinking an IF statement but cant think of how to code this in at the moment.

    Possible create a new field in the database called "ext" and if this is set to 1 then it shows a directory link if set to "0" then it displays index.php?pid=xxx link. And i would set up a check box on the create/edit pages section to set this.

    Any thoughts?

    Thanks.

    PHP Code:
    //---------------------------------------------------------------------------------------------------------------------------------------------------------------
    // Build Main Navigation menu and gather page data here -----------------------------------------------------------------------------
    $sqlCommand "SELECT id, linklabel FROM pages WHERE showing='1' ORDER BY id ASC"
    $query mysqli_query($myConnection$sqlCommand) or die (mysqli_error($myConnection)); 
    $menuDisplay '<ul>';
    while (
    $row mysqli_fetch_array($query)) { 
        
    $pid $row["id"];
        
    $linklabel $row["linklabel"];
     
     
    $menuDisplay .= '<li><a href="index.php?pid=' $pid '">' $linklabel '</a></li>';
     

    $menuDisplay .= '</ul>';
    mysqli_free_result($query); 
    //---------------------------------------------------------------------------------------------------------------------------------------------------------------
    //mysqli_close($myConnection); 
    Free Professional Webdesigns!

    Check it out!
    .................................................. ......................

  2. #2
    John Rambo is offline x10Hosting Member John Rambo is an unknown quantity at this point
    Join Date
    Jun 2011
    Posts
    21

    Re: PHP Problem. only page id links

    Add a new filed in table, for example url:
    PHP Code:
    while ($row mysqli_fetch_array($query)) { 
      
    $linklabel $row["linklabel"];
      if ( 
    $row['url'] ) { // && you can check $row['ext'] as well
        
    $menuDisplay .= '<li><a href="' $row['url'] . '">' $linklabel '</a></li>';
      } else {
        
    $pid $row["id"];
        
    $menuDisplay .= '<li><a href="index.php?pid=' $pid '">' $linklabel '</a></li>';
      }

    You can add 2 fileds, and show url if only ext field is set to 1.

  3. #3
    disturbedart is offline x10 Lieutenant disturbedart is an unknown quantity at this point
    Join Date
    Jun 2006
    Location
    Swindon
    Posts
    458

    Re: PHP Problem. only page id links

    Thanks this worked perfectly i dont know why i didnt think of this method,
    Cheers,
    Kyle.
    dinomirt96 and karimirt47 like this.
    Free Professional Webdesigns!

    Check it out!
    .................................................. ......................

  4. #4
    misson is offline x10 Spammer misson is a jewel in the rough
    Join Date
    Mar 2008
    Location
    Libertatia
    Posts
    2,506

    Re: PHP Problem. only page id links

    Quote Originally Posted by disturbedart View Post
    PHP Code:
    $query mysqli_query($myConnection$sqlCommand) or die (mysqli_error($myConnection)); 
    Don't use die when outputting HTML. You'll get invalid HTML.

    Outputting database error messages to non-admin users discloses too much information. Instead, log the MySQL error message. For some errors (such as those related to missing or invalid values), output your own error message to the user and what action the user can take to address it. For the rest, inform the user that there was an internal error.
    koforqtssweet15 likes this.
    Be sure to read all pages linked in this post; they have further information that should prove useful. When asking for help, make sure you follow Eric Raymond's and Jon Skeet's guidelines for prompt, accurate responses. Please answer any questions I ask; they're not rhetorical (probably). Any posted code is intended as illustrative example, rather than a solution to your problem to be copied without alteration. Study it to learn how to write your own solution.
    Misson, not Mission.

+ Reply to Thread

Similar Threads

  1. Links to Knowledgebase on Support page are dead
    By wardjk63 in forum Free Hosting
    Replies: 0
    Last Post: 11-03-2011, 01:22 PM
  2. how to put links on right and left side of page
    By sanso_9970 in forum Programming Help
    Replies: 7
    Last Post: 09-01-2011, 01:16 PM
  3. my web page news links have dissapeared?
    By phoenix2010 in forum Free Hosting
    Replies: 5
    Last Post: 08-29-2010, 06:16 AM
  4. Get Listed on the Links Page of my site
    By Jesse in forum Ads & Offers
    Replies: 9
    Last Post: 01-19-2008, 08:43 PM
  5. my page links
    By welard in forum Computers & Technology
    Replies: 2
    Last Post: 11-10-2007, 03:29 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
x10hosting free hosting for the masses
dedicated servers