WHILE ($rows = mysql_fetch_array($query)): //Fetch data from $query as long as there is data to fetch $rows = preg_replace('/[\x00-\x1F\x80-\xFF]/', '', $rows); // assign fields from the query to Variables using session variables $_SESSION['first_name'] = $rows['first_name']; $_SESSION['Last_name'] = $rows['last_name']; $_SESSION['company'] = $rows['company']; $_SESSION['spec'] = $rows['spec']; $_SESSION['discription'] = $rows['discription']; $_SESSION['spec'] = str_replace (" ", "", $_SESSION['spec']); //Deletes spaces from spec echo '<a href="spec/',$_SESSION['spec'],'.pdf">', $_SESSION['spec'],' ',$_SESSION['discription'],'</a><br/>'; //Prints data into a list endwhile; ?>
export data from a while loop
-
- Posts: 9
- Joined: Thu Jul 26, 2012 3:17 pm
- Contact:
export data from a while loop
I have a database that I use a loop to assign variables to it's fields. The loop then exports the data into a variable that also loops to make a list. Is there a way to have the echo do the same thing outside the loop as it does in the loop? This way the list and variables still exist after the loop dies. This might help from killing my links once this page is opened in a iframe (Please see PHP hyperlinks in a iFrame passing to a iFrame in index.php).
Local Server: XAMMP 1.8.0, Windows 7 64bit
Local PHP: 5.4.4
Local Apache: 2.4.2
Local MySQL: 14.14 Distrib 5.5.25a, for Win32 (x86)
PHP/HTML Editor: Komodo Edit, version 7.1.0
Local PHP: 5.4.4
Local Apache: 2.4.2
Local MySQL: 14.14 Distrib 5.5.25a, for Win32 (x86)
PHP/HTML Editor: Komodo Edit, version 7.1.0
-
- Posts: 9
- Joined: Thu Jul 26, 2012 3:17 pm
- Contact:
Re: export data from a while loop
Problem solved.
<body> <a href="spec/<?php echo $_SESSION['spec']; ?>.pdf" target="pdf"> <?php echo $_SESSION['spec'],' ',$_SESSION['discription'], '<br />'; ?> </a> <?php endwhile; ?> </body>
Local Server: XAMMP 1.8.0, Windows 7 64bit
Local PHP: 5.4.4
Local Apache: 2.4.2
Local MySQL: 14.14 Distrib 5.5.25a, for Win32 (x86)
PHP/HTML Editor: Komodo Edit, version 7.1.0
Local PHP: 5.4.4
Local Apache: 2.4.2
Local MySQL: 14.14 Distrib 5.5.25a, for Win32 (x86)
PHP/HTML Editor: Komodo Edit, version 7.1.0