Jump to content

[SOLVED] Newbie with SELECT issues.


RP

Recommended Posts

Title says it all, im kinda new at this so im really hoping you guys can help me out.

 

Ive been asked to make a SQL driven google maps mashup, the page has a submit form which a passes a varible to the SQL called $code, This varible is then used in the selct statement. My table has has multiple id feilds (id1, id2, id3, id4, id5) and id like to search all of them for the %code variable. I have gotten the code working perfectly searching just one of the id feilds (as below), but when i try to search more than one it returns 'no results'.

 

include("dbinfo.php");

mysql_connect('$main',$username,$password);

mysql_select_db($database) or die( "Unable to select database : " . mysql_error());

 

$result = mysql_query("SELECT *

FROM gmaps

WHERE id1 = '$code'");

 

 

if (!$result)

{

echo "no results";

}

while($row = mysql_fetch_array($result))

{

echo "var point = new GPoint(" . $row['long'] . "," . $row['lat'] . ");\n";

echo "var marker = createMarker(point, '<div id=\"infowindow\" style=\"white-space: nowrap;\"><p><strong>" . addslashes($row['station']) . "</strong><br /><a href=\"javascript:ajaxpage(\'ajaxfiles/" . addslashes($row['html']) . ".htm\',\'rightcolumn\')\">Learn More</a></p></div>');\n";

echo "map.addOverlay(marker);\n";

echo "\n";

}

 

mysql_close();

 

Everything ive read says that to achive this all i need to do is this :

 

$result = mysql_query("SELECT *

FROM gmaps

WHERE id1, id2, id3, id4, id5 = '$code'");

 

but that isnt working either, simply returning 'no result'. Ive tried with apostrophes, without apostrophes, with full text strings (idone, idtwo ect.), still no dice.

 

any ideas? id really appreciate the help.

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.