Solved

jQuery tool tip pulling DESCRIPTION from database

Posted on 2007-11-20
62
385 Views
Last Modified: 2013-12-13
I am wondering if it is possible to use say a call back function like in jQuery. Display a tool tip but when a user goes over the DIV/A it will show the description of a certain ID in the database?

Using: http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/

Any suggestions?

Thanks!
0
Comment
  • 38
  • 24
62 Comments
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20342031
If you want the tooltip to call the server only when mousing over you need

1. write the php that queries the DB
2. test that it works using normal url
3. wire it into the jQuery tool tip with ajax


0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20343003
Alrighty, let me try that ahead of time! Ill let you know! I might need some help wit that!.

Ryan
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20343033
I have this so far and I get the other end of the if the Error Has Occured
<?php

if($_REQUEST["paper"]){

	$id     = $_REQUEST["paper"];

	$sql    = "SELECT * FROM papers WHERE description=$id";

	$query  = mysql_query($sql) or die(mysql_error());

	

	while($row = mysql_fetch_array($query)){

		print "<p>Description: ".$row["description"]."</p>";

	}	

}else{

	echo "Error has occured";

}

?>

Open in new window

0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20343034
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20343048
I got it, here is my newest code and after looking at the JS for it, I have this so far:
<?php

if($_REQUEST["id"]){

	$id     = $_REQUEST["id"];

	$sql    = "SELECT * FROM papers WHERE id=$id";

	$query  = mysql_query($sql) or die(mysql_error());

	

	while($row = mysql_fetch_array($query)){

		print "<p>".$row["description"]."</p>";

	}	

}else{

	echo "Error has occured";

}

?>
 
 
 

JS ---------------------------------------------
 

$("#desc").Tooltip({ 

    track: true, 

    delay: 0, 

    showURL: false, 

    opacity: 1, 

    fixPNG: true, 

    showBody: " - ", 

    extraClass: "pretty"

}); 

Open in new window

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20344978
Sorry, I was offline for a while

Where are you now?

Still need some assistance and with which part?

I see an error has occurred on the link you gave.
http://newspapersofamerica.com/new/index.php?p=description&paper=96

Also have you decided to include all the IDs on the page at once (simpler) instead of pulling them in one by one on mouseover?
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20345462
Thats fine! I have this now - http://newspapersofamerica.com/new/index.php?p=description&id=96 - changed paper to id. I am stuck on the ajax part for the tooltip I have my JS set up but I am confused how to get it with ajax? Use the call back function with jquery?

>>Also have you decided to include all the IDs on the page at once (simpler) instead of pulling them in one by one on mouseover?

What do you mean by that? Wouldn't the only way be to on mouseover show id X

Thanks,
Ryan
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20345680
You can pull all the possible IDs in when you load the page with just the php in the page.
Ajax is normall only used if there are too many possible values to load in one page at once
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20345693
Oh that is true..so you are saying load all the IDs with the descriptions? Then pull using ajax? Am I right? I am stuck on that part, any suggestions?

How would i alter my PHP to do that?

Thanks,
Ryan
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20345818
No I say EITHER load ALL descriptions in ONE go (super simple - no big change to your php needed - just create an array of descriptions)
OR load them one at a time with Ajax
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20346472
Ohh..what would you recommend this is my first approach at this?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20346726
<script>
var myDescs = new Array();
<?php
if($_REQUEST["id"]){
        $id     = $_REQUEST["id"];
        $sql    = "SELECT * FROM papers WHERE id=$id";
        $query  = mysql_query($sql) or die(mysql_error());
       
        while($row = mysql_fetch_array($query)){
                print "\nmyDescs[myDescs.length]=\"".$row["description"]."\";";
        }      
}else{
        echo "alert('Error has occured')";
}
?>
</script>

have a look at view-source of the result

It should say
<script>
var myDescs = new Array();
myDescs[myDescs.length]="description 1";
myDescs[myDescs.length]="description 2";
myDescs[myDescs.length]="description 3";
</script>

and then you can use

document.getElementById('id3').title=myDescs[3];

for example
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20346743
I get an error when I run that, I get the alert box. Any suggestions? Is there any other way to do this, because in the long run I am going to have 1600 descriptions for each row? It wouldnt be easier to use the PHP file I created then use jquery tooltiip and call back to bring in each description for the correct ID?
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20346817
first get your php to return SOMETHING

