![]() |
Links to ID's
In the news script I have created I have the news in the center and headlines on the bottom right, in bullet format. I want these to work so that when you click them, they bring the full news page up (with that article). I presume this is by using ID's can anyone help?
<a href="$id" target="_blank"> ??? |
and also - to do with the ID's...
in the table for news i have.. i have id author message date the first 2 posts are - ID 1 and 2 the others are - 16+ wheres the other 15 gone? is it cos i had to change the message type to BLOB? (as it was varchar (255) i couldnt fit the whole post on! :( ) can anyone help with that too? |
First, you do not need blob for the news. That's basically for binary data. Use TEXT. There is a limit to that but I have never come across it.
Second, if you have the ID's to auto increase, then if you delete 3 through 15, 16 will be next inline. It does not go to the next number in line unless the next number in line wasen't used yet. If you want to number your fields, just do something like this: $i++; echo "News id: ".$i." News Title etc"; all in your while() loop. |
<a href=\"print.php?newsid=$myrow[id]\" target=\"_blank\">$myrow[title]</a>
<? //print.php?newsid= $realid=$id; $query=mysql_query"SELECT * FROM blabla WHERE id='$realid'"; while($myrow=mysql_fetch_array($query)){ echo"story"; } ?> |
^^ above is me
|
ooooook, cheers, i'll try that!
|
well that was no good lol :p
i probably cant understand it right.. but o well this is the code i have for delnews.php: <head><title>Delete News</title></head> <? mysql_connect(localhost,DB_NAME,DB_PASS); mysql_select_db(DB_NAME); $result = mysql_query("SELECT * FROM news order by id DESC LIMIT 7"); while ($row = mysql_fetch_array($result)) { $title = $row["title"]; $date = $row["date"]; echo "<ul><li><b>$title</b> - $date</li></ul>"; ++$i; } if(mysql_num_rows($result) == 0) { echo "<strong>There are currently no news articles in the database!</strong>"; } ?> <a href="./print.php?newsid=$myrow[id]" target="_blank">$myrow[title]</a> how can i get an option next to all of them saying - Delete? then by pressing this "link" deleting the item you pressed? |
carelessrabbit@hotmail.com for more help :p
1st of all ditch the my_row stuff :p
use:: mysql_connect(localhost,$username,$password); @mysql_select_db($database) or die( "Unable to select database"); $query("SELECT * FROM news order by id DESC LIMIT 7"); $result = mysql_query($query) or die (mysql_error()); $num = mysql_num_rows($result); mysql_close(); $i=0; while ($i < $num) { $title=mysql_result($result,$i,"title"); $date=mysql_result($result,$i,"date"); WHATEVER $i++; } } if(mysql_num_rows($result) == 0) { echo "<strong>There are currently no news articles in the database!</strong>"; } ?> just i hate using your method of SQL grabbin :D |
All times are GMT -5. The time now is 05:25 PM. |
Powered by vBulletin®