CainFool Posted July 23, 2009 Posted July 23, 2009 Im working on a script which I can modify from the Admin cPanel which basically allows you to edit the latest news, err.. the picture might be better. I want to be able to do that, but instead of editing the header.php all the time, I want to be able to edit it by the Admin Control Panel. This is my first time doing this so please no bad comments. testing.php <?php { include "globals.php"; global $db, $ir, $c, $h; print "<h3>The Newspaper</h3>"; $q=$db->query("SELECT text FROM header LIMIT 1"); $text=$db->fetch_single($q); print " <tr> <td colspan=3>$text</td></tr> </table>"; } $h->endpage(); ?> Im using that from the newspaper and im just editing it off that temporarily until I can get it sorted. I have a table in my database called header, and a field called text, but it's not coming up. MySQL CREATE TABLE IF NOT EXISTS `header` ( `text` longtext NOT NULL ) ENGINE=MyISAM DEFAULT CHARSET=latin1; -- -- Dumping data for table `header` -- INSERT INTO `header` (`text`) VALUES ('testing text'); What am I doing wrong? Quote
CainFool Posted July 23, 2009 Author Posted July 23, 2009 Re: [uRGENT] Help with my Code! [mcCodes v2] BUMP come on, answer Quote
AlabamaHit Posted July 23, 2009 Posted July 23, 2009 Re: [uRGENT] Help with my Code! [mcCodes v2] peeople will answer when they are on, and ready, please don't bump after an hour. try this for your staff stuff.. if(!isset($_POST['stuff'])) { $j = $db->fetch_row($db->query("SELECT `text` FROM `header`")); echo 'Enter stuff you want to put in there. '; echo '<form action="'.$_PHP['SELF'].'" method="post">'; echo '<input type="hidden" name="stuff" />'; echo '<textarea rows="20" cols="20">'.$j['text'].'</textarea>'; echo '</form>'; } else { $stuff = trim(mysql_real_escape_string($_POST['stuff'])); if(empty($stuff)) { echo 'You did not enter anything.'; exit; } $db->query("UPDATE `header` SET `text` = ".$stuff.""); echo 'You just updated it.'; } Now to display it,...i would do this. $he = mysql_fetch_object($db->query("SELECT `text` FROM `header`")); echo sprintf('%s',stripslashes($he->text)); //This will show the stuff.... Quote
CainFool Posted July 23, 2009 Author Posted July 23, 2009 Re: [uRGENT] Help with my Code! [mcCodes v2] where should i place it? Quote
Danny696 Posted July 28, 2009 Posted July 28, 2009 Re: [uRGENT] Help with my Code! [mcCodes v2] <?php { include "globals.php"; global $db, $ir, $c, $h; print "<h3>The Newspaper</h3>"; $q=$db->query("SELECT text FROM header LIMIT 1"); $text=$db->fetch_single($q); print " <tr> <td colspan=3>$text</td></tr> </table>"; } $h->endpage(); AND $he = mysql_fetch_object($db->query("SELECT `text` FROM `header`")); echo sprintf('%s',stripslashes($he->text)); //This will show the stuff.... try this: <?php { include "globals.php"; global $db, $ir, $c, $h; print "<h3>The Newspaper</h3>"; $he = mysql_fetch_object($db->query("SELECT `text` FROM `header`")); print " <tr> <td colspan=3>echo sprintf('%s',stripslashes($he->text));</td></tr> </table>"; } $h->endpage(); ?> meh i didnt do the work AlabamaHit did it i just put 2 & 2 together and made 4 Yay Quote
POG1 Posted July 29, 2009 Posted July 29, 2009 Re: [uRGENT] Help with my Code! [mcCodes v2] No offence but is this really needed? echo sprintf('%s',stripslashes($he->text)); @CainFool You could add the message bit to the settings table. Then all you would need to do is something like this into the header; if(isset($set['game_message'])) { echo '<div id="gameMessage">'. $set['game_message']. '</div>'; } Quote
Danny696 Posted July 29, 2009 Posted July 29, 2009 Re: [uRGENT] Help with my Code! [mcCodes v2] No offence but is this really needed? echo sprintf('%s',stripslashes($he->text)); @CainFool You could add the message bit to the settings table. Then all you would need to do is something like this into the header; if(isset($set['game_message'])) { echo '<div id="gameMessage">'. $set['game_message']. '</div>'; } if he did it that way he would need to add another row into the settings Quote
POG1 Posted July 29, 2009 Posted July 29, 2009 Re: [uRGENT] Help with my Code! [mcCodes v2] if he did it that way he would need to add another row into the settings Easy.. INSERT INTO `settings` (`conf_name` ,`conf_value`) VALUES ('game_message', 'IT WORKS!!!!'); Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.