Alexhoward Posted March 10, 2008 Share Posted March 10, 2008 Hello everybody! (Dr. nick) I’m attempting to build a rather complicated website, and have a limited knowledge of php. Saying that, I’ve come a long way from when I stated… Here's where I'm stuck: What I’d like to do is have a page of links, For example. This displays a link for ebay <a href="http://rover.ebay.com/rover/1/710-5232-2978-17/1?aid=5826369&pid=2804964&id=12" target="_blank" onmouseover="window.status='http://www.ebay.co.uk';return true;" onmouseout="window.status=' ';return true;"><img src="http://www.lduhtrp.net/image-2804964-5826369" width="120" height="60" alt="Click Here to shop at eBay.co.uk" border="0"/></a> Sorry, it's shown the link and i don't know how to show it just as the text...?! Then I’d like people to be able to choose this link and it will add it to their own login page (dynamically not a separate url) I’ve managed to drag the link out of the table via the username from a cookie and display the link of their page. But directly and not how I’d like However… This is how I’d like it work – Select link, this will save into a table – username, link_id, lets call it “memberslinks” Table of links = link_id, link, call this one “links” (this Is where I’ll save all the links) Next pull the link out of the table and display on page Something like: //$mysite_username is the username cookie $test = @mysql_query("select link_id FROM memberslinks WHERE member ='$mysite_username'"); $result = @mysql_query("select link FROM links WHERE member ='$test'"); Display the links in a nice little 9 x 9 grid, with paging script (?) Hope this is enough to explain what I’m up to Thanks in advance Alex Howard Quote Link to comment https://forums.phpfreaks.com/topic/95353-user-content-from-sql-table-igoogle-type-thing/ Share on other sites More sharing options...
Alexhoward Posted March 10, 2008 Author Share Posted March 10, 2008 Also, just to add. Doing it directly, so have a table with username, link i can pull an array and show all the results all at once (not in a nice grid however, just row by row) but doing the lookup between tables i can't anyone know a way round all this Thanks alot! ALex Howard Quote Link to comment https://forums.phpfreaks.com/topic/95353-user-content-from-sql-table-igoogle-type-thing/#findComment-488363 Share on other sites More sharing options...
trq Posted March 10, 2008 Share Posted March 10, 2008 It explains where you up too, but not where your stuck. What is your actual question? Quote Link to comment https://forums.phpfreaks.com/topic/95353-user-content-from-sql-table-igoogle-type-thing/#findComment-488364 Share on other sites More sharing options...
Alexhoward Posted March 10, 2008 Author Share Posted March 10, 2008 Hi Thorpe. Apologies... it's quite hard to expain.... say there was two tables 1. Username, link_id. and it had johnsmith, 1 then. 2. link_id, link. and it had 1, www.phpfreaks.com i could use the previous example to pull this link out of the two tables and display it on the page. however it would only show one, and not all using array... secondly, i'm unsure how to display the array as a nice grid on the page. i kind of want it to work as igoogle does with adding links (don't need to pull them about thou) and be arranged as www.gamershood.com is does this make it any clearer...? Thanks again Alex Howard Quote Link to comment https://forums.phpfreaks.com/topic/95353-user-content-from-sql-table-igoogle-type-thing/#findComment-488375 Share on other sites More sharing options...
Alexhoward Posted March 11, 2008 Author Share Posted March 11, 2008 Hi, I've got a little further and now i'm stuck again I've used some code that i found here, and adapted it to meet the needs of my site The problem is that the submit button does not work properly, and the username cookie and link are not inserted into the table. there are 2 pages used to acheive this, although i'd rather it just did it when you hit the buttin, rather than go to another page, then have to return to add more links The Code - ignore the page names add link page - http://www.everyonlinestore.co.uk/change_password.php <?php echo $_COOKIE["mysite_username"]; ?> <?php $conn = mysql_connect($server, $db_user, $db_pass) or die ("could not connect to mysql"); #Connect to mysql $rs = mysql_select_db( $database, $conn ) or die ("Could not select database"); #select database $sql = "Select link FROM links"; //pull the users from the table $result= mysql_query($sql) or die(" Could not add style facts"); echo "<FORM action=addlinks.php method=post><table align=center border=1>"; // display the users in table $c = 0; while($row = mysql_fetch_array($result)) { $user2 = $row['link']; if($c%5 == 0) echo "<tr height=\"100px\">"; // If the counter has ticked 6 times, start a new row. echo "<td><p align=center>$user2</p><p align=center>rating</p><p align=center><input type=submit></p>"; if($c%5 == 4) echo "</tr>"; // If we're drawing the 6th pic, end this row. $c++; } if($c%5 != 4) echo "</tr>"; // If there isn't a number of pics divisible by 6, end the row echo "</table></form>"; // end the table ?> Sumit page query // connect to the mysql server $link = mysql_connect($server, $db_user, $db_pass) or die ("Could not connect to mysql because ".mysql_error()); // select the database mysql_select_db($database) or die ("Could not select database because ".mysql_error()); // check if the link has already been added to username $mysite_username = $_COOKIE["mysite_username"]; $check = "select link from memberlinks where username = 'mysite_username'"; $qry = mysql_query($check) or die ("Could not match data because ".mysql_error()); $num_rows = mysql_num_rows($qry); if ($num_rows != 0) { echo "you have already added that link.<br>"; echo "<a href=Change_password.php>Back</a>"; exit; } // check username entered if (!$_POST['$mysite_username']) { echo "You did not enter a Username.<br>"; echo $_COOKIE["mysite_username"]; echo "<a href=change_password.php>Please Try again</a>"; exit; } // check link entered if (!$_POST['$user2']) { echo "You did not enter a link.<br>"; echo "<a href=change_password.php>Please Try again</a>"; exit; } else { // insert the data $insert = mysql_query("insert into memberlinks values ('".$_POST['mysite_username']."', '".$_POST['$user2']."')") or die("Could not insert data because ".mysql_error()); // print a success message echo $_COOKIE["mysite_username"]; echo "Your link has been added!<br>"; echo "Now you can <a href=change_password.php>add another link</a>"; } ?> Thanks in advance if you're gettign an error on the change_password page, it because you're not logged in. click the banner and sign up if you like then log in, and go back to the change_password page. refresh browser Thankyou! Quote Link to comment https://forums.phpfreaks.com/topic/95353-user-content-from-sql-table-igoogle-type-thing/#findComment-489302 Share on other sites More sharing options...
Alexhoward Posted March 11, 2008 Author Share Posted March 11, 2008 ok, so i've made them all their own seperate forms: code <?php $conn = mysql_connect($server, $db_user, $db_pass) or die ("could not connect to mysql"); #Connect to mysql $rs = mysql_select_db( $database, $conn ) or die ("Could not select database"); #select database $sql = "Select link FROM links"; //pull the users from the table $result= mysql_query($sql) or die(" Could not add style facts"); echo "<table align=center border=1>"; // display the users in table $c = 0; while($row = mysql_fetch_array($result)) { $user2 = $row['link']; if($c%5 == 0) echo "<tr height=\"100px\">"; // If the counter has ticked 6 times, start a new row. echo "<td><FORM action=addlinks.php method=post><p align=center>$user2</p><p align=center>rating script here</p><p align=center><input type=submit></form></p>"; if($c%5 == 4) echo "</tr>"; // If we're drawing the 6th pic, end this row. $c++; } if($c%5 != 4) echo "</tr>"; // If there isn't a number of pics divisible by 6, end the row echo "</table>"; // end the table ?> Quote Link to comment https://forums.phpfreaks.com/topic/95353-user-content-from-sql-table-igoogle-type-thing/#findComment-489380 Share on other sites More sharing options...
redarrow Posted March 11, 2008 Share Posted March 11, 2008 what is this code suppose to do please what is your aim i dont understand sorry please exsplain your plan... regards redarrow..... Quote Link to comment https://forums.phpfreaks.com/topic/95353-user-content-from-sql-table-igoogle-type-thing/#findComment-489387 Share on other sites More sharing options...
MadTechie Posted March 11, 2008 Share Posted March 11, 2008 also please use code tags (the # button) Quote Link to comment https://forums.phpfreaks.com/topic/95353-user-content-from-sql-table-igoogle-type-thing/#findComment-489388 Share on other sites More sharing options...
Alexhoward Posted March 11, 2008 Author Share Posted March 11, 2008 Hi redarrow, if you goto - http://www.everyonlinestore.co.uk/change_password.php you'll see. It drags all of the links out of my sql table, and displays them in a nice little grid on the page (i've just put a few in to test) (i'd still like the grid to be spread out a bit more, but don't know how to do that either...) (also eventually there will be hundreds of links, so i would like to include some kind of paging script as well) the "rating script here" will eventualy be a rating script The problem is the submit query button. I'd like it to save the username (from the cookie) and the link into another table, ready to be retrived from the users login page Quote Link to comment https://forums.phpfreaks.com/topic/95353-user-content-from-sql-table-igoogle-type-thing/#findComment-489391 Share on other sites More sharing options...
Alexhoward Posted March 11, 2008 Author Share Posted March 11, 2008 Hi MadTechie the # button....? Quote Link to comment https://forums.phpfreaks.com/topic/95353-user-content-from-sql-table-igoogle-type-thing/#findComment-489392 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.