Jump to content

echo result not showing on page


phily245

Recommended Posts

Hi,

Ive started work on a website and taken over from another developer, as, when he made the site and handed it over, half of it didn't work. One of the problems was there is a section in the admin system to edit the images in the header's jQuery, which uses php to populate it from a db. The admin page (amend_homepage.php) is meant to list all of the image's titles as hyperlinks that link you to the same page with an id in the url (e.g. amend_homepage.php?id=2), where the user can cange the images.

However, when you go onto the page where it is meant to list the hyperlinks, it does not show them on the page but, if you view the page's source, the hyperlinks are there. Here is the if statement that controls the page's content:

 

<?php if(!isset($_GET["id"])) { ?>
        
        <?php

	$query = mysql_query("SELECT * FROM images ORDER BY image_id ASC") or die (mysql_error());

	$count = mysql_num_rows($query);

	if($count == 0){

		echo '<a title="No homepage images to display." target="_self" class="button" >No homepage images to display.</a>';

	}

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

		echo '<a href="amend_homepage.php?id=' . $fetch["image_id"] . '" title="Amend ' . decodeText($fetch["image_title"]) . '" target="_self" class="button orange" >' . setLength(decodeText($fetch["image_title"])) . '</a>';

	}

	if($count % 2 != 0){

		echo "<br/><br/><br/><br/>";

	}

	?>
        
         <br/><br/><br/><br/>
        
        <a href="menu.php" title="Main Menu" target="_self" class="button purple">Main Menu</a>
        
        <?php }else{ ?>
        
        	<?php $query = mysql_query("SELECT * FROM images WHERE image_id = '" . $_GET["id"] . "' LIMIT 1") or die (mysql_error()); ?>
       		 <?php $fetch = mysql_fetch_array($query); ?>
        <form id="amend_form" name="amend_form" method="post" class="main_form" enctype="multipart/form-data" action="<?php echo $_SERVER["PHP_SELF"]."?id=".$_GET["id"]; ?>">				
			            
                
                <label for="title">Homepage Rotator Image Title
<input name="title" id="title" title="Homepage Rotator Image Title" type="text" maxlength="250" class="text"				
			<?php if(isset($_POST["title"])){ echo 'value="' . $_POST["title"] . '"'; }else{ echo 'value="' . decodeText($fetch["image_title"]) . '"'; } ?> 
			>				
                </label>
                <br/>
                
                <label for="currentimage">Current Homepage Rotator Image
			<input name="currentimage" id="currentimage" title="Current Homepage Image" type="text" class="text"<?php if(isset($fetch["image_image"])){ echo 'value="' . $fetch["image_image"] . '"'; } ?> ><?php if(isset($fetch["image_image"]) && !empty($fetch["image_image"])){ ?><img src="../images/<?php echo $fetch["image_image"]; ?>" width="100%" alt="Current Homepage Rotator Image" title="Current Homepage Rotator Image" /><?php } ?></label>
                <br/>
                
                <label for="image">Homepage Rotator Image
			<input id="image_button" name="image_button" type="button" value="Browse" class="button_small" title="Browse">
              <input id="image_text" name="image_text" type="text" class="text_small" > 
              <input id="image" name="image" type="file" class="hidden" title="product Image" size="51" onchange="this.form.image_text.value = this.value;" ></label>
                <br/>
                
                <label for="link">Homepage Rotator Image Link
<input name="link" id="link" title="Homepage Rotator Image Link" type="text" maxlength="250" class="text"				
			<?php if(isset($_POST["link"])){ echo 'value="' . $_POST["link"] . '"'; }else{ echo 'value="' . $fetch["image_link"] . '"'; } ?> 
			>				
                </label>
                <br/>
               
			<button name="submit" id="submit" type="submit" class="button" >Amend Homepage Rotator Image</button><a href="menu.php" title="Main Menu" target="_self" class="button purple">Main Menu</a>
		</form>

            
            <?php } ?>

 

But here is the section that is producing the error:

 

if($count == 0){

		echo '<a title="No homepage images to display." target="_self" class="button" >No homepage images to display.</a>';

	}

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

		echo '<a href="amend_homepage.php?id=' . $fetch["image_id"] . '" title="Amend ' . decodeText($fetch["image_title"]) . '" target="_self" class="button orange" >' . setLength(decodeText($fetch["image_title"])) . '</a>';

	}

	if($count % 2 != 0){

		echo "<br/><br/><br/><br/>";

	}

	?>
        
         <br/><br/><br/><br/>
        
        <a href="menu.php" title="Main Menu" target="_self" class="button purple">Main Menu</a>

Strangely enough, it still shows the main menu button.

 

here is the page source from the browser:

<!-- InstanceBeginEditable name="doccontent" --> 
        
                
        	        
        <a href="amend_homepage.php?id=1" title="Amend " target="_self" class="button orange" ></a><a href="amend_homepage.php?id=2" title="Amend " target="_self" class="button orange" ></a><a href="amend_homepage.php?id=3" title="Amend " target="_self" class="button orange" ></a><a href="amend_homepage.php?id=4" title="Amend " target="_self" class="button orange" ></a><a href="amend_homepage.php?id=5" title="Amend " target="_self" class="button orange" ></a><a href="amend_homepage.php?id=6" title="Amend " target="_self" class="button orange" ></a>        
         <br/><br/><br/><br/> 
        
        <a href="menu.php" title="Main Menu" target="_self" class="button purple">Main Menu</a> 
        
                
       
        
        <!-- InstanceEndEditable -->

Link to comment
https://forums.phpfreaks.com/topic/240866-echo-result-not-showing-on-page/
Share on other sites

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.