Jump to content

[SOLVED] A Little Help index.php?Page=Home


ow-design

Recommended Posts

Hi,

 

Okay i am struggling with this one as a PHP newby, I can get information from a database using id?=(numeric figure)

 

but how do i call from a database using a title.

 

I have for example a table with the following columns, title, Content, Added

 

how can i get information from a row with an address such as.

 

www.site.com?page=Home

 

Thank You,

Ollie

Link to comment
Share on other sites

You have to select each part, like this:

$result = mysql_query("SELECT item FROM table WHERE title='$title'") or die(mysql_error());

$item = mysql_result ($result, 0, 'item');

 

Let item be whatever value you need.

Then echo $item

You don't need to do that.

 

mysql_fetch_assoc returns an associative array of columns. Just save each item of the array to a variable. Then do what ever you want with the variables.

 

$row = mysql_fetch_assoc($result);

$title = $row['title'];
$content = $row ['content'];

echo '
<h1>'.$title.'</h1>
<p>'. $content . '</p>
';

Link to comment
Share on other sites

okay i dont know what i am doing wrong but this is not working...

 

Would you be able to give me a complete code... To connect to a database to select from a table called pages and looking for the ?page=

 

and the code i need to pick the title, content and author from the table row and display them individually.??

 

Really appreciate any help.

Thank You

Link to comment
Share on other sites

okay i dont know what i am doing wrong but this is not working...

 

Would you be able to give me a complete code... To connect to a database to select from a table called pages and looking for the ?page=

 

and the code i need to pick the title, content and author from the table row and display them individually.??

 

Really appreciate any help.

Thank You

I'm not here write scripts for you. I'm here to help/guide you.

 

You said earlier

I can get information from a database using id?=(numeric figure)

With that being said, you should know how to pull data from a databased on any type of column.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.   Restore formatting

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

Important Information

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.