lancey10 Posted February 21, 2006 Share Posted February 21, 2006 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? Quote Link to comment Share on other sites More sharing options...
lancey10 Posted February 21, 2006 Author Share Posted February 21, 2006 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? Quote Link to comment Share on other sites More sharing options...
fenway Posted February 21, 2006 Share Posted February 21, 2006 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. Quote Link to comment Share on other sites More sharing options...
lancey10 Posted February 21, 2006 Author Share Posted February 21, 2006 second question is how can u submit to mysql and post to a php file at the same time? Quote Link to comment Share on other sites More sharing options...
fenway Posted February 21, 2006 Share Posted February 21, 2006 I don't understand the question -- it's the script that connects to the DB. Quote Link to comment Share on other sites More sharing options...
lancey10 Posted February 22, 2006 Author Share Posted February 22, 2006 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 Quote Link to comment Share on other sites More sharing options...
fenway Posted February 22, 2006 Share Posted February 22, 2006 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? Quote Link to comment Share on other sites More sharing options...
lancey10 Posted February 22, 2006 Author Share Posted February 22, 2006 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 databasemysql_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 returnedif (mysql_num_rows($result) > 0) {// yes// print them one after anotherecho "$mysql_result[id]";}else {// no// print status messageecho "No rows found!";}// close connectionmysql_close($connection);?> [/code]what did i do wrong? Quote Link to comment Share on other sites More sharing options...
fenway Posted February 22, 2006 Share Posted February 22, 2006 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? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.