paulman888888 Posted July 10, 2008 Share Posted July 10, 2008 Hi. I have my code and its for a table. But i would like little script that stores the name in $name and sex in $sex and musictype in $musictype. I know i dont need the WHILE function because theres only one result. Because i use the WHERE function in Mysql. eg $result = mysql_query("SELECT * FROM unit4_art WHERE id=$id"); Below is my table code which is way to much for what i need <?php $result = mysql_query("SELECT * FROM unit4_art ORDER BY id ASC"); $i = 0; // setup a counter echo '<table border="1" width="100%">'; echo "<tr bgcolor='#FFFFFF'><th>ID</th><th>Name</th><th>Sex</th><th>Music Type</th><th>View</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><center><a href="?where=infoart&id='.$row['id'].'">'.$row['id']."</a></center></td>\n"; echo "<td><center>".$row['name']."</center></td>"; echo "<td><center>".$row['sex']."</center></td>"; echo "<td><center>".$row['music']."</center></td>"; echo '<td><center><a href="?where=viewart&id='.$row['id'].'"><img src="images/buttons/go.png" /></a></center></td>'; echo "</tr>"; $i++; // increment counter } echo "</table>"; ?> Thankyou Paul Link to comment https://forums.phpfreaks.com/topic/114082-_get-and-mysql-problem-please-help/ Share on other sites More sharing options...
gigas10 Posted July 10, 2008 Share Posted July 10, 2008 $name = $row['Column_Name_Which_Stores_The_Users_Name']; $sex = $row['Column_Name_Which_Stores_The_Users_Sex']; $musictype = $row['Column_Name_Which_Stores_The_Users_Musictype']; echo $name; or echo "<tr><td>Name</td></tr><tr><td>" . $name . "</td></tr>"; Link to comment https://forums.phpfreaks.com/topic/114082-_get-and-mysql-problem-please-help/#findComment-586457 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.