corsasport.co.uk
 

Corsa Sport » Message Board » Off Day » Geek Day » PHP/HTML


New Topic

New Poll
  Subscribe | Add to Favourites

You are not logged in and may not post or reply to messages. Please log in or create a new account or mail us about fixing an existing one - register@corsasport.co.uk

There are also many more features available when you are logged in such as private messages, buddy list, location services, post search and more.


Author PHP/HTML
liamC
Member

Registered: 28th Feb 04
User status: Offline
24th Jan 07 at 15:17   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 15:18   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 15:21   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 15:26   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 15:47   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 16:45   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 16:51   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 17:12   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 17:13   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 17:20   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 17:21   View User's Profile U2U Member Reply With Quote

echo <br />;

James
Member

Registered: 1st Jun 02
Location: Surrey
User status: Offline
24th Jan 07 at 17:21   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 17:24   View User's Profile U2U Member Reply With Quote

Bold - Put echo "<b>"; before the text and echo "</b>"; after
James
Member

Registered: 1st Jun 02
Location: Surrey
User status: Offline
24th Jan 07 at 17:26   View User's Profile U2U Member Reply With Quote

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
24th Jan 07 at 17:32   View User's Profile U2U Member Reply With Quote

yay! Thanks very much for your help mate - much appreciated!!!

 
New Topic

New Poll

  Related Threads Author Forum Replies Views Last Post
making a website Dave A Geek Day 59 3552
2nd Oct 06 at 19:45
by CorsaChris12
 
Young wippersnappers - Website tutourials wanted. Daimo B Geek Day 28 2245
8th Dec 06 at 14:24
by Cybermonkey
 
MYSQL Problem(s) liamC Geek Day 23 1003
14th Jan 07 at 14:21
by Ian
 

Corsa Sport » Message Board » Off Day » Geek Day » PHP/HTML 28 database queries in 0.0109110 seconds