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: lasha.wm@gmail.com <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>

Link to comment
Share on other sites

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?

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.