lasha Posted September 20, 2012 Share Posted September 20, 2012 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> Quote Link to comment Share on other sites More sharing options...
Jessica Posted September 20, 2012 Share Posted September 20, 2012 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? Quote Link to comment Share on other sites More sharing options...
lasha Posted September 20, 2012 Author Share Posted September 20, 2012 aahaaa There is $myrow = mysql_fetch_array($result); twice yeah? Thank you jesirose, it was problem and now everything works perfect!! thanks thanks )))))))) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.