Results 1 to 3 of 3
  1. #1

    MySQL $_GET help needed

    Hi, i am trying to set up this function to call "cat" from the browsers window, the table should try to find its value and include the corrisponding file. But if it doesnt exist i want it to just use the default value for $cat so the file include can just call this.

    Here is the code thats not working:
    PHP Code:
    <?
    $cat 
    $_GET['cat'];
    $result mysql_query("SELECT * FROM tablename WHERE category = '$cat' LIMIT 1");
    if (!
    $result) { // if it didnt find the $cat content in the table
    $col2 "default";
    }
    else { 
    // else if i did find the $cat content in the table
    while ( $row mysql_fetch_array($result) ) {
    $col2 $row["col2"];
    }
    }
    require_once(
    "folder/".$col2."/file.php");
    ?>
    Thanks in Advance,
    Matt
    http://www.theextremenetwork.com
    MSN: [email protected]

  2. #2
    Are the results you are searching for located in "col2" of your table? If so, you could change your query to include the name of the column that has your result(col2). This way you will isolate the variable and then call it in your array using $row[0].

    Not sure if that fixes everything, just some thoughts.

    PHP Code:
    <? 
    $cat 
    $_GET['cat']; 
    $result mysql_query("SELECT columnName FROM tablename WHERE category = '$cat' LIMIT 1"); 
    $col2 "default"//Set as default - no if needed
    if { // if $cat content matches
    $row mysql_fetch_array($result); // you wouldn't need a loop for one result
    $col2 $row[0]; 

    require_once(
    "folder/".$col2."/file.php"); 
    ?>
    Gleem Studios
    www.gleem.com

  3. #3
    Thanks, thats really helpfull!!
    http://www.theextremenetwork.com
    MSN: [email protected]

Posting Permissions

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