Forum Moderators: coopster

Message Too Old, No Replies

how to automatically display new data entered

         

Butterfly Wing

4:10 pm on Jan 9, 2005 (gmt 0)

10+ Year Member



People, I have a two column 1) Pic 2) content i use backend as MySql to store data and server coding PHP so very thing running somoothy.

But the problem is When i entry a new data into database, it never show a new entry level in the web. Al i can see is the old data level.

Well i made it using Dreamweaver MX built in PHP and MySql..

Some body plz hlp me .. if u dint get me what am saying plz let me know

mcibor

10:31 pm on Jan 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Do you eventually get that data written?

Have you checked mySQL if data is really there?

If so, then write the code for writing new data into mySQL and for getting it.

The question you asked has too many possible mistakes to really know what's happening!
Michal Cibor

Butterfly Wing

8:45 am on Jan 11, 2005 (gmt 0)

10+ Year Member



Do you eventually get that data written?
Have you checked mySQL if data is really there?

If so, then write the code for writing new data into mySQL and for getting it.

The question you asked has too many possible mistakes to really know what's happening!
Michal Cibor

Michal Cibor ,

Yes every thing is working fine, i can retrive data and put it in Mysql too but problem is i when i put new information into mysql its not updating in my page. All i can see is the old data in my web.. the new data i entered into mysql is very there.

for eg i got

1
2
3
4

so i added 5,6,7,8,9 into mysql after i insert a new data it shoud update the above one for eg

instead of 1,2,3,4 it should display

5,
6,
7,
8

any how did u got me .

mcibor

10:34 am on Jan 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes! I see the point.
Can you post here the code on how do you retrieve the data?
Does the new data appear eventually, eg next time you enter the page? If so the problem may lay with refreshing the view -> first you refresh, then insert data to mySQL?

I presume that you have a button <input type="submit" name="action" id="action" value="Change"/>
And then in PHP you write

<?PHP
if($_POST["action"] == "Change") my_insertData(); //refresh data in mySQL

my_retrieveData();// get data from mySQL and print them onto html
?>

And after one reload there is desired data (5,6,7,8) in mySQL? However not on the website?

Write the code. Otherwise it will still be too difficult to see what's wrong. Don't place your url, because it will be edited.
Michal Cibor

Butterfly Wing

3:27 pm on Jan 11, 2005 (gmt 0)

10+ Year Member



Friend ,

Below is my source code + database table. Its a simeple news that am trying to make some what like Yahoo "in the news" well plz have a look and u will understand more than i try to make u understand. Plz let me know what else u have added and how would u update this News table daily.

****************************************************

<?php
# FileName="Connection_php_mysql.htm"
# Type="MYSQL"
# HTTP="true"
$hostname_conn = "localhost";
$database_conn = "tol";
$username_conn = "root";
$password_conn = "";
$conn = mysql_pconnect($hostname_conn, $username_conn, $password_conn) or trigger_error(mysql_error(),E_USER_ERROR);
?>

<?php require_once('file:///C¦/web/tol.com/Connections/conn.php');?>
<?php
$maxRows_Recordset1 = 5;
$pageNum_Recordset1 = 0;
if (isset($_GET['pageNum_Recordset1'])) {
$pageNum_Recordset1 = $_GET['pageNum_Recordset1'];
}
$startRow_Recordset1 = $pageNum_Recordset1 * $maxRows_Recordset1;

mysql_select_db($database_conn, $conn);
$query_Recordset1 = "SELECT sb_img, title_link FROM news";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);
$Recordset1 = mysql_query($query_limit_Recordset1, $conn) or die(mysql_error());
$row_Recordset1 = mysql_fetch_assoc($Recordset1);

if (isset($_GET['totalRows_Recordset1'])) {
$totalRows_Recordset1 = $_GET['totalRows_Recordset1'];
} else {
$all_Recordset1 = mysql_query($query_Recordset1);
$totalRows_Recordset1 = mysql_num_rows($all_Recordset1);
}
$totalPages_Recordset1 = ceil($totalRows_Recordset1/$maxRows_Recordset1)-1;
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Untitled Document</title>
</head>

<body>
<table width="280" border="1" cellspacing="0">
<?php do {?>
<tr>
<td width="62"><?php echo $row_Recordset1['sb_img'];?></td>
<td width="208"><?php echo $row_Recordset1['title_link'];?></td>
</tr>
<?php } while ($row_Recordset1 = mysql_fetch_assoc($Recordset1));?>
</table>
</body>
</html>
<?php
mysql_free_result($Recordset1);
?>

***************************************************

#
# Table structure for table `news`
#

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 ;

[edited by: jatar_k at 5:32 pm (utc) on Jan. 11, 2005]
[edit reason] removed table dump [/edit]

mcibor

8:06 pm on Jan 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As I understand your problem, you want to show latest news first. Do to that simply correct the corresponding code and it should start to work:

mysql_select_db($database_conn, $conn);
$query_Recordset1 = "SELECT sb_img, title_link FROM news ORDER BY id DESC";
$query_limit_Recordset1 = sprintf("%s LIMIT %d, %d", $query_Recordset1, $startRow_Recordset1, $maxRows_Recordset1);

Best regards
Michal Cibor

PS. I understand, that in mySQL there is desired data.

Butterfly Wing

8:28 am on Jan 12, 2005 (gmt 0)

10+ Year Member



Michal,

Thank u so much all i have to do is "order by ID DESC" God i have been stuck in this so long thinking how to do that way.. now u helped me thanks a lot once agin for taking ur precious time.

Frend i got small samll thing to ask u in php ummm will post next time thanks.

Regards

Karma

mcibor

9:53 pm on Jan 12, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Post it, and we (on webmasterworld) will try to help:)

It's these small mistakes that make world happier. Imagine what would be Windows without a blue screen (or better come back to Earth:))

Have a nice writing PHP codes!
Best wishes
Michal Cibor