Jump to content

list all records in database starting with the letter 'A'


MDanz

Recommended Posts

i tried this and its not working... blank page

 

<?php

mysql_connect("localhost", "Master", "password");
mysql_select_db("Login");

$letter = htmlentities($_GET['search']); 
$user = mysql_query("SELECT * FROM Users WHERE username LIKE '$letter%' ORDER BY username")or die (mysql_error());  

while($rowz = mysql_fetch_array($user)){
$username = $rowz['username'];
echo "<font face='Courier New' font size=2px font color=#FBB917>$username</font>";
}
?>

Not really sure what is wrong, worked fine using my database information:

 

<?php

mysql_connect("localhost", "Master", "password") or trigger_error("Connection Failed: " . mysql_error());
mysql_select_db("Login") or trigger_error("Database Selection failed: " . mysql_error());

$letter = isset($_GET['search']) ? htmlentities($_GET['search']) : ''; 
$user = mysql_query("SELECT * FROM Users WHERE username LIKE '{$letter}%' ORDER BY username")or trigger_error ("SQL Failed: " . mysql_error());  

while($rowz = mysql_fetch_assoc($user)){
    $username = $rowz['username'];
    echo "<font face='Courier New' font size=2px font color=#FBB917>$username</font>";
}
?>

 

Try that and see if it does any better, not sure if it will because the original way seemed fine on my server, so it could be a server issue.

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.