Jump to content
MakeWebGames

Recommended Posts

Posted

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.

JulPicture%204.png

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?

Posted

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....
Posted

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

Posted

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>';

}
Posted

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

Posted

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!!!!');

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...