Jump to content

$_GET and Mysql Problem. Please Help!


paulman888888

Recommended Posts

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
Share on other sites

$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
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.