Ramones Posted July 23, 2007 Share Posted July 23, 2007 Ok I am working on a small website for some friends and I have hit three small roadblocks due to my small amount of PHP/MYSQL knowledge So my MySql table has these rows: Title Quick Pic Instruction Difficulty Parts Uploading pictures is my first problem, i can't find a simple script to do this for some reason I made a page that prints out Title, Quick, and Difficulty in a table I want it to make a link on the title that leads to a page which has everything on it And I would like to have a combo box allowing the user to sort between Title Ascending, Title Descending, Difficulty Ascending, Difficulty Descending Thanks in advance Quote Link to comment Share on other sites More sharing options...
simcoweb Posted July 23, 2007 Share Posted July 23, 2007 1. there's a tutorial here in the tutorial section for uploading plus you can search the forum for it and probably find 1000 topics 2. i'd have to see your query code and how you print your results to recommend a method for linking. 3. ok, this would be a drop down form. Quote Link to comment Share on other sites More sharing options...
Ramones Posted July 23, 2007 Author Share Posted July 23, 2007 mysql_select_db("wiring", $con); $result = mysql_query("SELECT * FROM diagrams"); echo "<table border='1'> <tr> <th>Title</th> <th>Quick Description</th> <th>Difficulty</th> </tr>"; while($row = mysql_fetch_array($result)) { echo "<tr>"; echo "<td>" . $row['Title'] . "</td>"; echo "<td>" . $row['Quick'] . "</td>"; echo "<td>" . $row['Difficulty'] . "</td>"; echo "</tr>"; } echo "</table>"; mysql_close($con); ?> thats what you want right? Quote Link to comment Share on other sites More sharing options...
simcoweb Posted July 23, 2007 Share Posted July 23, 2007 echo "<td><a href='nameofpagethatdisplaysdetails.php'>" . $row['Title'] . "</a></td>"; Quote Link to comment Share on other sites More sharing options...
dg Posted July 23, 2007 Share Posted July 23, 2007 wht is the error ?? .... also where is database connection defined? Quote Link to comment Share on other sites More sharing options...
Ramones Posted July 23, 2007 Author Share Posted July 23, 2007 is there any way to create a page when i make the record wht is the error ?? .... also where is database connection defined? there is no error if you refer to the first post i ask two questions i left that out on purpose Quote Link to comment Share on other sites More sharing options...
simcoweb Posted July 23, 2007 Share Posted July 23, 2007 echo "<td><a href='nameofpagethatdisplaysdetails.php'>" . $row['Title'] . "[/a]</td>"; My previous post got skewed by the message board. This is how you'd display the url you wanted in question #2. You have to create the page you want it to link to. Normally that would be something with a query that has that particular entry broken down in a table so they can view the details of it. So, write a page that connects to the database, runs the query then echo's the output pretty much like the one you already have. Quote Link to comment Share on other sites More sharing options...
Ramones Posted July 23, 2007 Author Share Posted July 23, 2007 echo "<td><a href='nameofpagethatdisplaysdetails.php'>" . $row['Title'] . "[/a]</td>"; My previous post got skewed by the message board. This is how you'd display the url you wanted in question #2. You have to create the page you want it to link to. Normally that would be something with a query that has that particular entry broken down in a table so they can view the details of it. So, write a page that connects to the database, runs the query then echo's the output pretty much like the one you already have. The question was phrased wrong I would also like the query when I create the record to create an html file which has all the information in it or something like that Quote Link to comment Share on other sites More sharing options...
Ramones Posted July 23, 2007 Author Share Posted July 23, 2007 Sorry for the double post but i have a new question Ok I am still looking for an answer on the second question if you read through my posts the question is slightly different than posed in the first post now I made a form where the user enters a number stored in MySql row Num which is auto incrementing and the primary key it then goes to a form in which they can edit the information in the record which corresponds the the number they entered I'm having a problem populating the form with the information from the MySql database Edit.php has this(unneeded things cut out) <form action="Edit2.php" method="post"> <input type="text" name="Num" /> <br> <input name="submit" type="submit" /> </form> Edit2.php has this(unneeded things cut out $result = mysql_query("SELECT '$_POST[Num]' FROM things"); $row = mysql_fetch_array($result) MORE CODE UNNEEDED <form action="Edit3.php" method="post"> <p><strong>Title:</strong> <br> <input type="text" name="Title" value=<? $row['Title'] ?>> <br> <strong>Quick Description:</strong> <br> <input type="text" name="Quick" /> </p> <strong>Instructions:</strong><br> <TEXTAREA NAME="Instruction" COLS=40 ROWS=6></TEXTAREA> <br> <strong>Difficulty(1-5 5 being hardest):</strong> <br> <input type="text" name="Difficulty" /> <br> <strong>Parts:</strong><br> <TEXTAREA NAME="Parts" COLS=10 ROWS=10></TEXTAREA> <br> <input name="submit" type="submit" /> </p> </form> right now i would expect that to print the title of the given number but it isn't Quote Link to comment Share on other sites More sharing options...
simcoweb Posted July 23, 2007 Share Posted July 23, 2007 Your logic is ok but the code is wrong. If you want to pull up the details of a specific id then pass the id through the edit.php form like this: <form action="Edit.php?id='$_POST['Num']'" method="POST"> Then on the Edit2.php you'd do this: <?php $id = $_GET['id']; $results = mysql_query("SELECT * FROM things WHERE id='$id'"); Then, according to your form code, looks like you want to display what they entered into the respective form fields. Not sure why but here's what you could do. Normally you'd display the query results in a table format. You would display the entries in the form fields IF, for example, they made a mistake or didn't complete a required field and you populated their entries for them so they didn't have to fill them all in again before resubmitting. value"<?php if (isset($_POST['Title'])) echo $_POST['Title']; ?>" This way it would only echo the value IF the form had been submitted. Quote Link to comment Share on other sites More sharing options...
Ramones Posted July 23, 2007 Author Share Posted July 23, 2007 ok so my only question left is there a way when the user submits the form a record is created it also creates an html file Quote Link to comment Share on other sites More sharing options...
per1os Posted July 23, 2007 Share Posted July 23, 2007 ok so my only question left is there a way when the user submits the form a record is created it also creates an html file www.php.net/fopen www.php.net/fwrite www.php.net/fclose Quote Link to comment Share on other sites More sharing options...
simcoweb Posted July 23, 2007 Share Posted July 23, 2007 To add to frost's post, you still have to write all the code that is displayed in the html page file so when it's created it knows what to show. 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.