PDA

View Full Version : PHP/Mysql Statements


sajid
05-02-03, 10:07 AM
Salams all

any php/mysql pros in here

ive got 2 questions

im creating this database on php/mysql

i have a table called product Detains and the fields in them i have are:

prod id,prod description,link,status,effective from,effective to,

i want to do the following:

1- on the right hand side of the website i want to display the top 10 products that have been clicked/accessed.. how wud i do that? do i need an extra field?

2)Link is the website url link..what happens is that when i insert say "www.google.com" in the database when the data is displayed on the Website the link is not clickable..how do i get around this?

jkk
ws
sajid

seven
05-02-03, 10:33 AM
1- you'd need an extra field 'counter' to count the hits

2- .... i forgot :scratch:

sajid
05-02-03, 11:53 AM
got the answer to number 2:

<td><a href="<?php echo $row_Recordset1 ['link']; ?>" target="_blank">Link</a></font></td>


still searching for number 1 :O

baba
05-02-03, 02:36 PM
As Seven said, create an extra LARGEINT (hey, you gotta prepare to get big hits!) field called "counter" or similar. Get the view script to add 1 to the number in the counter field (via an UPDATE query) every time the page is viewed.

If you give me access to your scripts then I could do it for you.

sajid
05-02-03, 02:54 PM
i dont have a largeint in the Field typ..

im using phpmyadmin i have bigint is this the same?

s

baba
05-02-03, 02:54 PM
Ah yes, it must be BIGINT then.

sajid
05-02-03, 02:56 PM
yup got that...

where do i go from there :confused: :confused:

ill give u the phpadmin access if u want..

btw..u logged off ,msn?

ive lost ya!

s

sajid
10-02-03, 09:04 AM
dont worry i already got it working


processor.php

<?php

//again, connect info

//update the table

$counter_query = "UPDATE prod_details SET counter=counter+1 WHERE product_id='$id'";
$result1 = mysql_query($counter_query) or die(mysql_error());

//this is where you get the link from the database

$get_link = "SELECT * FROM prod_details WHERE product_id = $id";
$result2 = mysql_query($get_link) or die(mysql_error());
$row_get_link = mysql_fetch_assoc($result2);

//I put array variables into flat variables for clarity when using them
//in functions. in this case, $destination_url is assigned the value
//of the current row's link column in order to use it in the header() function
//which performs the redirect.

$destination_url = $row_get_link['link'];

header("Location: $destination_url");

?>