liamC
Member
Registered: 28th Feb 04
User status: Offline
|
Right...just a thought/idea if anyone has any how to do this, or if it is possible.
Got a homepage (PHP) with 4 boxes on it. Each box has special offer text in it.
It would be ideal if via an admin page of some sort, that staff were able to type into a box what text they wanted in each special offer box and it then updates the homepage with the text they've just typed in.
Is this possible. Anyone have anymore info on this feature/function?
Cheers
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
Store the text of each one in a database.
Read it out on the homepage and create an admin screen that chages it in the DB
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
Is this hard to do mate?
I can write text to the database no problem, and can set that up easy, but it would be displaying the text that I would have a problem with, as I've never done this before? Any pointers/tips? Does it take much programming?
|
AndyKent
Member
Registered: 3rd Sep 05
User status: Offline
|
just SELECT the text out of the database (into a $var) and then echo it out again - simple...
[Edited on 24-01-2007 by aPk]
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
Cheers.
Anyone able to help me out with the code for this?
I am a php n00b.
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
OK, getting there eventually.
code: <?php
$db = mysql_connect("mysqlname.domain.com", "username", "password");
mysql_select_db("databasename",$db);
$result = mysql_query("SELECT databasetable FROM databasename",$db);
while($myrow = mysql_fetch_array($result))
{
echo $myrow["rowname"];
}
?>
I get the following error:
code: php:
Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/.saggy/user/domain.com/folder/index.php on line 61
?>
Any ideas where I'm going wrong?
[Edited on 24-01-2007 by liamC]
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
Nevermind, sorted it!
For future reference, in this line of code taken from my above post;
code: $result = mysql_query("SELECT databasetable FROM databasename",$db);
change it to
code: $result = mysql_query("SELECT * FROM tablename",$db);
Cheers for your help James/aPk for the help. Wasn't so hard at all
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
OK...another one.
I have made a table wit 2 fields (Title field and description field) so it is echoing 2 rows;
code: echo $myrow["title"];
echo $myrow["desc"];
Each field has 4 rows.
How would I get the PHP to only select the top row, or the third row etc?
[Edited on 24-01-2007 by liamC]
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
I would set a flag, say call the field "AdvertId" or something. Give it 1, 2, 3, 4 etc and then put "Where AdvertId = 3" etc on the end of the select.
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
I love you James
One last thing though...(for now!).
The 2 rows which are being echoed, I want a line space between them.
Putting a <br /> inbetween them doesn't work as it is obviously disrupting the PHP code.
Also, I would like the row in bold!!
Any ideas?
[Edited on 24-01-2007 by liamC]
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
echo <br />;
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
oops might need the <br /> in speech marks.
havent done PHP for ages.
[Edited on 24-01-2007 by James]
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
Bold - Put echo "<b>"; before the text and echo "</b>"; after
|
James
Member
Registered: 1st Jun 02
Location: Surrey
User status: Offline
|
You can apply any HTML styles to it just as you would anything else by echo-ing out the HTML
|
liamC
Member
Registered: 28th Feb 04
User status: Offline
|
yay! Thanks very much for your help mate - much appreciated!!!
|