Jump to content

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.

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.