Jump to content

Three Questions


Ramones

Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Link to comment
Share on other sites

  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.

Link to comment
Share on other sites

  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

Link to comment
Share on other sites

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

Link to comment
Share on other sites

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.

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.