MySQL-PHP & JavaScript

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
c1000mg
Forum Newbie
Posts: 3
Joined: Mon Aug 21, 2006 1:06 pm

MySQL-PHP & JavaScript

Post by c1000mg »

Hi everyone!!

I was wondering is someone can help me with this code, I'm trying to get the data from MySQL to make a row of other pictures for the same ID, that can show in the big picture (I got the code form http://www.irt.org/script/642.htm) but if I don't have 'FishDescription['Picture'] or FishOtherPictures['OtherFile'] I will like it no to show anything I was trying with IF & ELSE but I couldn't make it happen!!!

Thank you for your help.

Code: Select all

<SCRIPT LANGUAGE="JavaScript"><!--
function show(name,src) {
    if (document.images)
        document.images[name].src = src;
}
//--></SCRIPT>

<?php if ($row_FishDescription['Picture'] == NULL)
	{
	print('<img src="images/FishPicID/blank.jpg" NAME="myimagename" width="196" height="135">');	}
	else
	{
	print('<img src="images/FishPicID/');print($row_FishDescription['Picture']);print('" NAME="myimagename" width="196" height="135">'); }
?>
<table border="0">
          <tr>
		  <td><A HREF="javascript:show('myimagename','images/FishPicID/<?php echo $row_FishDescription['Picture']; ?>')"><img src="images/FishPicID/<?php echo $row_FishDescription['Picture']; ?>" width="60" height="41" border="0"></a></td>
		  </tr>
		       <?php do { ?>
          <tr>
		   <td><A HREF="javascript:show('myimagename','images/FishPicID/<?php echo $row_FishOtherPictures['OtherFile']; ?>')"><img src="images/FishPicID/<?php echo $row_FishOtherPictures['OtherFile']; ?>" width="60" height="41" border="0"></a></td>
          </tr>
          <?php } while ($row_FishOtherPictures = mysql_fetch_assoc($FishOtherPictures)); ?>
      </table>
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Post by RobertGonzalez »

Can you post some generated HTML? What I mean is run the PHP page and do a view source, then post that source that shows the code above already parsed.
c1000mg
Forum Newbie
Posts: 3
Joined: Mon Aug 21, 2006 1:06 pm

Post by c1000mg »

feyd | Please use

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]


This is the code that shows if I have images in the OtherPictures Table

[syntax="html"]<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Fish Description</title>
<link href="../MainStyles.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<SCRIPT LANGUAGE="JavaScript"><!--
function show(name,src) {
    if (document.images)
        document.images[name].src = src;
}
//--></SCRIPT>
</head>

<body>
<img src="images/FishPicID/Guppy01.jpg" NAME="myimagename" width="196" height="135"><table border="0">

          <tr>
                  <td><A HREF="javascript:show('myimagename','images/FishPicID/Guppy01.jpg')"><img src="images/FishPicID/Guppy01.jpg" width="60" height="41" border="0"></a></td>
                  </tr>
                                 <tr>
                   <td><A HREF="javascript:show('myimagename','images/FishPicID/Guppy02.jpg')"><img src="images/FishPicID/Guppy02.jpg" width="60" height="41" border="0"></a></td>
          </tr>
                    <tr>
                   <td><A HREF="javascript&:show('myimagename','images/FishPicID/Guppy03.jpg')"><img src="images/FishPicID/Guppy03.jpg" width="60" height="41" border="0"></a></td>
          </tr>

                </table></body>
</html>


And This is the code if the Fish ID doesn't hav OtherPictures in the table

Code: Select all

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Fish Description</title>
<link href="../MainStyles.css" rel="stylesheet" type="text/css">
<script language="JavaScript" type="text/JavaScript">
<!--
function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);
//-->
</script>
<SCRIPT LANGUAGE="JavaScript"><!--
function show(name,src) {
    if (document.images)
        document.images[name].src = src;
}
//--></SCRIPT>
</head>

<body>
<img src="images/FishPicID/5.jpg" NAME="myimagename" width="196" height="135"><table border="0">

          <tr>
                  <td><A HREF="javascript:show('myimagename','images/FishPicID/5.jpg')"><img src="images/FishPicID/5.jpg" width="60" height="41" border="0"></a></td>
                  </tr>
                                 <tr>
                   <td><A HREF="javascript:show('myimagename','images/FishPicID/')"><img src="images/FishPicID/" width="60" height="41" border="0"></a></td>
          </tr>
                </table></body>
</html>
If you see in the second code It generates another link with no pictures and if you click the main picture will change,

btw Thank you very much for posting in here!!!


feyd | Please use[/syntax]

Code: Select all

,

Code: Select all

and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read:  [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
c1000mg
Forum Newbie
Posts: 3
Joined: Mon Aug 21, 2006 1:06 pm

Post by c1000mg »

Please Help me!!!!
Post Reply