paulman888888 Posted June 9, 2008 Share Posted June 9, 2008 How can i get my php code to echo out all the information on the same row as id? Eg info.php?id=13 i would like it to echo out all information on row 13. Thankyou Quote Link to comment https://forums.phpfreaks.com/topic/109433-solved-quick-question/ Share on other sites More sharing options...
Clinton Posted June 9, 2008 Share Posted June 9, 2008 $id = $_GET['id']; echo $id; Quote Link to comment https://forums.phpfreaks.com/topic/109433-solved-quick-question/#findComment-561302 Share on other sites More sharing options...
paulman888888 Posted June 9, 2008 Author Share Posted June 9, 2008 so something like $id = $_GET['id']; $result = mysql_query("SELECT * FROM downloads ROW $id WHERE id ASC"); Is that right? Quote Link to comment https://forums.phpfreaks.com/topic/109433-solved-quick-question/#findComment-561303 Share on other sites More sharing options...
Clinton Posted June 9, 2008 Share Posted June 9, 2008 $id = $_GET['id']; $result = mysql_query("SELECT * FROM downloads ROW $id WHERE id = ASC"); Missing the equal sign if you want it to look exactly for that. Quote Link to comment https://forums.phpfreaks.com/topic/109433-solved-quick-question/#findComment-561308 Share on other sites More sharing options...
Clinton Posted June 9, 2008 Share Posted June 9, 2008 YOu're going to want to put '' around ASC as well. So 'ASC'. Quote Link to comment https://forums.phpfreaks.com/topic/109433-solved-quick-question/#findComment-561312 Share on other sites More sharing options...
wildteen88 Posted June 9, 2008 Share Posted June 9, 2008 No that query is wrong. You should use if(isset($_GET['id']) && is_numeric($_GET['id'])) { $id = $_GET['id']; $result = mysql_query("SELECT * FROM downloads WHERE id = '$id'"); if(mysql_num_rows($result) > 0) { $row = mysql_fetch_assoc($result); echo '<pre>' . print_r($row, true) . '</pre>'; } else { echo $id . ' does not exist!'; } } Quote Link to comment https://forums.phpfreaks.com/topic/109433-solved-quick-question/#findComment-561318 Share on other sites More sharing options...
paulman888888 Posted June 9, 2008 Author Share Posted June 9, 2008 ? Pardon I just want to echo out that row from my mysql database I get this error when i try running it. Warning: mysql_fetch_array(): supplied argument is not a valid MySQL result resource in /home/www/somesite.com/info.php on line 17 and line 17 is this while($row = mysql_fetch_array( $result )) and the whole php code is this <?php $id = $_GET['id']; $result = mysql_query("SELECT * FROM friends ROW $id WHERE id = ASC"); echo '<table border="1" width="550">'; echo "<tr bgcolor='#FFFFFF'><th>ID</th><th>Name</th><th>Location</th><th>GO</th><th>Comments</th></tr>"; while($row = mysql_fetch_array( $result )) { // alternate class $class = ($i%2 == 0) ? '#00FF00' : '#00FF00'; $class2 = ($i%2 == 0) ? '#CCCCCC' : '#999999'; // Print out the contents of each row into a table echo "<tr bgcolor='".$class2."' onmouseover=\"this.style.backgroundColor = '".$class."';\" onmouseout=\"this.style.backgroundColor = '".$class2."';\">"; echo '<td><a href="info.php?id='.$row['id'].'">'.$row['id']."</a></td>\n"; echo "<td>".$row['name']."</td>"; echo "<td>".$row['location']."</td>"; echo '<td><center><a href="'.$row['location'].'"><img src="Images/downloadsm.png" /></a></center></td>'; echo "<td>".$row['Comments']."</td>"; echo "</tr>"; $i++; // increment counter } echo "</table>"; ?> Thankyou for all the help Quote Link to comment https://forums.phpfreaks.com/topic/109433-solved-quick-question/#findComment-561321 Share on other sites More sharing options...
paulman888888 Posted June 9, 2008 Author Share Posted June 9, 2008 Thankyou. It works. Forget my other post i didnt see you post come up till i posted mine. Thankyou. Again wildteen88 Quote Link to comment https://forums.phpfreaks.com/topic/109433-solved-quick-question/#findComment-561327 Share on other sites More sharing options...
trq Posted June 9, 2008 Share Posted June 9, 2008 Look at the query wildteen posted, then look at yours. Quote Link to comment https://forums.phpfreaks.com/topic/109433-solved-quick-question/#findComment-561329 Share on other sites More sharing options...
Clinton Posted June 9, 2008 Share Posted June 9, 2008 Sorry, I tried. I'm no pro like these guys. Quote Link to comment https://forums.phpfreaks.com/topic/109433-solved-quick-question/#findComment-561348 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.