Jump to content

Archived

This topic is now archived and is closed to further replies.

lancey10

big time help!

Recommended Posts

Ok, i would like to insert information from a Row, lets say row 1 ( SELECT * FROM `table` WHERE `id` = '1' ) and insert the data in a template, and it will have a url that will be something like index.php?page=1. How do i go by doing that?
and how would i go by doing that with every row that is created?

Share this post


Link to post
Share on other sites
also how do i go by creating a entire different page with the content that u filled out on a form and you click submit?

Share this post


Link to post
Share on other sites
The answer to your first question is simply to retrieve the id value from the $_GET hash, then run the desired query (as per above) and substitute the appropriate id value. Once you have all the field values, do whatever you want with them in your template. And I don't understand your second question.

Share this post


Link to post
Share on other sites
I don't understand the question -- it's the script that connects to the DB.

Share this post


Link to post
Share on other sites
ok lets say when i submit the form it makes and ID that equals 1 and the id will be inserted it to the url like: index.php?page=1, now when i click on that link, it wont do anything because it doesnt know where to connect to..... so how do i make the submit button that will grab a certain row information (like row 1 a.k.a ID 1) and display it on a template, and give it a name index.php?page=1

Share this post


Link to post
Share on other sites
Maybe I wasn't clear before -- on your index.php page, you check to see if a GET parameter was passed in PHP, and if so, query whatever table you desire. The submit button doesn't "do" anything but call your script with a parameter. Where did I lose you?

Share this post


Link to post
Share on other sites
ok, i think i found an easier way to do it, but it says "No rows found!"
here is my script:
[code]<?php
$page = $_GET[page];

// mysql variables
$host = "BLOCKED";
$user = "dbo154983898";
$pass = "BLOCKED";
$db = "db154983898";

// open connection
$connection = mysql_connect($host, $user, $pass) or die ("Unable to connect!");

// select database
mysql_select_db($db) or die ("Unable to select database!");

// Grabs variable from url

// Setup mysql connection
$query = "SELECT * FROM 'reviews' WHERE 'id' = '$page' ";
$result = mysql_fetch_array($query);
// Then display the result as you wish
// see if any rows were returned

if (mysql_num_rows($result) > 0) {
// yes
// print them one after another
echo "$mysql_result[id]";
}
else {
// no
// print status message
echo "No rows found!";
}

// close connection
mysql_close($connection);

?>

[/code]

what did i do wrong?

Share this post


Link to post
Share on other sites
First, I assume what looks like single quotes around your column/table names are in fact backticks, not single quotes, otherwise it won't work. Assuming that's not it, are you sure such a record exists?

Share this post


Link to post
Share on other sites

×

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.