Jump to content

A-Z selector does not select veri first record from database


lasha

Recommended Posts

hello :)

I have problem and i think my topic title explains everything ("A-Z selector does not select veri first record from database")

I can't understend why, please help :)

Thanks

 

<table width="100%" border="0" >
<tr>
<td valign="top">
<ul id="items">

<?php
$this_link = htmlentities( $_SERVER['PHP_SELF'] );

$letters = range('A', 'Z');

$menu = '<ul id="az">'."\n";
foreach ( $letters as $letter ) {
    $menu .= '<li><a href="'. $this_link .'?var='. $letter .'">'. $letter .'</a></li>'."\n";
}
$menu .= '</ul>'."\n";

if ( isset( $_GET['var'] ) AND in_array( $_GET['var'], $letters ) ){



$result = mysql_query("SELECT * FROM data WHERE band_name LIKE '". $_GET['var'] ."%' ",$db);
$myrow = mysql_fetch_array($result);

if (!$result)
{
echo "<p>The operation unsuccessful ... Please contact the administrator by e-mail: [email protected] <br> <strong>Error:</strong></p>";
exit(mysql_error());
}
if(mysql_num_rows($result) > 0)
{
$myrow = mysql_fetch_array($result);
do
{
printf ("	
<li>
<table style='float:left; margin:0px;'>
<tr>
	<td valign='top' id='header23' style='color:#888888; font-family:arial;'>
		<div>
			<span class='vidtitle'><span style='color:#fff; font-size:12px;'><strong>%s</strong></span></span>
			<br><a href='%s' target='_blank'>Sound Cloud</a> <br> <a href='%s' target='_blank'>%s</a>
		</div>
			<br>
	</td>
</tr>
</table>
</li>
",$myrow["band_name"],$myrow["sound_cloud"],$myrow["social_link"],$myrow["place_in_social"]);
}
while ($myrow = mysql_fetch_array($result));	
}
else
{
echo "<p>Information not found...</p>";

}
}
else {
echo '<p>Please select a letter</p>';
}

?>
</ul>
<div style="position:absolute; top:1px; left:111px;"><?php echo $menu; ?></div>
</td>
</tr>
</table>

very.

 

 

$result = mysql_query("SELECT * FROM data WHERE band_name LIKE '". $_GET['var'] ."%' ",$db);
$myrow = mysql_fetch_array($result);

if (!$result){...}
if(mysql_num_rows($result) > 0){
$myrow = mysql_fetch_array($result);
do.....

 

This is the section in which the problem exists. I've cut out some code to make it shorter. Do you see the problem now?

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.