Jump to content


Photo

big time help!


  • Please log in to reply
8 replies to this topic

#1 lancey10

lancey10
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 21 February 2006 - 03:48 AM

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?

#2 lancey10

lancey10
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 21 February 2006 - 05:04 AM

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?

#3 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 21 February 2006 - 05:53 AM

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.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#4 lancey10

lancey10
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 21 February 2006 - 05:57 AM

second question is how can u submit to mysql and post to a php file at the same time?

#5 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 21 February 2006 - 09:18 PM

I don't understand the question -- it's the script that connects to the DB.
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#6 lancey10

lancey10
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 22 February 2006 - 03:01 AM

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

#7 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 22 February 2006 - 03:16 AM

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?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.

#8 lancey10

lancey10
  • Members
  • PipPip
  • Member
  • 13 posts

Posted 22 February 2006 - 04:15 AM

ok, i think i found an easier way to do it, but it says "No rows found!"
here is my script:
<?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);

?> 


what did i do wrong?

#9 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 22 February 2006 - 08:06 AM

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?
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users