SourceTec Software

It is currently Fri Apr 25, 2014 1:17 am

All times are UTC + 8 hours




Post new topic Reply to topic  [ 13 posts ] 
Author Message
 Post subject: PHP MySQl Dynamic News
PostPosted: Mon Nov 23, 2009 1:21 am 
Offline
Member

Joined: Wed Nov 04, 2009 9:19 pm
Posts: 2
PHP MySQl Dynamic News


Hello,


I am trying to accomplish a dynamic news scroller with PHP + MySql. I have gone through the sample lesson provided elsewhere in the SourceTec site. I have to say that it was not that useful to me, as I am a beginner. I was able to successfully connect the scroller to the database, but, the news is not looping. It just shows the first record. I persume that the part that deals with the loop is
[code]<?php
$myFile = file("sc.txt");
for($index = 0; $index < count($myFile); $index++)
{
list($iid,$sImage,$sDesc,$sName,$sLink)=split("\|",preg_replace("/[\r\n]/","",$myFile[$index]));
?>[/code]
Am I correct?

Is there any working example with MySql, than a text file?
Thanks for any help


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 23, 2009 3:58 pm 
Offline
Member

Joined: Mon Nov 23, 2009 3:55 pm
Posts: 2
I have met such kind of problem before!

I suggest you to hire one person for this task!


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jan 06, 2010 10:20 pm 
Offline
Member

Joined: Tue Jan 05, 2010 9:44 pm
Posts: 4
OK there are that many of these threads now it's silly.

For anyone that wants to retrieve data from a MySQL database using PHP rather than reading in from a text file.

The example here is using a customer html image/text scroller, feel free to adapt to your usage, the database code will be the same regardless.

In your prefix add the following code

Code:
/*
<?php
$dbhost = "[your host]"; // DB Host name
$dbusername = "[your database Username]"; // DB User
$dbpass = "[your database password]"; // DB User password
$dbname = "[your databasename]"; // DB Name
$query = "select * from [add your tablename here]";
$connection = mysql_connect($dbhost, $dbusername, $dbpass);
$resultCat = mysql_db_query($dbname, $query);
$numrowsCat = mysql_num_rows($resultCat);

for ($i = 0; $i < $numrowsCat; $i++)
{
     $rowCat = mysql_fetch_array($resultCat);

$ImageID=$rowCat["ImageID"];
$Image_name=$rowCat["Image_name"];
$Image_d=$rowCat["Image_description"];
$Image_url=$rowCat["Image_url"];
$Image_path=$rowCat["Image_path"];
?>
*/


In the Suffix add this code
Code:
/*
<?php   
}
?>
*/


***Remember to change the dbhost, dbusername,dbpass, dbname to your settings.

***Also change the line below to reflect your tablename.
Code:
$query = "select * from [add your tablename here]";


Under the item tab refer to your database fields like this:

For the image use <?php echo($Image_path)?>
For the Description use <?php echo $Image_d?>
and so on etc etc etc.....

Hope this helps. Here's the output of the js file for any who maybe interested,

Code:
sts_bs("",[20080623,"images/","","blank.gif",5,1,1,4,"430px","center",1,1,440,155,1,0,0,0,0,6000,1,24,2,"progid:DXImageTransform.Microsoft.RandomDissolve(,enabled=0,Duration=0.60)",12,50],["none",1,"#9FB8CE","#1a1a1a","","repeat"]);
sts_sca(["right","middle","left","middle"],["arrow05_lt.gif","arrow05_lv.gif","arrow05_ld.gif",24,25,"arrow05_rt.gif","arrow05_rv.gif","arrow05_rd.gif",24,25]);
sts_sbd([1],["solid",1,"#4377A6",10,"border05_tl.gif","border05_tr.gif","border05_br.gif","border05_bl.gif","transparent","border05_t.gif","repeat","transparent","border05_r.gif","repeat","transparent","border05_b.gif","repeat","transparent","border05_l.gif","repeat"]);
/*
<?php
$dbhost = "localhost"; // DB Host name
$dbusername = "*****"; // DB User
$dbpass = "*****"; // DB User password
$dbname = "*****"; // DB Name
$query = "select * from ClientDetails";
$connection = mysql_connect($dbhost, $dbusername, $dbpass);
$resultCat = mysql_db_query($dbname, $query);
$numrowsCat = mysql_num_rows($resultCat);

for ($i = 0; $i < $numrowsCat; $i++)
{
     $rowCat = mysql_fetch_array($resultCat);

$ImageID=$rowCat["ImageID"];
$Image_name=$rowCat["Image_name"];
$Image_d=$rowCat["Image_description"];
$Image_url=$rowCat["Image_url"];
$Image_path=$rowCat["Image_path"];
?>
*/
sts_ai("i0",[1,"<style type=\"text/css\">\r\n<!--\r\n.STYLE10 {\r\n   font-weight: bold;\r\n}\r\n-->\r\n</style>\r\n<table width=\"430\" height=\"104\" cellpadding=\"5\" cellspacing=\"0\" style=\"font-size:11px; font-family:Verdana; margin:10px; color: #98CB3E;\">\r\n  <tr>\r\n    <td width=\"33\" rowspan=\"2\" align=\"center\" valign=\"middle\" class=\"STYLE10\"><img src=\"../2010/client_logos/<?=$Image_path?>\" alt=\"\" name=\"Image\" id=\"Image\" /></td>\r\n    <td width=\"530\" height=\"28\" align=\"left\" class=\"STYLE10\"><span style=\"font-size: 14px\"></span><?php echo($Image_name)?><span style=\"text-align: left\"></span></td>\r\n  </tr>\r\n  <tr>\r\n    <td align=\"left\" valign=\"top\" style=\"color: #FFF\"><?php echo($Image_d)?></td>\r\n  </tr>\r\n</table>","<?php echo($Image_url)?>","_self","",0,0,"center"],["transparent","9pt Verdana,Arial","#FFFFFF","none","9pt Verdana,Arial","#FFFFFF","none"]);
sts_tip("i0",[1,"<?php echo(Image_d)?>","stEffect(\"rect\")","",75,0,0,-545,"bottom","center",460,360],["9pt Verdana,Arial","#4377A6","none","#000000","","no-repeat"]);
/*
<?php   
}
?>
*/
sts_es();

I have also attached a working project example for anyone who learn better by example.


You do not have the required permissions to view the files attached to this post.


Top
 Profile  
 
 Post subject: Solution
PostPosted: Wed Jan 06, 2010 10:24 pm 
Offline
Member

Joined: Tue Jan 05, 2010 9:44 pm
Posts: 4
Anyone that needs the MySQL database run this code

Code:
CREATE TABLE IF NOT EXISTS `ClientDetails` (
  `ImageID` int(3) NOT NULL auto_increment,
  `Image_name` varchar(255) NOT NULL,
  `Image_description` longtext NOT NULL,
  `Image_url` varchar(255) default NULL,
  `Image_path` varchar(255) NOT NULL,
  PRIMARY KEY  (`ImageID`)
) ENGINE=MyISAM  DEFAULT CHARSET=latin1 AUTO_INCREMENT=6 ;


Top
 Profile  
 
 Post subject:
PostPosted: Sat Jan 09, 2010 7:04 pm 
Offline
Member

Joined: Sat Jan 09, 2010 7:02 pm
Posts: 1
Nice one


Top
 Profile  
 
PostPosted: Fri Jun 04, 2010 3:03 am 
Offline
Member

Joined: Thu Jun 03, 2010 5:55 pm
Posts: 1
Yet another example that does not. As for the example that you can dowoload from sourcetec does not work!!!! I have on thing to say WHAT A LOAD OF RUBBISH. ps the download link comes up with an error when trying to unzip>>>>>>>>>>>>>>> :oops: :oops: :oops:


Top
 Profile  
 
PostPosted: Tue Jun 08, 2010 6:20 pm 
Offline
Member

Joined: Tue Jan 05, 2010 9:44 pm
Posts: 4
[quote="bhozar"]Yet another example that does not. As for the example that you can dowoload from sourcetec does not work!!!! I have on thing to say WHAT A LOAD OF RUBBISH. ps the download link comes up with an error when trying to unzip>>>>>>>>>>>>>>> :oops: :oops: :oops:[/quote]

Try reading all the post instructions prior to posting, I clearly state to rename the zip archive to .sjc in order to load the sample. I simply named it to .zip so i could attach it.

The attached instructions work 100% if you care to take the time to learn basic php and MySQL


Top
 Profile  
 
PostPosted: Sun Jul 04, 2010 8:49 am 
Offline
Member

Joined: Wed Dec 02, 2009 1:20 pm
Posts: 11
Location: Los Angeles, CA
JaffaDave, Thank you for the SQL code. I am going to try it out. I have requested so much help for this and wrote tickets and what not, nothing really happened with SourceTec... There are so many flawed tutorials and I just don't understand why they don't just fix them. The code downloaded for:

http://www.sothink.com/product/javascri ... /phpdb.htm

seems to be flawed. The example doesn't even work from the source code. A long time ago I made it work - but forgot what I did and now can't seem to get back to where I was. All in all I agree, this is Silly that the software tutorials and support should be this bad.

Thanks though for the code, it is much appreciated.

Brian


Top
 Profile  
 
PostPosted: Mon Jul 05, 2010 10:39 am 
Offline
Member

Joined: Tue Jan 05, 2010 9:44 pm
Posts: 4
[quote="Relative0"]JaffaDave, Thank you for the SQL code. I am going to try it out. I have requested so much help for this and wrote tickets and what not, nothing really happened with SourceTec... There are so many flawed tutorials and I just don't understand why they don't just fix them. The code downloaded for:

http://www.sothink.com/product/javascri ... /phpdb.htm

seems to be flawed. The example doesn't even work from the source code. A long time ago I made it work - but forgot what I did and now can't seem to get back to where I was. All in all I agree, this is Silly that the software tutorials and support should be this bad.

Thanks though for the code, it is much appreciated.

Brian[/quote]

When the software outputs the javascript filename say scroller.js make sure to rename it scroller.js.php after the file has been created if using PHP/MySQl else it just won't work. Also rename your script file in the page to match!


Top
 Profile  
 
PostPosted: Tue Aug 31, 2010 12:40 am 
Offline
Member

Joined: Wed Dec 02, 2009 1:20 pm
Posts: 11
Location: Los Angeles, CA
Ok..... I am having quite a difficult time here and I can not figure out what I am doing wrong..... If anyone could help it would be very much appreciated.

First it looks like I am generating the whole of the Database file (that I made form the forum thread here and added a few items such as image names etc.). The Database file is attached. Furthermore the scroller that I am trying to use is attached also. Looks like the /js, the /images and the scroll_js.php are all correct, even more so it looks like stuff is getting taken from the database as it is appearing in the code below. The only problem is that nothing visible to the user including the menu itself!

[code]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<script type="text/javascript" src="js/stscode.js"></script>
</head>

<body>
<span><a href="http://www.dhtml-menu-builder.com" style="display:none;visibility:hidden;">Javascript DHTML Image Web Scroller Powered by dhtml-menu-builder.com</a>
<script id="sothink_widgets:dwwidget_webscroll7_30_2010_2.sjc" type="text/javascript">
<!--
sts_bs("",[20080623,"images/","","blank.gif",5,1,1,4,"500px","center",1,1,500,155,1,0,0,0,0,3000,1,24,2,"progid:DXImageTransform.Microsoft.RandomDissolve(,enabled=0,Duration=0.60)",12,50],["none",1,"#9FB8CE","#141212","006.gif","repeat"]);
sts_sca(["right","middle","left","middle"],["arrow02_lt.gif","arrow02_lv.gif","arrow02_ld.gif",20,20,"arrow02_rt.gif","arrow02_rv.gif","arrow02_rd.gif",20,20]);
sts_tbd([1],["solid",1,"#000066",5,"border03_tl[1].gif","border03_tr[1].gif","border03_br[1].gif","border03_bl[1].gif","transparent","border03_t[1].gif","repeat","transparent","border03_r[1].gif","repeat","transparent","border03_b[1].gif","repeat","transparent","border03_l[1].gif","repeat"]);
/*
<br />
<b>Deprecated</b>: mysql_db_query() [<a href='function.mysql-db-query'>function.mysql-db-query</a>]: This function is deprecated; use mysql_query() instead in <b>C:\Users\Steve\Desktop\Freelance\Tracy\Dev\Code\Menus\Iphonedb\Test.php</b> on line <b>22</b><br />
*/
sts_ai("i0",[1,"<table width=\"300\" height=\"150\" cellpadding=\"5\" cellspacing=\"0\" style=\"font-size:11px; font-family:Verdana; margin:10px;\">\r\n <tr>\r\n <td width=\"91\" align=\"center\" valign=\"middle\" class=\"STYLE10\"><img src=\"somepath\" alt=\"\" name=\"Image\" id=\"Image\" /></td>\r\n <td width=\"300\" class=\"STYLE10\">Hey This is a description!</td>\r\n </tr>\r\n</table>","www.csupomona.edu","_self","",0,0,"center"],["transparent","9pt Verdana,Arial","#FFFFFF","none","9pt Verdana,Arial","#FFFFFF","none"]);
sts_tip("i0",[1,"<br />
<b>Notice</b>: Use of undefined constant Image_d - assumed 'Image_d' in <b>C:\Users\Steve\Desktop\Freelance\Tracy\Dev\Code\Menus\Iphonedb\Test.php</b> on line <b>37</b><br />
Image_d","stEffect(\"rect\")","",75,0,0,-545,"bottom","center",460,360],["9pt Verdana,Arial","#4377A6","none","#000000","","no-repeat"]);
/*
*/
sts_ai("i0",[1,"<table width=\"300\" height=\"150\" cellpadding=\"5\" cellspacing=\"0\" style=\"font-size:11px; font-family:Verdana; margin:10px;\">\r\n <tr>\r\n <td width=\"91\" align=\"center\" valign=\"middle\" class=\"STYLE10\"><img src=\"The path to the stars!\" alt=\"\" name=\"Image\" id=\"Image\" /></td>\r\n <td width=\"300\" class=\"STYLE10\">some more stuff</td>\r\n </tr>\r\n</table>","www.jpl.nasa.gov","_self","",0,0,"center"],["transparent","9pt Verdana,Arial","#FFFFFF","none","9pt Verdana,Arial","#FFFFFF","none"]);
sts_tip("i0",[1,"<br />
<b>Notice</b>: Use of undefined constant Image_d - assumed 'Image_d' in <b>C:\Users\Steve\Desktop\Freelance\Tracy\Dev\Code\Menus\Iphonedb\Test.php</b> on line <b>37</b><br />
Image_d","stEffect(\"rect\")","",75,0,0,-545,"bottom","center",460,360],["9pt Verdana,Arial","#4377A6","none","#000000","","no-repeat"]);
/*
*/
sts_es();
//-->
</script>
</span>
</body>
</html>

[/code]


Top
 Profile  
 
PostPosted: Sat Oct 02, 2010 5:48 pm 
Offline
Member

Joined: Sat Oct 02, 2010 5:41 pm
Posts: 2
Here is a working code , check out the result at http://www.fine-jewelry-stores.net


Last edited by omniblogs on Tue Oct 19, 2010 2:02 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Sat Oct 02, 2010 9:31 pm 
Offline
Member

Joined: Sat Oct 02, 2010 5:41 pm
Posts: 2
[quote="dijenga"]Very nice job.

There is a missing image though . . . but still, very nice![/quote]

The missing image comes from the datafeed the vendors sometime have broken links . Thanks for the comment.


Top
 Profile  
 
PostPosted: Mon Aug 15, 2011 5:25 pm 
Offline
Member

Joined: Mon Aug 15, 2011 5:22 pm
Posts: 2
[quote="omniblogs"]Here is a working code , check out the result at http://www.fine-jewelry-stores.net[/quote]
there's no code at all


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 13 posts ] 

All times are UTC + 8 hours


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group