•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 422,996 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,935 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 2035 | Replies: 13
![]() |
•
•
Join Date: Jul 2006
Posts: 11
Reputation:
Rep Power: 3
Solved Threads: 0
Hi everyone!!
I need some help with setting up a php page that calls an sql database..
here is what I want it to do?
-firstly: a user must be able to log in(because under this login you must be able to get stats from this user)
Then the user has 3 options (links) for example:
clink chlink elink
when a user clicks a link it takes you to another page with 3 more links.
plink cnlink hlink
(these links takes you to a list of tpics.. same topics for each link)
now I guess what I want to do here is make a counter, so that it couts each time you click a specific link and adds it to a table:
for example
clink 26
chlink 23
elink 27
in a table on a web interface..
for me it gets tricky when each user under a seperate username, logging into the same database, should have unique results,,
so you can call.. how many times did jsmith click clink,, for example//
I use Apache server so I want to use php,, i actually like the language,, and I am using mysql for a database, should I need one in this project..
I think I am on the right track with this, what I have done is built a mysql database with the info above in it, and am calling the databse withphp, selecting the appropriate links above... it's just counting it !! no I am stuck!!
Please help ,, Thanks
I need some help with setting up a php page that calls an sql database..
here is what I want it to do?
-firstly: a user must be able to log in(because under this login you must be able to get stats from this user)
Then the user has 3 options (links) for example:
clink chlink elink
when a user clicks a link it takes you to another page with 3 more links.
plink cnlink hlink
(these links takes you to a list of tpics.. same topics for each link)
now I guess what I want to do here is make a counter, so that it couts each time you click a specific link and adds it to a table:
for example
clink 26
chlink 23
elink 27
in a table on a web interface..
for me it gets tricky when each user under a seperate username, logging into the same database, should have unique results,,
so you can call.. how many times did jsmith click clink,, for example//
I use Apache server so I want to use php,, i actually like the language,, and I am using mysql for a database, should I need one in this project..
I think I am on the right track with this, what I have done is built a mysql database with the info above in it, and am calling the databse withphp, selecting the appropriate links above... it's just counting it !! no I am stuck!!
Please help ,, Thanks
•
•
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation:
Rep Power: 4
Solved Threads: 6
You can create a table which contains username and names of all the 9 links (3x3). When the user login, the counter only update the number of click of this user, not others. For example:
[php]UPDATE table SET clink = clink+1, cnlink = cnlink+1 WHERE username = '$user'[/php]
Using a simple math, you can also sum up all the clicks you get for one particular link, and % of all clicks etc.
[php]UPDATE table SET clink = clink+1, cnlink = cnlink+1 WHERE username = '$user'[/php]
Using a simple math, you can also sum up all the clicks you get for one particular link, and % of all clicks etc.
Ecommerce-Web-Store.com Building Your e-Business.
•
•
Join Date: Jul 2006
Posts: 11
Reputation:
Rep Power: 3
Solved Threads: 0
Zippee!!
your help was greatly appreciated, however you suggested I make a table with username and name of links.
When I started getting down to this, I started making tables, and just confused myself all over again...(I only started using mysql and php about 3 days ago, so please bear with me)... I learn pretty quick.
this is what I started: a table with all usernames and passwords. so I could make a login page, when the user logs in, the first step must start example:
clink chlink elink (this is in a table of course)
are you suggesting that I insert the above links/all the links under each user name? and then selecting what I want to see on each page?
like:
+-------------+
-USER1
+-------------+
your help was greatly appreciated, however you suggested I make a table with username and name of links.
When I started getting down to this, I started making tables, and just confused myself all over again...(I only started using mysql and php about 3 days ago, so please bear with me)... I learn pretty quick.
this is what I started: a table with all usernames and passwords. so I could make a login page, when the user logs in, the first step must start example:
clink chlink elink (this is in a table of course)
are you suggesting that I insert the above links/all the links under each user name? and then selecting what I want to see on each page?
like:
+-------------+
-USER1
+-------------+
•
•
Join Date: Jul 2004
Location: North East Indiana
Posts: 491
Reputation:
Rep Power: 5
Solved Threads: 20
Create another table with the username and the stats you want to keep. You'll then have two tables:
[Users]
Username
Password
[Stats]
Username (Foreign key* to Users.Username)
LinkA
LinkB
LinkC
LinkD
[* A foreign key requires the data in that field to be unique and linked to another field in another table. It makes sure you don't have stats for Joe User while Joe User doesn't exist in your users table, for example.]
[Users]
Username
Password
[Stats]
Username (Foreign key* to Users.Username)
LinkA
LinkB
LinkC
LinkD
[* A foreign key requires the data in that field to be unique and linked to another field in another table. It makes sure you don't have stats for Joe User while Joe User doesn't exist in your users table, for example.]
www.uncreativelabs.net
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
Old computers are getting to be a lost art. Here at Uncreative Labs, we still enjoy using the old computers. Sometimes we want to see how far a particular system can go, other times we use a stock system to remind ourselves of what we once had.
•
•
Join Date: Jul 2006
Posts: 11
Reputation:
Rep Power: 3
Solved Threads: 0
Thanks for the response, I will work on thsi right away.. however I am stuck with something again, I will paste the code here.. firstly some details:
there are 3 webpages involved here:
page 1
linkA ID = 1
linkB ID = 2
linkC ID = 3
page 2 (every link on page one takes you to this page below, thats why each one has an ID:
linkX ID=1
linkY ID=2
linkZ ID=3
Page 3 (all the links from page 2 takes you here)
link1
link2
link3
link4
link5
etc...
the result should be:
EXAMPLE
how many link2's of linkY from linkB have been clicked?
so you would get:
today, user1
linkX
------
linkA linkB linkC
link1 3
link2 5
link3 3
link4 1 3
etc...
linkY
-----
etc,, same until linkZ(so 3 tables with results for link X, Y and Z)
My fistp page liiks like this:
actions.php
[php]<?
$database = "strokesheet";
$user = "odbc";
$pass = "";
$hostname = "localhost";
mysql_connect ( $hostname, $user, $pass)or die("Could not connect: ".mysql_error());
mysql_select_db($database) or die(mysql_error());
$results = mysql_query("select * from actions");
$numrows = mysql_num_rows($results);
for ($i=0 ;$i<$numrows; $i++)
{
$row = mysql_fetch_array($results);
echo("<p><a href=\"companies.php?actionid=");
echo($row["actionID"]);
echo("\">");
echo($row["actionName"]);
echo("</a></p>");
}
?>[/php]
this page is perfect!!
the next page:
companies.php
[php]<?
$database = "strokesheet";
$user = "odbc";
$pass = "";
$hostname = "localhost";
mysql_connect ( $hostname, $user, $pass)or die("Could not connect: ".mysql_error());
mysql_select_db($database) or die(mysql_error());
$results = mysql_query("select * from companies");
//assume company 1
//<table>
//loop through topics
// <tr><td>$topicname</td>
//loop though actions
//select count(*) as num from strokes where actionid = x and topicid = y and companyid = 1
//<td>$num</td>
//end loop actions
//</tr>
//end loop topics
//</table>
$numrows = mysql_num_rows($results);
for ($i=0 ;$i<$numrows; $i++)
{
$row = mysql_fetch_array($results);
echo("<p><a href=\"topics.php?actionid=");
echo($actionid);
echo("&companyid=");
echo($row["companyID"]);
echo("\">");
echo($row["companyName"]);
echo("</a></p>");
}
?>[/php]
HERE IS THE PROBLEM: FINALY!!!
because I want each company ID to correspnd to actionID etc, eventually topcID...
I want to see in the url: http://blablablablabla//something?ac...=1&companyid=2 for EXAMPLE.
on page 2 above it doesnt want to work, and gives me a long explanation in the address bar(can't remeber now)
whats wrong with the code on page 2, is my question
hint: I think it has something to do with this variable i'm calling from page1: is this syntax correct?
echo($actionid);
THANKS A MILLION!!!!! any help with this project will be appreciated..
there are 3 webpages involved here:
page 1
linkA ID = 1
linkB ID = 2
linkC ID = 3
page 2 (every link on page one takes you to this page below, thats why each one has an ID:
linkX ID=1
linkY ID=2
linkZ ID=3
Page 3 (all the links from page 2 takes you here)
link1
link2
link3
link4
link5
etc...
the result should be:
EXAMPLE
how many link2's of linkY from linkB have been clicked?
so you would get:
today, user1
linkX
------
linkA linkB linkC
link1 3
link2 5
link3 3
link4 1 3
etc...
linkY
-----
etc,, same until linkZ(so 3 tables with results for link X, Y and Z)
My fistp page liiks like this:
actions.php
[php]<?
$database = "strokesheet";
$user = "odbc";
$pass = "";
$hostname = "localhost";
mysql_connect ( $hostname, $user, $pass)or die("Could not connect: ".mysql_error());
mysql_select_db($database) or die(mysql_error());
$results = mysql_query("select * from actions");
$numrows = mysql_num_rows($results);
for ($i=0 ;$i<$numrows; $i++)
{
$row = mysql_fetch_array($results);
echo("<p><a href=\"companies.php?actionid=");
echo($row["actionID"]);
echo("\">");
echo($row["actionName"]);
echo("</a></p>");
}
?>[/php]
this page is perfect!!
the next page:
companies.php
[php]<?
$database = "strokesheet";
$user = "odbc";
$pass = "";
$hostname = "localhost";
mysql_connect ( $hostname, $user, $pass)or die("Could not connect: ".mysql_error());
mysql_select_db($database) or die(mysql_error());
$results = mysql_query("select * from companies");
//assume company 1
//<table>
//loop through topics
// <tr><td>$topicname</td>
//loop though actions
//select count(*) as num from strokes where actionid = x and topicid = y and companyid = 1
//<td>$num</td>
//end loop actions
//</tr>
//end loop topics
//</table>
$numrows = mysql_num_rows($results);
for ($i=0 ;$i<$numrows; $i++)
{
$row = mysql_fetch_array($results);
echo("<p><a href=\"topics.php?actionid=");
echo($actionid);
echo("&companyid=");
echo($row["companyID"]);
echo("\">");
echo($row["companyName"]);
echo("</a></p>");
}
?>[/php]
HERE IS THE PROBLEM: FINALY!!!
because I want each company ID to correspnd to actionID etc, eventually topcID...
I want to see in the url: http://blablablablabla//something?ac...=1&companyid=2 for EXAMPLE.
on page 2 above it doesnt want to work, and gives me a long explanation in the address bar(can't remeber now)
whats wrong with the code on page 2, is my question
hint: I think it has something to do with this variable i'm calling from page1: is this syntax correct?
echo($actionid);
THANKS A MILLION!!!!! any help with this project will be appreciated..
Last edited by cscgal : Jul 17th, 2006 at 7:53 pm.
•
•
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation:
Rep Power: 4
Solved Threads: 6
It would be useful to check the source code for each page, for example in your action.php page, make sure the link created is correspond to the action id you post from one page to another. You SQL query may have to change to select * FROM companies WHERE actionID = '$actionID'. It would be very useful if you paste the error message here so myself or someone could comment on it.
Last edited by zippee : Jul 12th, 2006 at 11:08 am.
Ecommerce-Web-Store.com Building Your e-Business.
•
•
Join Date: Jul 2006
Posts: 11
Reputation:
Rep Power: 3
Solved Threads: 0
here is the error I got in the in address bar after I click on
http://localhost/phpmysql/topics.php.../>&companyid=1
after I click on linkX ID=1 for example,, on page two.. like I said, if I remove, echo($actionid) ; it goes away, but I cannot follow the ID's from the previous page if I do this. please help ,, thanks alot.
http://localhost/phpmysql/topics.php.../>&companyid=1
after I click on linkX ID=1 for example,, on page two.. like I said, if I remove, echo($actionid) ; it goes away, but I cannot follow the ID's from the previous page if I do this. please help ,, thanks alot.
•
•
Join Date: Jan 2005
Location: Sheffield, UK
Posts: 294
Reputation:
Rep Power: 4
Solved Threads: 6
No one can see your localhost... But the text appear in the link did showed that you have problem in line 46 (?) or more precisely is you did not define $actionid in your program. If the value is post from previous page, the use $_GET or $_POST to retrieve it.
Last edited by zippee : Jul 18th, 2006 at 4:55 pm.
Ecommerce-Web-Store.com Building Your e-Business.
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Genuis PHP/Mysql programmers and Awesome Designers! (Web Development Job Offers)
- PHP and MySQL Web Development (PHP)
- master database with php mysql (Legacy and Other Languages)
- Flash Poll System using php/mysql for free (Graphics and Multimedia)
- PHP/MySQL programmer available (Post your Resume)
- Integrating Apache with PHP and MySQL (Linux Servers and Apache)
- Using PHP, MySQL and Apache Server (PHP)
Other Threads in the PHP Forum
- Previous Thread: Fck editer need help
- Next Thread: browse directory window


Linear Mode