Forum Moderators: coopster
This line in particular:
echo '<td>'.$row['date_string'].'</td><td><a href="details.php?id='.$row['id'].'"</a>'.$row['diwtitle'],'</td><td>'.$row['id'].'</td>';
Is supposed to make the result a clickable link, but it does not.. What have I done wrong on this line?
All code on page:
[php]
<?PHP
$connect= mysql_connect("localhost","root")
or die("Could not connect to database in localhost!");
$result=mysql_select_db("testdiw")
or die("Could not select that database!");
$curdate = date("F j, Y");
$sqlquery = "SELECT id, diwtitle, date_string FROM mktime WHERE date_string >= CURDATE() ORDER BY date_string";
$queryresult = mysql_query($sqlquery) or die(" Could not execute mysql query!");
$row = mysql_fetch_row($queryresult);
$date_string = $row[0];
$diwtitle = $row[1];
$id = $row[2];
$tdcount = 1;
$numtd = 1; // number of cells per row
echo '<table border="0" width="" bgcolor="">
<tr>
<td colspan=3 bgcolor="#000080"><font face="Tahoma" size="5" color="white"> I-DEP - Current Depositions</font></td>
</tr>
<tr>
<td bgcolor="#ccccff" width=100><font face="Tahoma" size=2 color="black"><b> Date of Dep </b></font></td>
<td bgcolor="#ccccff" width=400><font face="Tahoma" size=2 color="black"><b> Title </b></font></td>
<td bgcolor="#ccccff" width=60><font face="Tahoma" size=2 color="black"><b> Dep ID </b></font></td>';
while($row = mysql_fetch_array($queryresult)) {
if ($tdcount == 1) echo "<tr>";
//echo "<td>",$row['date_string'],"</td><td>",$row['diwtitle'],"</td><td>",$row['id'],"</td>";
echo '<td>'.$row['date_string'].'</td><td><a href="details.php?id='.$row['id'].'"</a>'.$row['diwtitle'],'</td><td>'.$row['id'].'</td>';
if ($tdcount == $numtd) {
echo "</tr>";
$tdcount = 1;
} else {
$tdcount++;
}
}
// time to close up our table
if ($tdcount!= 1) {
while ($tdcount <= $numtd) {
echo "<td> </td>";
$tdcount++;
}
echo "</tr>";
}
echo "</table>";
?>[/php]
<td><a href="details.php?id=39" ></a></td>
But it does not make the content pulled from the db for that cell clickable. I think the closing </a> is in the wrong position.. I think it should be after '.$row['diwtitle'],' but I am not sure how to move it, what with all the 's and "s :p I have been trying, all unsuccessful so far..
EDIT: I moved the closing </a> tag to this:
echo '<td>'.$row['date_string'].'</td><td><a href="details.php?id='.$row['id'].'" '.$row['diwtitle'],'</a></td><td>'.$row['id'].'</td>';
And now when I view the page source it looks like it should echo a clickable link, but in the browser, there is now nothing in the field to click.. All text is missing from that column.
let me try ;)
echo '<td>'.$row['date_string'].'</td><td><a href="details.php?id='.$row['id'].'" '.$row['diwtitle'],'</a></td><td>'.$row['id'].'</td>';
should be...
echo '<td>'
.$row['date_string']
.'</td><td><a href="details.php?id='
.$row['id']
.'">'
.$row['diwtitle']
.'</a></td><td>'
.$row['id']
.'</td>';
BTW, the comma worked instead of a dot because echo takes multiple parameters and printes them out after each other, so you can actually replace all dots with commas ;)
Regards,
SN
echo '<td>'.$row['date_string'].'</td><td><a href="details.php?id='.$row['id'].'"> '.$row['diwtitle'],'</a></td><td>'.$row['id'].'</td>';
details.php is where I will edit the variables if needed. I created a variables.php page but nothing is pulled. Currentl;y the query statement on details.php is $sqlquery = "SELECT * FROM mktime ";
Does the correct query also reference the id which I want the data for?