Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 9 of 9

Thread: Help Please

  1. #1
    Join Date
    Jun 2005
    Location
    USA
    Posts
    2,047
    Tokens
    0

    Latest Awards:

    Default Help Please

    I want to add news catergories into this news script. I want it so i click UK News and the uk news will show.

    PHP Code:
    <?   
    ob_start
    (); # Allows Cookies  
    include("config.php"); 
    if(
    $logged[username] && $logged[level] == 12 || $logged[level] == 9){
    switch(
    $_GET[action]){
    default:
    echo(
    "<b><u>Add News</b></u><br>Here you can add news to Thishabbo. Please only post news, and make sure the image url is correct, and check it once you have posted it");
    echo(
    "<form method=\"post\" action=\"addnews.php?action=submit_news\">   
      Title:<br>   
    <input type='text' size='30' name='title'>
      <br>  
      <br>   
      Image URL:<br>   
    <input type='text' size='30' name='image'><br><br>
    News Story: (Simple HTML Allowed eg. Bold, Underline, Italic)<br>
      <textarea name=\"content\" cols='80' rows='10'></textarea>   
      <br>    
      <input type=\"submit\" value=\"Submit Article\"></form>"
    );
    break;

    case 
    'submit_news':
    $author $logged[username];
    $date $date =  date("j F");
    $title $_POST[title];
    $image $_POST[image];
    $contents $_POST[content];
    if(
    $title==NULL||$image==NULL||$content==NULL){
    echo(
    "<meta http-equiv=\"Refresh\" content=\"2; URL=addnews.php\"/>You have left a field blank<br><br><b>Please Wait...</b>");
    }else{
    $sql=("INSERT INTO `news` (id, date, author, title, content, image)VALUES('', '$date', '$author', '$title', '$contents', '$image')");
    $result mysql_query($sql) or die ('Error during the execution of the MySQL query : ' mysql_error());
    echo(
    "<meta http-equiv=\"Refresh\" content=\"2; URL=viewnews.php\"/>Your News Article has successfulyl been submitted!<br><br><b>Please Wait...</b>");
    }
    break;
    }
    }else{
    echo(
    "You need to be Admin or a Manager to view this!");
    }
    ?>
    + rep if you can help.
    *Image Removed*

    Thank you Brad for the sig


    Signature edited by Nick- (Forum Super Moderator): Please do not have images that exceed the limit for non VIPs (700 x 150) in your signature.

  2. #2
    Join Date
    Jun 2005
    Location
    USA
    Posts
    2,047
    Tokens
    0

    Latest Awards:

    Default

    UPDATE :-

    The catergories i need are

    UK News
    CA News
    USA News
    World News
    Site News
    *Image Removed*

    Thank you Brad for the sig


    Signature edited by Nick- (Forum Super Moderator): Please do not have images that exceed the limit for non VIPs (700 x 150) in your signature.

  3. #3
    Join Date
    Jan 2007
    Location
    Wales
    Posts
    2,432
    Tokens
    141

    Latest Awards:

    Default

    <?
    ob_start
    (); # Allows Cookies
    include("config.php");
    if(
    $logged[username] && $logged[level] == 12 || $logged[level] == 9){
    switch(
    $_GET[action]){
    default:
    echo(
    "<b><u>Add News</b></u><br>Here you can add news to Thishabbo. Please only post news, and make sure the image url is correct, and check it once you have posted it");
    echo(
    "<form method=\"post\" action=\"addnews.php?action=submit_news\">
    Title:<br>
    <input type='text' size='30' name='title'>
    <br>
    <br>
    Image URL:<br>
    <input type='text' size='30' name='image'><br><br>
    News Story: (Simple HTML Allowed eg. Bold, Underline, Italic)<br>
    <textarea name=\"content\" cols='80' rows='10'></textarea>
    <br>
    Category:<br />
    <select name='cat'>
    <option>UK News</option>
    <option>CA News</option>
    <option>USA News</option>
    <option>World News</option>
    <option>Site News</option>
    </select>
    <br>
    <input type=\"submit\" value=\"Submit Article\"></form>");
    break;

    case
    'submit_news':
    $author = $logged[username];
    $date = $date = date("j F");
    $title = $_POST[title];
    $image = $_POST[image];
    $cat = $_POST[cat];
    $contents = $_POST[content];
    if(
    $title==NULL||$image==NULL||$content==NULL){
    echo(
    "<meta http-equiv=\"Refresh\" content=\"2; URL=addnews.php\"/>You have left a field blank<br><br><b>Please Wait...</b>");
    }else{
    $sql=("INSERT INTO `news` (id, date, author, title, content, image)VALUES('', '$date', '$author', '$title', '$contents', '$image')");
    $result = mysql_query($sql) or die ('Error during the execution of the MySQL query : ' . mysql_error());
    echo(
    "<meta http-equiv=\"Refresh\" content=\"2; URL=viewnews.php\"/>Your News Article has successfulyl been submitted!<br><br><b>Please Wait...</b>");
    }
    break;
    }
    }else{
    echo(
    "You need to be Admin or a Manager to view this!");
    }
    ?>
    ---------------------------------

    Hope that's what you wanted and hope it works.
    If not tell me
    Last edited by ThisNameWillDo!; 29-01-2007 at 04:39 PM.
    Free Online Games And Videos:
    http://www.vincesgames.com



  4. #4
    Join Date
    Jan 2007
    Location
    Wales
    Posts
    2,432
    Tokens
    141

    Latest Awards:

    Default

    Just edited the above code so if you used it before I edited it, try it now
    Free Online Games And Videos:
    http://www.vincesgames.com



  5. #5
    Join Date
    Jun 2005
    Location
    USA
    Posts
    2,047
    Tokens
    0

    Latest Awards:

    Default

    I have been told to do this but i cant get it too work. How would i set out the SQL table for it. and where abouts would i add the code below. + rep for help.

    create a new MySQL table called cats then set names and id's for them. Then in your news table add a new field called cat_id then in there put the id of the cat you want that news item to be in. Then to select the specific news do
    CODE
    PHP Code:
    $id $_GET['cat'];//GEt the cat in the url

    $query = @mysql_query(SELECT FROM `newsWHERE `cat_id` = '".$id."';")or die("Could not get news!" . mysql_error());//Query the db or show an error
    while( 
    $n = mysql_fetch_array($query))//Get the array
    {
    //Echo the news here!

    *Image Removed*

    Thank you Brad for the sig


    Signature edited by Nick- (Forum Super Moderator): Please do not have images that exceed the limit for non VIPs (700 x 150) in your signature.

  6. #6
    Join Date
    Jan 2007
    Location
    Wales
    Posts
    2,432
    Tokens
    141

    Latest Awards:

    Default

    Hold on, I'm confused with what you want help with now

    is it creating the database or getting the category to show?
    Free Online Games And Videos:
    http://www.vincesgames.com



  7. #7
    Join Date
    Jun 2005
    Location
    USA
    Posts
    2,047
    Tokens
    0

    Latest Awards:

    Default

    creating a database for the catergorys and ID's and to add that code above into the code in my first post so it will work.
    *Image Removed*

    Thank you Brad for the sig


    Signature edited by Nick- (Forum Super Moderator): Please do not have images that exceed the limit for non VIPs (700 x 150) in your signature.

  8. #8
    Join Date
    Jan 2007
    Location
    Wales
    Posts
    2,432
    Tokens
    141

    Latest Awards:

    Default

    Oh, Ok, I've PMed you.
    Free Online Games And Videos:
    http://www.vincesgames.com



  9. #9
    Join Date
    Jun 2005
    Location
    USA
    Posts
    2,047
    Tokens
    0

    Latest Awards:

    Default

    Anyone help on this?
    *Image Removed*

    Thank you Brad for the sig


    Signature edited by Nick- (Forum Super Moderator): Please do not have images that exceed the limit for non VIPs (700 x 150) in your signature.

Posting Permissions

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