Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Ok, my first post, yay!
I havent been using PHP for long so I am still learning alot. I used a tutorial the other day to add a "News" section to my website. It is pretty basic, just has Incremented ID, Title, Author, Post and Date. I have that working fine but what i want to do now is add 3 radio buttons so that I can add a image into the table row the title is in. So, basically its going to be a row with the image aligning to the left and the title aligned to the middle, then another row below it with the post and then another row below that with the Author and Date. I have the layout allready but I need to get that image in there relating to one of the radio buttons.
this is the code i have for the addnews.php form:Code: Select all
<?php
if (isset($_POST['submitted'])) {
include ('mysql_connect.php');
if (empty($_POST['title'])) {
echo '<p><font color="red">You need to enter a title.</font></p>';
} else {
$title = $_POST['title'];
}
if (empty($_POST['name'])) {
echo '<p><font color="red">You need to enter a name.</font></p>';
} else {
$name = $_POST['name'];
}
if (empty($_POST['message'])) {
echo '<p><font color="red">You need to enter a message.</font></p>';
} else {
$message = $_POST['message'];
}
if ($title && $name && $message) {
$query = "INSERT INTO news_posts (title, author, newstype, post, date) VALUES ('$title', '$name', '$newstype', '$message', NOW())";
$result = @mysql_query($query);
if ($result) {
echo '<p><font color="red">News was added!</font></p>';
} else {
echo '<font color="red"><p>News could not be added! Please try again.</p></font>';
}
} else {
echo '<p><font color="red">Please fill in the appropriate information</font></p>';
}
}
?>
<form action="<?php $_SERVER['PHP_SELF']; ?>" method="post">
<p><b>News Title :</b><br />
<input type="input" name="title" size="25" maxlength="60" value="<?php if(isset($_POST['title'])) echo $_POST['title']; ?>" /></p>
<p><b>Name :</b><br />
<input type="input" name="name" size="15" maxlength="35" value="<?php if(isset($_POST['name'])) echo $_POST['name']; ?>" /></p>
<p><b>News Type :</b><br />
<input type="radio" name="newstype[]" value="news" /> News<br />
<input type="radio" name="newstype[]" value="wow" /> World of Warcraft<br />
<input type="radio" name="newstype[]" value="war" /> Warhammer 40,000<br />
<input type="radio" name="newstype[]" value="random" /> Random</p>
<p><b>Message :</b><br />
<textarea rows="7" cols="55" name="message"><?php if(isset($_POST['message'])) echo $_POST['message']; ?></textarea></p>
<p><input type="submit" name="submit" value="Add News" /></p>
<input type="hidden" name="submitted" value="TRUE" /></p>
</form>Hope that made sense. Thanks for any responces.
Regards,
Xager
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]