Jump to content
xisto Community
marretas

Need Some Help Using PHP & MySQL

Recommended Posts

I wonder if its possible or if anyone know how to :

I'm making a website for my soccer team and every week there are new news, but in the index file i only show some part of the text and the rest of the news is in Stored in Database, of course that all news are inside mysql database, i only set a script to get from the Database the text and title and so. My doubt is if there is some how to attach a link to that news and when i run the link, this show me another page but with FULL news text ? i Read something like, i've to create a cicle

<?php                // mysql connections // Select database bla bla bla             -> Then html Mask                 and inside de php code to inteact with mysql ( just an E.g )                            $id ( its hidden, i dont need to show it )                $foto               <a href='news?id=$id'>                 $title               </a>                $subtitle                $parttext             ->  End html Mask                Then when i click hover the link                 Opens a new File ( news.php )                -> Html Mask                                // mysql connections // Select database bla bla bla                   $getnews = "SELECT * FROM news WHERE ´id´ = '$id' ";                  mysql_query($getnews);                 Then the Output                $foto                $title                $subtitle                $FULLTEXT         -> END HTML MASK?>

Did i missed something ???

Share this post


Link to post
Share on other sites

Well from what I can see so far all you did with what you have shown is your post is that you told the MySQL server to send a resultset of all the colums in the news table with a particular id. But this would be the array of $getnews which should contain a foto a title a subtitle and then the fulltext but you need to process further that what you have shown, so I guess what I am saying is there more code to display the result set of $getnews?

Share this post


Link to post
Share on other sites

Okay, sounds good. I didn't notice any particular question. Perhaps if you post some actual code, or ask a particular question we could help you a little better. If you're just using this as a design and asking if it will work, then it looks alright. Now you just need to code it up. If you pass the id via the querystring I don't see why you couldn't do it. All you need to do is limit how much of the story is actually shown on your main page ('index.php'). How are you going to do that? Just limit how many characters of the string are shown? Pull the entire string and cut off the last so many characters per entry of news?

Share this post


Link to post
Share on other sites

Thats all, you got it, im the webmaster of a page related to the best soccer team here in Peru:

 

Club Universitario de Deportes

 

and in the main page i do almost the same thing, please visit Trinchera Norte to see it in action, this show the 8 last news (4 complete and 4 only shows the title), all are linked to their respective detail page.

 

Some others considerations that you can take are for example limit the number of news that you can show,, show the next game of your soccer team (date, stadium, opponent), place a link to the news index and a lot of other things.

 

best regards,

Share this post


Link to post
Share on other sites

Hi i'am ronald.
I make a website for my cafĂŠ and read this topic.

First we make contact to a database (your database name!).

<?$conn = mysql_connect("localhost", "username", "password");mysql_select_db("yourdatabase", $conn) or die(mysql_error());?>

This is the connection to the database.

Select or Update or Delete ?

When you are select some data the most simple line is
$sql = select * from tabelname;mysql_query($sql) or die(mysql_error());

* means a wildcard this seems to call all names in the tabel.

When you are update some data the most simple line is
$sql = "update tabelname set name=$_POST['name']";mysql_query($sql) or die(mysql_error());
When you are delete some data then call
$sql = "delete * from tabelname where id='"$_POST['id']"'";mysql_query($sql) or die(mysql_error());

This is the simple way to connect php to a MySQL database!

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.