Then we need to use Ajax since yo uhave too many descriptions for one page assuming you have 1600 items on ONE page you need to describe (why so many???)
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20346882
I have so many because there are about 1600 papers if you go http://www.newspapersofamerica.com/new/index.php?p=daily and click a state it has each paper, each paper will have a description and then use a tool tip mouse over to show it.

I have my php get results - http://www.newspapersofamerica.com/new/index.php?p=description&id=96

This pulls the results of the ID from 96, not all of them have ids yet, i just added in 96.

Ryan
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20348618
Ok, now you need to make that php ONLY return the description string - nothing else
If you need to, make a new php
description.php?p=description&id=96

so it can be called by the Ajax
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20348665
Like this:
var currentId = "";
function getTip(myObject) {
  if (myObject.title) return; // no need to get it more than  oce
  currentId=myObject.id;
  $.get("description.php", { p: "description", id: currentId },
    function(data){
      if (currentId) document.getElementById(currentId).title=data;
    });
}

you MAY need to call the mouseover of the object and/or add a letter to the ID to not make it numeric...
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20349496
Alrighty, on this part I am kind of confused about - http://bassistance.de/jquery-plugins/jquery-plugin-tooltip/ - you set a tag to do the mouse over but how will you call the tooltip?

EX CODE:

$('label').Tooltip({
  delay: 0,
  track: true,
  event: "click"
});
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20349999
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20350045
Yeah...just like that, on the hover it will show the description of the specific ID.
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20350106
So visit
http://15daysofjquery.com/jquery-tooltips/21/

