id, name, url
данные там такие
1, Август, 0
2, Брайан, 0
3, Бекхем, 0
4, Вивальди, 0
5, Викентий, 0
6, Григорий, 0
7, Дмитрий, 0
и так далее по алфавиту,
нужно чтобы php выводил что то типа
А Б
август Брайан
Бекхем
и т.д.
так вот не могу это сделать помогите а ?
<? include "../o-proekte/connect.php";?>
<ul id="nav">
<li><a class=" link" href="citaty-i-aforizmy/">А</a>
<ul>
<?$a = iconv('utf8', 'cp1251', "А");
$sql = 'SELECT * FROM authors WHERE name LIKE "'.$a.'%"';
$query = mysql_query($sql) or die("Invalid query: " . mysql_error());
While ($row = mysql_fetch_array ($query))
{$results[] = $row;};?>
<? foreach ($results as $num=> $result ) {
echo iconv("cp1251", "utf8", "<li><a href=".$result['id']." id=".$result['name'].">".$result['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Б</a>
<ul>
<?$b = iconv('utf8', 'cp1251', "Б");
$sqlb = 'SELECT * FROM authors WHERE name LIKE "'.$b.'%"';
$queryb = mysql_query($sqlb) or die("Invalid query: " . mysql_error());
While ($rowb = mysql_fetch_array ($queryb))
{$resultsb[] = $rowb;};?>
<? foreach ($resultsb as $numb=> $resultb ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultb['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">В</a>
<ul>
<?$v = iconv('utf8', 'cp1251', "В");
$sqlv = 'SELECT * FROM authors WHERE name LIKE "'.$v.'%"';
$queryv = mysql_query($sqlv) or die("Invalid query: " . mysql_error());
While ($rowv = mysql_fetch_array ($queryv))
{$resultsv[] = $rowv;};?>
<? foreach ($resultsv as $numv=> $resultv ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultv['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Г</a>
<ul>
<?$g = iconv('utf8', 'cp1251', "Г");
$sqlg = 'SELECT * FROM authors WHERE name LIKE "'.$g.'%"';
$queryg = mysql_query($sqlg) or die("Invalid query: " . mysql_error());
While ($rowg = mysql_fetch_array ($queryg))
{$resultsg[] = $rowg;};?>
<? foreach ($resultsg as $numg=> $resultg ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultg['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Д</a>
<ul>
<?$d = iconv('utf8', 'cp1251', "Д");
$sqld = 'SELECT * FROM authors WHERE name LIKE "'.$d.'%"';
$queryd = mysql_query($sqld) or die("Invalid query: " . mysql_error());
While ($rowd = mysql_fetch_array ($queryd))
{$resultsd[] = $rowd;};?>
<? foreach ($resultsd as $numd=> $resultd ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultd['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Е</a>
<ul>
<?$e = iconv('utf8', 'cp1251', "Е");
$sqle = 'SELECT * FROM authors WHERE name LIKE "'.$e.'%"';
$querye = mysql_query($sqle) or die("Invalid query: " . mysql_error());
While ($rowe = mysql_fetch_array ($querye))
{$resultse[] = $rowe;};?>
<? foreach ($resultse as $nume=> $resulte ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resulte['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Ж</a>
<ul>
<?$j = iconv('utf8', 'cp1251', "Ж");
$sqlj = 'SELECT * FROM authors WHERE name LIKE "'.$j.'%"';
$queryj = mysql_query($sqlj) or die("Invalid query: " . mysql_error());
While ($rowj = mysql_fetch_array ($queryj))
{$resultsj[] = $rowj;};?>
<? foreach ($resultsj as $numj=> $resultj ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultj['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">З</a>
<ul>
<?$z = iconv('utf8', 'cp1251', "З");
$sqlz = 'SELECT * FROM authors WHERE name LIKE "'.$z.'%"';
$queryz = mysql_query($sqlz) or die("Invalid query: " . mysql_error());
While ($rowz = mysql_fetch_array ($queryz))
{$resultsz[] = $rowz;};?>
<? foreach ($resultsz as $numz=> $resultz ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultz['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">И</a>
<ul>
<?$i = iconv('utf8', 'cp1251', "И");
$sqli = 'SELECT * FROM authors WHERE name LIKE "'.$i.'%"';
$queryi = mysql_query($sqli) or die("Invalid query: " . mysql_error());
While ($rowi = mysql_fetch_array ($queryi))
{$resultsi[] = $rowi;};?>
<? foreach ($resultsi as $numi=> $resulti ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resulti['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">К</a>
<ul>
<?$k = iconv('utf8', 'cp1251', "К");
$sqlk = 'SELECT * FROM authors WHERE name LIKE "'.$k.'%"';
$queryk = mysql_query($sqlk) or die("Invalid query: " . mysql_error());
While ($rowk = mysql_fetch_array ($queryk))
{$resultsk[] = $rowk;};?>
<? foreach ($resultsk as $numk=> $resultk ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultk['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Л</a>
<ul>
<?$l = iconv('utf8', 'cp1251', "Л");
$sqll = 'SELECT * FROM authors WHERE name LIKE "'.$l.'%"';
$queryl = mysql_query($sqll) or die("Invalid query: " . mysql_error());
While ($rowl = mysql_fetch_array ($queryl))
{$resultsl[] = $rowl;};?>
<? foreach ($resultsl as $numl=> $resultl ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultl['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">М</a>
<ul>
<?$m = iconv('utf8', 'cp1251', "М");
$sqlm = 'SELECT * FROM authors WHERE name LIKE "'.$m.'%"';
$querym = mysql_query($sqlm) or die("Invalid query: " . mysql_error());
While ($rowm = mysql_fetch_array ($querym))
{$resultsm[] = $rowm;};?>
<? foreach ($resultsm as $numm=> $resultm ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultm['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Н</a>
<ul>
<?$n = iconv('utf8', 'cp1251', "Н");
$sqln = 'SELECT * FROM authors WHERE name LIKE "'.$n.'%"';
$queryn = mysql_query($sqln) or die("Invalid query: " . mysql_error());
While ($rown = mysql_fetch_array ($queryn))
{$resultsn[] = $rown;};?>
<? foreach ($resultsn as $numn=> $resultn ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultn['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">О</a>
<ul>
<?$o = iconv('utf8', 'cp1251', "О");
$sqlo = 'SELECT * FROM authors WHERE name LIKE "'.$o.'%"';
$queryo = mysql_query($sqlo) or die("Invalid query: " . mysql_error());
While ($rowo = mysql_fetch_array ($queryo))
{$resultso[] = $rowo;};?>
<? foreach ($resultso as $numo=> $resulto ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resulto['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">П</a>
<ul>
<?$p = iconv('utf8', 'cp1251', "П");
$sqlp = 'SELECT * FROM authors WHERE name LIKE "'.$p.'%"';
$queryp = mysql_query($sqlp) or die("Invalid query: " . mysql_error());
While ($rowp = mysql_fetch_array ($queryp))
{$resultsp[] = $rowp;};?>
<? foreach ($resultsp as $nump=> $resultp ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultp['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Р</a>
<ul>
<?$r = iconv('utf8', 'cp1251', "Р");
$sqlr = 'SELECT * FROM authors WHERE name LIKE "'.$r.'%"';
$queryr = mysql_query($sqlr) or die("Invalid query: " . mysql_error());
While ($rowr = mysql_fetch_array ($queryr))
{$resultsr[] = $rowr;};?>
<? foreach ($resultsr as $numr=> $resultr ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultr['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">С</a>
<ul>
<?$s = iconv('utf8', 'cp1251', "С");
$sqls = 'SELECT * FROM authors WHERE name LIKE "'.$s.'%"';
$querys = mysql_query($sqls) or die("Invalid query: " . mysql_error());
While ($rows = mysql_fetch_array ($querys))
{$resultss[] = $rows;};?>
<? foreach ($resultss as $nums=> $results ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$results['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Т</a>
<ul>
<?$t = iconv('utf8', 'cp1251', "Т");
$sqlt = 'SELECT * FROM authors WHERE name LIKE "'.$t.'%"';
$queryt = mysql_query($sqlt) or die("Invalid query: " . mysql_error());
While ($rowt = mysql_fetch_array ($queryt))
{$resultst[] = $rowt;};?>
<? foreach ($resultst as $numt=> $resultt ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultt['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">У</a>
<ul>
<?$u = iconv('utf8', 'cp1251', "У");
$sqlu = 'SELECT * FROM authors WHERE name LIKE "'.$u.'%"';
$queryu = mysql_query($sqlu) or die("Invalid query: " . mysql_error());
While ($rowu = mysql_fetch_array ($queryu))
{$resultsu[] = $rowu;};?>
<? foreach ($resultsu as $numu=> $resultu ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultu['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Ф</a>
<ul>
<?$f = iconv('utf8', 'cp1251', "Ф");
$sqlf = 'SELECT * FROM authors WHERE name LIKE "'.$f.'%"';
$queryf = mysql_query($sqlf) or die("Invalid query: " . mysql_error());
While ($rowf = mysql_fetch_array ($queryf))
{$resultsf[] = $rowf;};?>
<? foreach ($resultsf as $numf=> $resultf ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultf['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Х</a>
<ul>
<?$h = iconv('utf8', 'cp1251', "Х");
$sqlh = 'SELECT * FROM authors WHERE name LIKE "'.$h.'%"';
$queryh = mysql_query($sqlh) or die("Invalid query: " . mysql_error());
While ($rowh = mysql_fetch_array ($queryh))
{$resultsh[] = $rowh;};?>
<? foreach ($resultsh as $numh=> $resulth ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resulth['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Ц</a>
<ul>
<?$c = iconv('utf8', 'cp1251', "Ц");
$sqlc = 'SELECT * FROM authors WHERE name LIKE "'.$c.'%"';
$queryc = mysql_query($sqlc) or die("Invalid query: " . mysql_error());
While ($rowc = mysql_fetch_array ($queryc))
{$resultsc[] = $rowc;};?>
<? foreach ($resultsc as $numc=> $resultc ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultc['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Ч</a>
<ul>
<?$ch = iconv('utf8', 'cp1251', "Ч");
$sqlch = 'SELECT * FROM authors WHERE name LIKE "'.$ch.'%"';
$querych = mysql_query($sqlch) or die("Invalid query: " . mysql_error());
While ($rowch = mysql_fetch_array ($querych))
{$resultsch[] = $rowch;};?>
<? foreach ($resultsch as $numch=> $resultch ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultch['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Ш</a>
<ul>
<?$sh = iconv('utf8', 'cp1251', "Ш");
$sqlsh = 'SELECT * FROM authors WHERE name LIKE "'.$sh.'%"';
$querysh = mysql_query($sqlsh) or die("Invalid query: " . mysql_error());
While ($rowsh = mysql_fetch_array ($querysh))
{$resultssh[] = $rowsh;};?>
<? foreach ($resultssh as $numsh=> $resultsh ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultsh['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Щ</a>
<ul>
<?$jh = iconv('utf8', 'cp1251', "Щ");
$sqljh = 'SELECT * FROM authors WHERE name LIKE "'.$jh.'%"';
$queryjh = mysql_query($sqljh) or die("Invalid query: " . mysql_error());
While ($rowjh = mysql_fetch_array ($queryjh))
{$resultsjh[] = $rowjh;};
if ($resultsjh == "") {
echo "<li></li>";
}else {
?>
<? foreach ($resultsjh as $numjh=> $resultjh ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultjh['name']."</a></li>");
}}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Э</a>
<ul>
<?$ie = iconv('utf8', 'cp1251', "Э");
$sqlie = 'SELECT * FROM authors WHERE name LIKE "'.$ie.'%"';
$queryie = mysql_query($sqlie) or die("Invalid query: " . mysql_error());
While ($rowie = mysql_fetch_array ($queryie))
{$resultsie[] = $rowie;};?>
<? foreach ($resultsie as $numie=> $resultie ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultie['name']."</a></li>");
}?>
</ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Ю</a>
<ul>
<?$yu = iconv('utf8', 'cp1251', "Ю");
$sqlyu = 'SELECT * FROM authors WHERE name LIKE "'.$yu.'%"';
$queryyu = mysql_query($sqlyu) or die("Invalid query: " . mysql_error());
While ($rowyu = mysql_fetch_array ($queryyu))
{$resultsyu[] = $rowyu;};?>
<? foreach ($resultsyu as $numyu=> $resultyu ) {
echo iconv("cp1251", "utf8", "<li><a href=\"\">".$resultyu['name']."</a></li>");
}?></ul>
</li>
<li><a class=" link" href="citaty-i-aforizmy/">Я</a>
<ul>
<?$ya = iconv('utf8', 'cp1251', "Я");
$sqlya = 'SELECT * FROM authors WHERE name LIKE "'.$ya.'%"';
$queryya = mysql_query($sqlya) or die("Invalid query: " . mysql_error());
While ($rowya = mysql_fetch_array ($queryya))
{$resultsya[] = $rowya;};?>
<? foreach ($resultsya as $numya=> $resultya ) {?>
<script>
$(document).ready(function() {
$(".op_<?=$resultya['id'];?>").click(function () {
// $.post("../modules/info.php", { id: "<?=$resultya['id'];?>" } );
$("#open").show("slow");
$("#open").css('display', 'block');
return true;
});
});
</script>
<? echo iconv("cp1251", "utf8", "<li><a href=\"#\" class='op_".$resultya['id']."' >".$resultya['name']."</a></li>");
//$allname = iconv("cp1251", "utf8", $resultya['name']);
?>
<?}?>
</ul>
</li>
</ul>
</td>
</tr>
</tbody>
</table>
Ну на каждую букву соотв.
Я конечно сам прекрасно понимаю что это говнокод, но Только не глумитесь код писал не я, но надо переделать, а я не шибко понимаю в программировании
Спустя 9 минут, 7 секунд (27.11.2011 - 07:41) hookman написал(а):
Пиздец, простите.
Спустя 56 секунд (27.11.2011 - 07:42) Jekax написал(а):
аха
Спустя 56 минут, 12 секунд (27.11.2011 - 08:38) bulgakov написал(а):
Как же меня радуют темы - код писал не я, но надо переделать так как я не шибко понимаю в программировании. А мы вот не шибко понимаем в финансах, помогите с финансами а?
Спустя 2 часа, 41 минута, 50 секунд (27.11.2011 - 11:20) Invis1ble написал(а):
OMG
ПС. хотел на говнокод.ру запостить, но опередили
ПС. хотел на говнокод.ру запостить, но опередили
Спустя 3 минуты, 45 секунд (27.11.2011 - 11:24) Семён написал(а):
Я думаю здесь всё можно сократить до 1 запроса с FULLTEXT по name, во всяком случае будет быстрее чем через SUBSTRING