Jump to content

help with code - A-Z listing


Ameslee

Recommended Posts

ok i am having trouble with the following code

[code]
<a href="?search=A"><font size="2"><strong>A</strong></font></a><strong><font size="2">
                            | <a href="?search=B">B</a> | <a href="?search=C">C</a>
                            | <a href="?search=D">D</a> | <a href="?search=E">E</a>
                            | <a href="?search=F">F</a> | <a href="?search=G">G</a>
                            | <a href="?search=H">H</a> | <a href="?search=I">I</a>
                            | <a href="?search=J">J</a> | <a href="?search=K">K</a>
                            | <a href="?search=L">L</a> | <a href="?search=M">M</a>
                            | <a href="?search=N">N</a> | <a href="?search=O">O</a>
                            | <a href="?search=P">P</a> | <a href="?search=Q">Q</a>
                            | <a href="?search=R">R</a> | <a href="?search=S">S</a>
                            | <a href="?search=T">T</a> | <a href="?search=U">U</a>
                            | <a href="?search=V">V</a> | <a href="?search=W">W</a>
                            | <a href="?search=X">X</a> | <a href="?search=Y">Y</a>
                            | <a href="?search=Z">Z</a></font></strong></p>
                          <p align="left">&nbsp;</p>
                        </div>
<?php
$hostname = localhost;
$username = ;
$password = ;


$conn = mysql_connect($hostname, $username, $password) or die(mysql_error());
$connection = mysql_select_db("greenac_VORNExpo", $conn);

$query = "SELECT * FROM exhibits WHERE exhibit LIKE '".$_GET['search']."%'";
while ($row = mysql_fetch_object($result)) {
echo $row->data."<BR />";}
?>[/code]

The following error happens - Warning: mysql_fetch_object(): supplied argument is not a valid MySQL result resource in /home/greenac/public_html/search.php on line 216

Can someone plz help?
Link to comment
Share on other sites

i'm just looking over your code. you probably took out your username and password for your mysql on purpose. but place localhost in talking marks. "localhost".

[code=php:0]
$hostname = "localhost";
[/code]

now what else. AND DUH! lol... sorry... ummm... try this:

[code=php:0]
$query = mysql_query("SELECT * FROM exhibits WHERE LEFT(exhibit, 1)='{$_GET['search']}");
while ($row = mysql_fetch_object($result)) {
echo $row->data."<BR />";
}
[/code]
Link to comment
Share on other sites

added it in, still the same error, here is my code again

[code]<a href="?search=A"><font size="2"><strong>A</strong></font></a><strong><font size="2">
                            | <a href="?search=B">B</a> | <a href="?search=C">C</a>
                            | <a href="?search=D">D</a> | <a href="?search=E">E</a>
                            | <a href="?search=F">F</a> | <a href="?search=G">G</a>
                            | <a href="?search=H">H</a> | <a href="?search=I">I</a>
                            | <a href="?search=J">J</a> | <a href="?search=K">K</a>
                            | <a href="?search=L">L</a> | <a href="?search=M">M</a>
                            | <a href="?search=N">N</a> | <a href="?search=O">O</a>
                            | <a href="?search=P">P</a> | <a href="?search=Q">Q</a>
                            | <a href="?search=R">R</a> | <a href="?search=S">S</a>
                            | <a href="?search=T">T</a> | <a href="?search=U">U</a>
                            | <a href="?search=V">V</a> | <a href="?search=W">W</a>
                            | <a href="?search=X">X</a> | <a href="?search=Y">Y</a>
                            | <a href="?search=Z">Z</a></font></strong></p>
                          <p align="left">&nbsp;</p>
                        </div>
<?php
$hostname = "localhost";
$username = greenac_Admin;
$password = greenac;


$conn = mysql_connect($hostname, $username, $password) or die(mysql_error());
$connection = mysql_select_db("greenac_VORNExpo", $conn);

$query = mysql_query("SELECT * FROM exhibits WHERE LEFT(exhibit, 1)='{$_GET['search']}");
while ($row = mysql_fetch_object($query)) {
echo $row->data."<BR />";
}


?>[/code]
Link to comment
Share on other sites

have changed the code again, this time a different error, plz help
[code]<a href="?search=A"><font size="2"><strong>A</strong></font></a><strong><font size="2">
                            | <a href="?search=B">B</a> | <a href="?search=C">C</a>
                            | <a href="?search=D">D</a> | <a href="?search=E">E</a>
                            | <a href="?search=F">F</a> | <a href="?search=G">G</a>
                            | <a href="?search=H">H</a> | <a href="?search=I">I</a>
                            | <a href="?search=J">J</a> | <a href="?search=K">K</a>
                            | <a href="?search=L">L</a> | <a href="?search=M">M</a>
                            | <a href="?search=N">N</a> | <a href="?search=O">O</a>
                            | <a href="?search=P">P</a> | <a href="?search=Q">Q</a>
                            | <a href="?search=R">R</a> | <a href="?search=S">S</a>
                            | <a href="?search=T">T</a> | <a href="?search=U">U</a>
                            | <a href="?search=V">V</a> | <a href="?search=W">W</a>
                            | <a href="?search=X">X</a> | <a href="?search=Y">Y</a>
                            | <a href="?search=Z">Z</a></font></strong></p>
                          <p align="left">&nbsp;</p>
                        </div>
<?php
$hostname = localhost;
$username = ;
$password = ;


$conn = mysql_connect($hostname, $username, $password) or die(mysql_error());
$connection = mysql_select_db("greenac_VORNExpo", $conn);

$query = mysql_query("SELECT * FROM exhibits WHERE LEFT(exhibit, 1)='{$_GET['search']}") or die(mysql_error());
while ($row = mysql_fetch_object($query)) {
echo $row->data."<BR />";
}


?>[/code]
Link to comment
Share on other sites

fill in your db info correctly and this will work

[code]<?php
for ($i = 'A'; $i != 'AA'; $i++){
echo "<a href = \"?search=$i\"> $i </a>";
}
if(isset($_GET['search']) && $_GET['search'] != ''){
// connect to db
$db  = mysql_connect('localhost', 'user',  'pass') or die(mysql_error());
$dbi = mysql_select_db('db_name', $db) or die(mysql_error());
$search = $_GET['search'];

$sql = mysql_query("SELECT * FROM table_name WHERE table_row LIKE '$search"."%'") or die(mysql_error());
while ($row = mysql_fetch_array($sql)){
// display results
echo "<br />" .$row['row to display']. "<br />";
}
}
?>[/code]
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.