vet911 Posted October 20, 2010 Share Posted October 20, 2010 I need help with my script! I search the database and post the thumbnail pictures, I have an href statement that I want the link I put in the database to link to the picture. When I look at the html code the href is blank. I don't know what wrong, please help. Below is the code: Thanks for your help. <?php include 'config1.php'; include 'form.php'; $search=$_GET["search"]; // Connect to server and select database. mysql_connect($dbhost, $dbuser, $dbpass)or die("cannot connect"); mysql_select_db("xxxxxx")or die("cannot select DB"); $result = mysql_query("SELECT * FROM $dbname WHERE year LIKE '%$search%'") or die(mysql_error()); // store the record of the "" table into $row //$current = ''; // keeps getting the next row until there are no more to get if($result && mysql_num_rows($result) > 0) { $i = 0; $max_columns = 6; echo "<table>"; echo "<br>"; while($row = mysql_fetch_array($result)) { // make the variables easy to deal with extract($row); // open row if counter is zero if($i == 0) echo "<tr>"; echo "<td align=center>"; ?> <div style="float: left;"> <div><a href="<?php echo $link; ?>"><img src="<?php echo $tn; ?>"></a></div> <div><?php echo $title; ?></div> </div> <?php echo "</td>"; // increment counter - if counter = max columns, reset counter and close row if(++$i == $max_columns) { echo "</tr>"; $i=0; } // end if } // end while } // end if results // clean up table - makes your code valid! if($i > 0) { for($j=$i; $j<$max_columns;$j++) echo "<td> </td>"; echo '</tr>'; } mysql_close(); ?> Link to comment https://forums.phpfreaks.com/topic/216428-i-need-help-with-my-script/ Share on other sites More sharing options...
PFMaBiSmAd Posted October 21, 2010 Share Posted October 21, 2010 So the variable $link is either empty or does not exist? Are you sure you have a column in your database table that is spelled and capitalized exactly the same as 'link'? Link to comment https://forums.phpfreaks.com/topic/216428-i-need-help-with-my-script/#findComment-1124681 Share on other sites More sharing options...
vet911 Posted October 21, 2010 Author Share Posted October 21, 2010 Yes, I do have the variable spelled correctly in a table, but the wrong table I just found out. Thank you for your time and expertise. Link to comment https://forums.phpfreaks.com/topic/216428-i-need-help-with-my-script/#findComment-1124711 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.