Forum Moderators: coopster
mysql_select_db($database_conn, $conn);
$query_Recordset1 = "SELECT sb_img, title_link, url FROM news ORDER BY id DESC";
Or if the article is in a separate file named eg. "news1.txt", "news5.txt", where 1, 5 is the id from database, then
mysql_select_db($database_conn, $conn);
$query_Recordset1 = "SELECT sb_img, title_link, id FROM news ORDER BY id DESC";
//$result = ask mysql
$filename = "news".$result[2].".txt";
However I would opt for storing the url in the database.
best regards Butterfly!
Michal Cibor
Ok ummm what i wanted was how to give different hyperlinks to that news table since its a repeting region + only one recordset.
I just dont know how... well i did manage to givb hypoerlink to one table that i newly update and its working fine . what abt the old data , can i give hyperlink..
Plz suggest me the best way to give hyperlinks to different titles of news .
thanks
As I recall this is your table:
CREATE TABLE `news` (
`id` int(10) unsigned NOT NULL auto_increment,
`extr_frm` varchar(100) NOT NULL default '',
`sb_img` varchar(100) NOT NULL default '',
`title_link` varchar(100) NOT NULL default '',
`cont` longtext NOT NULL,
PRIMARY KEY (`id`)
) TYPE=MyISAM AUTO_INCREMENT=28 ;
I presume that title_link is not a hyperlink url, but just name?
If so, then add here another column, eg. url, where you can place the desired url to the news.
If the whole news is written in the field 'cont' then the url is easier, cause you past the id into the $_GET:
(Example with news text in 'cont' field)
#index.html
<?PHP
$id = (int)$_GET["id"];if($id)
{
$sql = "SELECT extr_frm, sb_img, title_link, cont FROM news WHERE id = '$id'";
//ask the database
//print the news
}
else
{
//get the article list
?>
<body>
<table width="280" border="1" cellspacing="0">
<?php do {?>
<tr>
<td width="62"><?php echo $row_Recordset1['sb_img'];?></td>
<td width="208"><a href="index.html?id=<?echo $row_Recordset1['id'];?>"><?php echo $row_Recordset1['title_link'];?></a></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
If you can't do that, then place in the <a href desired url, but taken from the database, from the table news
Best wishes!
Michal Cibor
PS. Don't make a new table, because it's not worth it.
O u want me to add one more row named "Url" so i have to give url here for the tile .
any way let me try.
O and by the way , do u have any idea abt screen resolution. I am designing a web on my 17inch monitor, so what happens is when i view it in 800/600 screen monitor. The whole design looks horible , text looks bigger just every thing loooks bigger.
How do i solve this problem. Thanks once again
Ops me again, i tried all i could make was a new url table which u have told me to make. After that am puzzled looking by ur coding.
Can u plz give a step by step how to implement it plz..as am very fresh into this developing part.
thanks
*********************************************
<?PHP
$id = (int)$_GET["id"];
if($id)
{
$sql = "SELECT extr_frm, sb_img, title_link, cont FROM news WHERE id = '$id'";
//ask the database
//print the news
}
else
{
//get the article list
?>
<body>
<table width="280" border="1" cellspacing="0">
<?php do {?>
<tr>
<td width="62"><?php echo $row_Recordset1['sb_img'];?></td>
<td width="208"><a href="index.html?id=<?echo $row_Recordset1['id'];?>"><?php echo $row_Recordset1['title_link'];?></a></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
***************************************************
First you need to add the column 'url' to the table news (column, not a new table).
To do that, in MySQL write:
ALTER TABLE news ADD url VARCHAR(100) DEFAULT 'index.html' AFTER title_link;
Then correct the rows by using command
UPDATE news SET url = 'here your desired url' WHERE id = '1';
To do that automatically, when you insert new data write:
INSERT INTO news(extr_frm, sb_img, title_link, url, cont) VALUES('$extr', '$img', '$title', '$url', '$cont');
Then the code (with explanation):
<?PHP
$id = (int)$_GET["id"]; //take the value of id from the clicked url
if($id)
{
$sql = "SELECT extr_frm, sb_img, title_link, url, cont FROM news WHERE id = '$id'"; // here you take all the relevant information from the database
//ask the database - the code to ask database
//print the news - code to print the news, eg. echo "<p>".$cont."</p>;
}
else //this is code if no article is selected
{
//get the article list
?>
<body>
<table width="280" border="1" cellspacing="0">
<?php do {?>
<tr>
<td width="62"><?php echo $row_Recordset1['sb_img'];?></td>
<td width="208"><a href="index.html?id=<?echo $row_Recordset1['id'];?>"><?php echo $row_Recordset1['title_link'];?></a></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>
This won't work straight away. I'm just giving out examples how to do this. However if you hold the whole news in database you can easily disregard using url. (I'm not sure what do you hold in the 'cont' field)
Best regards!
Michal Cibor
Well long time ago actually i did found one php script that automically sets the server configuration , when the clients views the poarticular site it gives them a resoulution of what has been coded in the php. i lost that script ....i did try to google search, i couldnt.
Rather the client making manual change in their resoulution (800/600) to view the good loking site , why not a php code that disply the resoulution of 17" monitor instead of changing the resoution.
Thanks ,
[edited by: eelixduppy at 8:07 pm (utc) on Feb. 18, 2009]