Jump to content

How to modify this code???


scepanmali

Recommended Posts

I just need to display the result from one selected table with id number, but it should work with all 5. Example: I have 5 separate tables. And, if I click on id in the first table, I want to display result from that table only! If I click on id in the 3th table, I want to display the result related just for that table! And I want to do that just with this code! I noticed that always display the first result correctly, but then it continues to echo the results from all 5 tables! So, I tried to limit the result with LIMIT 1 function, but it doesn't work. Like this:

 

$sql = mysql_query("SELECT * FROM ".$table." WHERE ID = '$id' LIMIT 1");

 

Here is my code for the first page:

 

$sql = mysql_query("SELECT * FROM oblast_metal ORDER BY id DESC LIMIT $from, $max_results");

$id= $row['id'];

$row['id']=$id;

$row['Artist']=$Artist;

$row['Song']=$Song;

while ($row = mysql_fetch_array($sql)) { ?>

 

<table border="0" bordercolor=#A49F8B align = "center"

cellspacing="0" cellpadding= 3 width= 500 >

<tr onMouseOver="this.bgColor='#355466';" onMouseOut="this.bgColor='#2c4453';">

<td width= "170" ><font color="white" font size=3><font face="Arial, Helvetica, sans-serif"><? echo

$row['Artist']; ?></font></td>

<td width= "200"><font color="white"><font face="Arial, Helvetica, sans-serif"><? echo

$row['Song']; ?></font></td>

<td width= "50"><font face="Arial, Helvetica, sans-serif"><a href="<?php echo "download.php?id=".$row['id'].">".$row['Artist']."- ". $row['Song'] . "";?>" target="_blank" style="text-decoration:none"><b><font color=#A49F8B>Download</b></a></a></font></td>

</tr>

 

<?php

 

echo "</table>";

}

echo "</br></br></br></br>";

 

echo "</center>";

echo "<center><font color=#C8C9CA><font size = 4>Select a Page<br />";

 

And here is from the second page:

 

<?php

 

$dbhandle = mysql_connect($hostname, $username, $password) or die("Unable to connect to MySQL");

echo "<br>";

$selected = mysql_select_db("spotovi1", $dbhandle) or die("Could not select DB");

 

$row['Artist']=$Artist;

$row['Song']=$Song;

$id= $row['id'];

$id = $_GET['id'];

$Artist = $_GET['Artist'];

$Song = $_GET['Song'];

 

$tables = array("oblast_metal","oblast_rock","oblast_pop","oblast_hip_hop","oblast_domaca");

 

foreach($tables as $table)

{

 

$sql = mysql_query("SELECT * FROM ".$table." WHERE ID = '$id'");

while ($row = mysql_fetch_array($sql)) { ?>

<?php

$zajedno=$row['Artist']."- ".$row['Song'];

echo "<font size=3><font color=white><b>Download </b></a> </font></font>";

echo "<font size=4><font color='#A49F8B'><a href=\"{$row['Link']}\"><font color='#A49F8B'>$zajedno</font></font></a>";

echo "<font size=3><font color=white><b> Music Video</b> </a> </font></font>";

}

}

php?>

 

So, again, how to display only the first result

Link to comment
https://forums.phpfreaks.com/topic/97728-how-to-modify-this-code/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.