Jump to content

[SOLVED] Database question


harkly

Recommended Posts

Not really sure how to go about this question.

 

I am getting an error when pulling id's for a certain page of mine. Most of the time it works and other times it pulls a bunch of information. Upon researching the problem it seems to pull a list on names if the ID its pulling starts at the low end, example ... if I ask for AR1000, then that is the only info it gives me but if I ask for AR100 then I get a bunch more - AR1001, AR1002 etc.

 

My question is shouls all my primary IDs be the exact same number lenght? Should AR100 be AR0100?

 

This is my code but I don't think the issue is there.

 

$search=$_GET["artid"];


echo "<table width=950 border=0 align=center>";
echo " <tr>";
   echo " <td width=200>";echo " </td>";



   echo " <td width=600>";
//pulls info for Artist

$result = mysql_query("SELECT * FROM artist WHERE artid LIKE '%$search%'");


            while ($r=mysql_fetch_array($result))
              {	


   $fullName=$r["fullName"];

   $dob=$r["dob"];

   $dod=$r["dod"];

   $nationality =$r["nationality"];

   $choosen_medium=$r["artForm"];
   $artid=$r["artid"];

   

   //display the row

echo " <img src=\"image/artist/$artid.jpg\" border=0> ".$fullName.", ".$dob."-".$dod."  <br><br>";
}

 

Link to comment
https://forums.phpfreaks.com/topic/133543-solved-database-question/
Share on other sites

Change your query

$result = mysql_query("SELECT * FROM artist WHERE artid LIKE '%$search%'")

to

$result = mysql_query("SELECT * FROM artist WHERE artid = '$search'")

 

The first one is getting anything that is similar (LIKE) to your search criteria.

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.