thunderousity Posted July 30, 2013 Share Posted July 30, 2013 (edited) I usually use the following syntax for my php pages mysql_select_db($database_school, $school);$query_Recordset1 = "SELECT * FROM tblSchool";$Recordset1 = mysql_query($query_Recordset1, $school) or die(mysql_error());$row_Recordset1 = mysql_fetch_assoc($Recordset1);$totalRows_Recordset1 = mysql_num_rows($Recordset1); and use something like this to echo the results echo "<table border='1'>< tr>< th>Firstname</th>< th>Lastname</th>< /tr>";while($row = mysql_fetch_assoc($Recordset1)) { echo "<tr>"; echo "<td>" . $row['FirstName'] . "</td>"; echo "<td>" . $row['LastName'] . "</td>"; echo "</tr>"; }echo "</table>"; Scenario: I usually do 2 separate PHP/MYSQL statements as above with 2 separate results but that doesn't seem very efficient. In a bid to be more efficient what if I have 1 query which returns 2 rows but I want to echo the first row of results on one side of the web page and the second somewhere completely different on the page. I can't really use a 'while' statement as it's not really a list. I'm guessing I'd have to put it in an array where I can specify which row I want to echo? Edited July 30, 2013 by thunderousity Link to comment Share on other sites More sharing options...
justsomeguy Posted July 30, 2013 Share Posted July 30, 2013 You can use mysql_result to get individual cells from an arbitrary row in a result, or you can just get the 2 rows individually and save them for later. http://www.php.net/manual/en/function.mysql-result.php Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now