Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Nov 2010
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Arrow Please help me oh yee magical programming masters :)

    Okay... so I am loading some content into my page from the database... I know how to do this normally... but here is the sticking point... I want to load the content from one of 5 options (so there are multiple pages with 5 different options for body copy) depending on what the value of the cookie is...

    Here is what I tried, but it did not work:

    PHP Code:
    //Determin which page ID to use in our query ----------------------------------------------------------------------------------------------
    if (!$_GET['pid']){
        
    $pageid '1';    
    } else {
        
    $pageid $_GET['pid'];
    }
    //Query the Main Content and Titles for the proper page ---------------------------------------------------------------------------------------------
    $sqlCommand="SELECT process_mainContent_vers1, process_mainContent_vers2, process_mainContent_vers3, process_mainContent_vers4, process_mainContent_vers5, process_pagetitle FROM pages_process WHERE process_id='$pageid' LIMIT 1";
    $query=mysqli_query($myConnection$sqlCommand) or die (mysql_error());
    $body '';
    $title '';
    while (
    $row mysqli_fetch_array($query))
    {
        if (isset(
    $_COOKIE['career_status']))
        {
            
    $carreerStatus = ($_COOKIE['career_status']);
            
            if (
    $carreerStatus=="Starting Residency/Graduating Medical School")
                
    $body $row["process_mainContent_vers1"];
                
            if (
    $carreerStatus=="Ending Residency/Starting Fellowship")    
                
    $body $row["process_mainContent_vers2"];
                
            if (
    $carreerStatus=="Practicing Physician")
                
    $body $row["process_mainContent_vers3"];
                
            if (
    $carreerStatus=="Practicing Physician")
                
    $body $row["process_mainContent_vers4"];
                
            if (
    $carreerStatus=="Hospital/Practice Administrator")
                
    $body $row["process_mainContent_vers5"];
        }
        else
        {
            
    $carreerStatus = ($_SESSION['career_status']);
            
            if (
    $carreerStatus=="Starting Residency/Graduating Medical School")
                
    $body $row["process_mainContent_vers1"];
                
            if (
    $carreerStatus=="Ending Residency/Starting Fellowship")    
                
    $body $row["process_mainContent_vers2"];
                
            if (
    $carreerStatus=="Practicing Physician")
                
    $body $row["process_mainContent_vers3"];
                
            if (
    $carreerStatus=="Practicing Physician")
                
    $body $row["process_mainContent_vers4"];
                
            if (
    $carreerStatus=="Hospital/Practice Administrator")
                
    $body $row["process_mainContent_vers5"];
        }
        
        
    $title $row["process_pagetitle"];
    }
    mysqli_free_result($query);
    //----------------------------------------------------------------------------------------------------------------------------------------- 

  • #2
    Master Coder
    Join Date
    Jun 2003
    Location
    Cottage Grove, Minnesota
    Posts
    9,464
    Thanks
    8
    Thanked 1,085 Times in 1,076 Posts
    First of all, make sure you found something in the query ...
    add an echo (shown in red) to make sure a row was found ...

    $body = '';
    $title = '';
    while ($row = mysqli_fetch_array($query))
    {
    echo "row found <br>";


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •