I've been at this for a few months and just recently found a good grasp on the include() and require() functions, CSS layout, and the like. However, in trying to display a single row from a table I have become somewhat catatonic. I'm hoping that someone might be so kind as to give me a clue towards accomplishing this - as follows:
I have a 'search' page with a simple form - enter a number and post to another page called 'results'. The number that is entered on 'search' is unique and has nine other fields in the row. What I would like to see is 1 row with all fields included, but for the life of me, I see nothing. The db connect statements don't return any errors and I'm quite positive that it's not the issue.
Anyone have a quick sample of how I would retrieve the query results in the 'results' page - I've tried so many different things, I don't even remember what I've done. I apologize if this is too vague - 6 hours at the puter has made me somewhat "mushy" in the head.
Even the slightest hint may be most helpful.
Undying thanks and appreciation!!
A hint desparately needed...
Moderator: General Moderators
If I understood correctly; You need to rewrite my example, but basicly...
Select everything from table, starting at line $search. The last 1 means 'one row' from $start.
Code: Select all
SELECT * FROM table LIMIT $search,1It's usually better not to just post a script - better to help someone work it out for themselves. But since it sounds like you've spent a lot of time on this already here's a sample:
Code: Select all
<?php
// defines a string - the db query
// replace col1 etc with your own column and table names
$mysql = "SELECT col1, col2, col3 FROM table WHERE id='$id'";
// creates a result resource - a mysterious entity a bit like an array only it's not
// also some commonly used error handling (the or step)
$query = mysql_query(mysql) or die('oh bugger' . mysql_error() . '<br />');
// now this IS an array - fetches a row from the result resource (just one here) as an array with numerical and associative keys (try a print_r() on it)
$result = mysql_fetch_array($query);
// assign the keys
$var1 = $result['var1'];
$var2 = $result['var2'];
$var3 = $result['var3'];
// etc..
?>
Last edited by McGruff on Wed Aug 10, 2005 7:22 pm, edited 1 time in total.