If you are lazy, grab the files from my site (view-source:http://www.plungjan.name/ee/testjq.html) and see how you pass the url to return the description in the REL attribute


The php just did this:

<?php
 

if ($_GET["id"] == "96") {

  echo "<b>ID 96</b>: Read North East and Newcastle news  from ChronicleLive, the <i>Evening Chronicle</i> newspaper online.<br>All the latest on Newcastle Utd, Sunderland AFC and more.";

} 

else {

  echo "Description not found";

}
 

?>

Open in new window

0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20350121
Thank you! Let me try this out, ill post my results, I might have some questions..Ill give this a go!
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20350899
So i started to implement it, i cant get anything to display. I see how this is starting to work. I pasted yours to try to get something working and nothing so far.

You gave me this code as well, the get ID description (at bottom of page) - Is there a way to retrieve it from t he database according to what ID is being displayed on the row? Does my old code work for that? The PHP works fine.

At the very bottom.
Any suggestions?
Thanks a ton for your help!
while($row = mysql_fetch_array($query)){

	print "<tr>";

		print "<td>".$row["name"]."</td>"; 

		print "<td>".$row["city"]."</td>"; 

		print "<td>".$row["circulation"]."</td> ";

		print "<td>$".$row["price"]."</td> ";

		print "<td class=\"desc\" align=\"center\"><span class=formInfo\"><a href=\"#\" rel=\"description.php?id=96&width=375&amp;name=Description%20is%20as%20follows:\"><img src=\"images/newspaper.png\" alt=\"description\" /></a></span></td>";

		print "<td align=\"center\"><a href=\"#\"><img src=\"images/dollar.png\" alt=\"purchase\" /></a></td>";

	print "</tr>";

	}
 
 

GET ID CODE ###################################
 

<?php

 

if ($_GET["id"] == "96") {

  echo "<b>ID 96</b>: Read North East and Newcastle news  from ChronicleLive, the <i>Evening Chronicle</i> newspaper online.<br>All the latest on Newcastle Utd, Sunderland AFC and more.";

} 

else {

  echo "Description not found";

}

 

?>
 
 

MY DESCRIPTION CODE #############################################
 
 

<?php

if($_REQUEST["id"]){

	$id     = $_REQUEST["id"];

	$sql    = "SELECT * FROM papers WHERE id=$id";

	$query  = mysql_query($sql) or die(mysql_error());

	

	while($row = mysql_fetch_array($query)){

		print "<p>".$row["description"]."</p>";

	}	

}else{

	echo "Error has occured";

}

?>

Open in new window

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20352154
I fail to understand your problems

Copy my code from the html and upload the js files to your server,

use

<a target="_blank" href="somelink.html" class="jTip" id="someLink" rel="desc.php?id=95&link=whatever&width=375&amp;name=Description%20of%paper:">Google</a>


where 95 is the ID of that newspaper and desc.php could look like this:


<?php

if($_REQUEST["id"]){

        $id     = $_REQUEST["id"];

        $sql    = "SELECT * FROM papers WHERE id=$id";

        $query  = mysql_query($sql) or die(mysql_error());

print "<table>";        

while($row = mysql_fetch_array($query)){

        print "<tr>";

                print "<td>".$row["name"]."</td>"; 

                print "<td>".$row["city"]."</td>"; 

                print "<td>".$row["circulation"]."</td> ";

                print "<td>$".$row["price"]."</td> ";

                print "<td class=\"desc\" align=\"center\"><span class=formInfo\"><a href=\"#\" rel=\"description.php?id=96&width=375&amp;name=Description%20is%20as%20follows:\"><img src=\"images/newspaper.png\" alt=\"description\" /></a></span></td>";

                print "<td align=\"center\"><a href=\"#\"><img src=\"images/dollar.png\" alt=\"purchase\" /></a></td>";

        print "</tr>";

        }

print "</table>";

}else{

        echo "Error has occured";

}

?>

Open in new window

0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20352841
I made your code above in to desc.php and I pasted the code in my papers.php code.

http://www.newspapersofamerica.com/new/index.php?p=papers&state=3

And I get no results

Any suggestions?
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20352938
In my firebug I get two errors:

jQuery is not defined
http://www.newspapersofamerica.com/new/index.php?p=papers&state=3
Line 15

I had to use jquery no conflict to work

$ is not defined
http://www.newspapersofamerica.com/new/js/jtip.js
Line 9

Any suggestions?

Thanks!
<script type="text/javascript">

// prevent conflict with niceforms

var J = jQuery.noConflict();

// code for table sorting

$(document).ready(function() { 

	J("#myTable").tablesorter();

});

// code for editing in place

$(document).ready(function() {
 

   J(".name").editInPlace({

               url: "save.php",

			   bg_out: "#FFFFFF"

       });
 

   J(".state").editInPlace({

               url: "save.php",

		 	   bg_out: "#FFFFFF"

       });
 

   J(".circulation").editInPlace({

               url: "save.php",

			   bg_out: "#FFFFFF"

       });
 

   J(".price").editInPlace({

               url: "save.php",

			   bg_out: "#FFFFFF"

       });

});

$(document).ready(function() { 

Date.firstDayOfWeek = 7;

Date.format = 'mm/dd/yyyy';

	J('.date-pick').datePicker()

});

</script>

Open in new window

0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20353456
I made sure both of my files are updated and my code looks correct, but I cant see a tool tip at all? Any ideas?
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20353493
Doesnt that seem a bit too much and the code I had for description.php would work. Since we need the description.

The code after the one I posted is the one I came up with.



<?php

if($_REQUEST["id"]){

        $id     = $_REQUEST["id"];

        $sql    = "SELECT * FROM papers WHERE id=$id";

        $query  = mysql_query($sql) or die(mysql_error());

print "<table>";        

while($row = mysql_fetch_array($query)){

        print "<tr>";

                print "<td>".$row["name"]."</td>"; 

                print "<td>".$row["city"]."</td>"; 

                print "<td>".$row["circulation"]."</td> ";

                print "<td>$".$row["price"]."</td> ";

                print "<td class=\"desc\" align=\"center\"><span class=formInfo\"><a href=\"#\" rel=\"description.php?id=96&width=375&amp;name=Description%20is%20as%20follows:\"><img src=\"images/newspaper.png\" alt=\"description\" /></a></span></td>";

                print "<td align=\"center\"><a href=\"#\"><img src=\"images/dollar.png\" alt=\"purchase\" /></a></td>";

        print "</tr>";

        }

print "</table>";

}else{

        echo "Error has occured";

}

?>
 
 
 

DESCRIPTION.PHP ################################
 
 
 

<?php

if($_REQUEST["id"]){

	$id     = $_REQUEST["id"];

	$sql    = "SELECT * FROM papers WHERE id=$id";

	$query  = mysql_query($sql) or die(mysql_error());

	

	while($row = mysql_fetch_array($query)){

		print "<p>".$row["description"]."</p>";

	}	

}else{

	echo "Error has occured";

}

?>

Open in new window

0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20353743
I had some errors, i fixed them all, i had a conflict with some other JS I was using and i had to use - http://docs.jquery.com/Using_jQuery_with_Other_Libraries

I set that up and had to alter my jtip.js file for the functions to change "$" to "$j" to fix them all.

No errors no with firebug, any suggestions?
// prevent conflict with niceforms

var $j = jQuery.noConflict();

// code for table sorting

$j(document).ready(function() { 

	$j("#myTable").tablesorter();

});

// code for editing in place

$j(document).ready(function() {
 

   $j(".name").editInPlace({

               url: "save.php",

			   bg_out: "#FFFFFF"

       });
 

   $j(".state").editInPlace({

               url: "save.php",

		 	   bg_out: "#FFFFFF"

       });
 

   $j(".circulation").editInPlace({

               url: "save.php",

			   bg_out: "#FFFFFF"

       });
 

   $j(".price").editInPlace({

               url: "save.php",

			   bg_out: "#FFFFFF"

       });

});

$j(document).ready(function() { 

	Date.firstDayOfWeek = 7;

	Date.format = 'mm/dd/yyyy';

	$j('.date-pick').datePicker()

});

Open in new window

0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20353768
I have this: http://www.newspapersofamerica.com/new/index.php?p=desc&id=4

That is what will be returned correct?

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20356180
Sorry, I am in CET. I was not online.

I will look
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20356197
try

<a href="#" class="jTip" rel="description.php?id=96&width=375&amp;name=Description%20is%20as%20follows:">

and fix your description.php


Warning: mysql_query(): Can't connect to local MySQL server through socket '....'(2) in .... description.php on line 5

Warning: mysql_query(): A link to the server could not be established in .... description.php on line 5
Can't connect to local MySQL server through socket '....' (2)

0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20357412
Hey. I did, I was making my config file use both local/remote server to connect, If you go http://www.newspapersofamerica.com/new/index.php?p=description&id=62

You will see that pulls the description from row 62.

<?php

if($_REQUEST["id"]){

	$id     = $_REQUEST["id"];

	$sql    = "SELECT * FROM papers WHERE id=$id";

	$query  = mysql_query($sql) or die(mysql_error());

	

	while($row = mysql_fetch_array($query)){

		print "<p>".$row["description"]."</p>";

	}	

}else{

	echo "Error has occured";

}

?>

Open in new window

0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20357441
I get this error on mouse over my the link:

    >> oLeft = o.offsetLeft // Get left position from the parent object

>>o has no properties
http://www.newspapersofamerica.com/new/js/jtip.js
Line 55
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20357444

<a href="#" class="jTip" rel="description.php?id=62&width=375&amp" name="Description%20is%20as%20follows:">TEST TOOL TIP!</a>

Open in new window

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20357650
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20357961
It shoud be now I am using header.php/footer.php and loading content in between with PHP so I have my config.php file in my header.php file. Let me add it now for it works. Should be working.
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20360602
I did that..any suggestions now?

THanks!
Ryan
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20360851
Where is the example with the
<a href="#" class="jTip"
rel="description.php?id=62&width=375&name=Description%20is%20as%20follows:">TEST TOOL TIP!</a>

then?

Notice the lack of quote
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20360869
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20360986
Should be

rel="description.php?id=62&width=375&name=Description%20is%20as%20follows:">
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20361094
I changed that and still nothing - I get a JS error, do you? On mouseoever on that image.
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20361108
http://www.codylindley.com/blogstuff/js/jtip/ at the site if you view source t hey have the name as its on attribute.
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20361130
I get this js error:

 Error: o has no properties
Source File: http://www.newspapersofamerica.com/new/js/jtip.js
Line: 55
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20364202
You did not have an ID!

Please make the links look like the ones in the examples I have given you.


Todays News Heralds:


<a href="#" class="jTip" id="paper96" rel="description.php?id=96&width=300&name=Description%20as%20follow:"><img src="images/newspaper.png" alt="description" /></a>
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20364207
So
1. class="jTip"
2. unique ID
3. No spaces and no quotes in the REL

Feel free to change
&name=Description%20as%20follow:
to whatever you wish as long as you substitute %20 for spaces
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20366346
I have all of that dont I? do you know why I am gettting that JS error?

Ryan
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20366366
But did you see on there site they have name as

    name="NAME HERE"

not in the REL
0
 
LVL 75

Accepted Solution

by:
Michel Plungjan earned 500 total points
ID: 20366423
"I have all of that dont I? do you know why I am gettting that JS error?"

No you did not. No ID - please check:::

This is yours:

<a href="#" class="jTip" rel="description.php?id=62&width=375&name=Description%20is%20as%20follows:">TEST TOOL TIP!</a>

Should have been

<a href="#" ID="TEST" class="jTip" rel="description.php?id=62&width=375&name=Description%20is%20as%20follows:">TEST TOOL TIP!</a>


-----------

You wrote:
"But did you see on there site they have name as
    name="NAME HERE"
not in the REL"

Who?? what?? where???

Just please follow ALL instructions and it will work...
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20367301
I get this now - http://www.newspapersofamerica.com/new/index.php?p=papers&state=3

Try it out, I get the whole page, any idea how to get one Id, haha.

Thanks,
RYan
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20368035
Try giving it an href

<a href="http://www.newspapersofamerica.com/new/description.php?id=62"
class="jTip" id="test" rel="description.php?id=62&width=375&name=Description%20is%20as%20follows:">TEST TOOL TIP!</a>
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20368178
One last quick question! I got the rest to show up! Thanks so much for your help and guiding me through this.

How would I get it to show "Nothing to display" If there is no description?
<?php

include_once ("config.php");

if($_REQUEST["id"]){

	$id     = $_REQUEST["id"];

	$sql    = "SELECT * FROM papers WHERE id=$id";

	$query  = mysql_query($sql) or die(mysql_error());

	

	while($row = mysql_fetch_array($query)){

		print "<p>".$row["description"]."</p>";

	}	

}else{

	echo "Error has occured";

}

?>

Open in new window

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20368215
change

while($row = mysql_fetch_array($query)){
            print "<p>".$row["description"]."</p>";
      }      

to

$desc = "";
while($row = mysql_fetch_array($query)){
  &desc.="<p>".$row["description"]."</p>";
}      
if ($desc=="") {
  $desc = "Nothing to display";
}
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20368227
PS: Feel free to visit my profile....
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20368521
Thank you, i get this now":

[Exception... "'Permission denied to call method XMLHttpRequest.open' when calling method: [nsIDOMEventListener::handleEvent]"  nsresult: "0x8057001e (NS_ERROR_XPC_JS_THREW_STRING)"  location: "<unknown>"  data: no]

Line 0

And no idea why.
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20368609
Nevermind, I got it!
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20368630
i have this and it display nothing no matter what...any ideas?
<?php

include_once ("config.php");

if($_REQUEST["id"]){

	$id     = $_REQUEST["id"];

	$sql    = "SELECT * FROM papers WHERE id=$id";

	$query  = mysql_query($sql) or die(mysql_error());

	

	$desc = "";

	while($row = mysql_fetch_array($query)){

    	$desc.="<p>".$row["description"]."</p>";

	}

	if ($desc=="") {

		$desc = "Nothing to display";

	}
 

}else{

	echo "Error has occured";

}

?>

Open in new window

0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20371979
oops

$desc = "";
while($row = mysql_fetch_array($query)){
  $desc.="<p>".$row["description"]."</p>";
}
if ($desc=="") {
  $desc = "Nothing to display";
}
echo $desc;
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20375293
I still get the same results..any ideas?

Thanks man!

<?php

include_once ("config.php");

if($_REQUEST["id"]){

	$id     = $_REQUEST["id"];

	$sql    = "SELECT * FROM papers WHERE id=$id";

	$query  = mysql_query($sql) or die(mysql_error());

	

	$desc = "";

	while($row = mysql_fetch_array($query)){

    	$desc.="<p>".$row["description"]."</p>";

	}

	if ($desc=="") {

		$desc = "Nothing to display";

	}

	echo $desc;
 

}else{

	echo "Error has occured";

}

?>

Open in new window

0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20375297
0
 
LVL 75

Expert Comment

by:Michel Plungjan
ID: 20376271
Where?

I get test description on the test link

I get test test test
on
http://newspapersofamerica.com/new/description.php?id=63

I get error on
http://newspapersofamerica.com/new/description.php?id=0
and on http://newspapersofamerica.com/new/description.php?id=63X



Try

$found = false;
while($row = mysql_fetch_array($query)){
  $desc.="<p>".$row["description"]."</p>";
  $found=true;
}
if ($found) echo $desc;
else echo "Nothing to display";

If that does not work, please post a new question in the php area on how to test a fetch returns something
0
 
LVL 1

Author Comment

by:catonthecouchproductions
ID: 20376317
That didnt work, ill go post another question..thank you!
0

Featured Post

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

This article will give core knowledge of JavaScript and will head in to your first JavaScript program. I am Durvesh Naik and I am here to deal with this series of JavaScript. I will teach you JavaScript in part wise , as its quite boring to read big…
Password hashing is better than message digests or encryption, and you should be using it instead of message digests or encryption.  Find out why and how in this article, which supplements the original article on PHP Client Registration, Login, Logo…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now