Jump to content
Paul Andrei

Need help with a loop in SQL

Recommended Posts

Hi, can anyone help me to understand where to put the "while" function in the code so i can display more than one row from the table please.

This is the code i use: 

<?php 
	$data_sheet = false;
	$datasheet_query = $db->Execute("SELECT TECHLINK_ID, TECHLINK_INCODE, TECHLINK_URLID, TECHLINK_products_id, TECH_URL, TECH_TITLE
									FROM FTECHLINK
									LEFT JOIN FTECHSHEET_URL ON TECH_ID = TECHLINK_URLID
									WHERE TECHLINK_products_id = ".(int)$_GET['products_id']."");
		if (!$datasheet_query->EOF){
		$data_sheet = true;
		$pdf_title = $datasheet_query->fields['TECH_TITLE'];
		$pdf_file = $datasheet_query->fields['TECH_URL'];
		$pdf_path = "acrobat/".$pdf_file;
		$image_name = str_ireplace('.pdf','.jpg',$pdf_file);
		$image_path = "acrobat/".$image_name;
		$tech_image = '<div class="download_image_container"><a href="' . $pdf_path . '"target="_blank">' . zen_image($image_path, $products_name, "173", "245", 'class="box_image_pdf"') . '</a></div>';
		$tech_title = '<div class="download_title_container"><a class="document_title"href="' . $pdf_path . '"target="_blank">' . $pdf_title . '</a></div>';
	
	}
	?>

 <?php if ($data_sheet == true) {  ?>
      <div id="datasheet" class="tab-pane">
				    <div class="product-tab">
				<?php 
										
				    echo $tech_image;
				    echo $tech_title;
					
				?>
				    </div>
      </div>
						
     <?php }	?>

and the table looks like the image i attached, i know that the SQL query is working but i can't seem to display all the rows.

Much appreciated for the help.

Kind regards

 

image_(1).png

Share this post


Link to post
Share on other sites

This does not look like code from any database library I'm familiar with. You're at high risk of hacking through SQL injection because you're putting user input straight into the query.

Wherever in your code the database object's fetch() method is, you would put the loop there.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...

×
×
  • Create New...