NamePros
Welcome, Guest! Ready to make a name for yourself in the domain business? We welcome both the hobbyist and professional domainer to join the discussion as part of the NamePros community.

Click here to create your profile to start earning reputation for posting, and trader ratings for buying & selling in our free e-marketplace. Build your trader rating with each successful sale. Our system has tracked over 100,000 sales and counting!
FAQ & TOS Register Search Today's Posts Mark Forums Read

Go Back   NamePros.com > Website Development Discussion Forums > Programming
Reload this Page Can anyone help me please? :]

Programming PHP, Perl, Ruby on Rails, AJAX, HTML, XHTML, CSS, JavaScript, MySQL and any other coding topics.

Advanced Search


Closed Thread
 
LinkBack Thread Tools
Old 12-18-2006, 02:50 PM THREAD STARTER               #1 (permalink)
Account Closed
Join Date: Apr 2006
Location: England, UK
Posts: 494
Marty Rogers is a jewel in the roughMarty Rogers is a jewel in the roughMarty Rogers is a jewel in the rough
 



Can anyone help me please? :]


Hi,

I was wondering if somebody would be able to help me. I want to have a page on my website where i can see all layouts that have been submitted to my database that have a status set as inactive. I know how to output those but i just need a tick box or button/link to delete a layout row from the database (if i dont want to add it to my website) and a tick box or button/link to change the status from inactive to active (if i want to add it to my website).

Thanks in advance!

UPDATE!!!!

Okay, i've done the delete row and edit status links but i've realised it's crap LOL. Each time i add a row to my database it automatically adds an id, which is a number going up in order. Im upto 330 layouts now, i just added a test layout with an id of 331 and deleted with the function i just created (that i asked for help with above) so it deletes the row but then when i add another row it adds an id of 332, but i'd like it to use 331 again (if the row doesn't exist for the id) - anyone know what i could do here?
Last edited by Fun4Free.co.uk; 12-18-2006 at 03:22 PM.
Marty Rogers is offline  
Old 12-18-2006, 03:45 PM   #2 (permalink)
NamePros Member
Join Date: May 2006
Posts: 160
TwistMyArm is on a distinguished road
 



It's not a great idea to start reusing IDs... it kind of defeats to purpose and I don't know of any easy way to do it other than to grab all of the IDs and iterate through them until you possibly find an unused one.

But again: don't do it
TwistMyArm is offline  
Old 12-18-2006, 04:58 PM   #3 (permalink)
NamePros Member
Join Date: Nov 2006
Posts: 57
Cybo is on a distinguished road
 



Originally Posted by Fun4Free.co.uk
Hi,

I was wondering if somebody would be able to help me. I want to have a page on my website where i can see all layouts that have been submitted to my database that have a status set as inactive. I know how to output those but i just need a tick box or button/link to delete a layout row from the database (if i dont want to add it to my website) and a tick box or button/link to change the status from inactive to active (if i want to add it to my website).
????: NamePros.com http://www.namepros.com/programming/270705-can-anyone-help-me-please.html

Thanks in advance!

UPDATE!!!!

Okay, i've done the delete row and edit status links but i've realised it's crap LOL. Each time i add a row to my database it automatically adds an id, which is a number going up in order. Im upto 330 layouts now, i just added a test layout with an id of 331 and deleted with the function i just created (that i asked for help with above) so it deletes the row but then when i add another row it adds an id of 332, but i'd like it to use 331 again (if the row doesn't exist for the id) - anyone know what i could do here?
The only way to do something like that is to use manual submition on the id's, not automatic. Which means defining an ID each time you insert a row.

EDIT:

On a better note; i'll explain it a bit more, my post above sounds a little odd

You would need to do the following steps:

1) Turn off "auto_increment" for "id"
2) Rebuild the database

Then when you isert a row, you would need to do the following:

PHP Code:
$result mysql_query ("SELECT * FROM table");
$total_rows mysql_num_rows($result);
$counter1 0;
$freespaces 0;
$last_id 0;
$free = array();
while (
$row mysql_fetch_assoc($results))
????: NamePros.com http://www.namepros.com/showthread.php?t=270705
{
      
$counter1 += 1;
      if (
$last_id != $counter1 1)
      {
            
// We have found a free space
            
$free[$freespaces] = $row['id'] - 1;
            
$freespaces += 1;
      }
      
$last_id $row['id'];
}
// $free[0] is the id of the first free space
if ($freespaces == 0)
{
      
// No free spaces? Move to the next in the list.
      
$nextspace $total_rows 1;
}
else
{
      
// A Free Space was found
      
$nextspace $free[0];
}

// Make the new ID = $nextspace 

Hope this helps

- Richard Anderson
Last edited by Cybo; 12-19-2006 at 03:06 AM.
Cybo is offline  
Old 12-19-2006, 01:02 AM   #4 (permalink)
NamePros Regular
 
beaver6813's Avatar
Join Date: May 2005
Location: England
Posts: 392
beaver6813 is a jewel in the roughbeaver6813 is a jewel in the roughbeaver6813 is a jewel in the rough
 




Although considering all the code needed to do that, you might be better off just letting it auto-increment. And then sort out the numbers in your site's interface... Why do you need to get the id's in order so much?
beaver6813 is offline  
Old 12-19-2006, 02:45 AM THREAD STARTER               #5 (permalink)
Account Closed
Join Date: Apr 2006
Location: England, UK
Posts: 494
Marty Rogers is a jewel in the roughMarty Rogers is a jewel in the roughMarty Rogers is a jewel in the rough
 



Thanks alot cybo

Im just fussy, i guess i don't really need it lol. Hmm i think i will leave it then instead of making more work for myself when it's not needed =P.

I have another question if any of you are up for helping me? this question is about my new website BangVideoBang and i want to add tags for videos i put up on the site now, view this video for example:
????: NamePros.com http://www.namepros.com/showthread.php?t=270705

http://www.bangvideobang.com/videos/...e-session.html

I have added some tags for it, is there anyway that i could make each tag goto something like this:

http://www.bangvideobang.com/videos/tags.php?tag=bmx
http://www.bangvideobang.com/videos/...tag=dave+mirra
http://www.bangvideobang.com/videos/...?tag=back+flip
http://www.bangvideobang.com/videos/...?tag=warehouse

(i haven't added tags.php yet so the links above won't work)

Those are the tags i have added for that video, i want it so a visitor can click any of the tags and then it will go off and get all the videos with that tag in it.

Anyone know how i could do this? Im new with php and mysql so i don't know much.

Thanks alot.
Marty Rogers is offline  
Old 12-19-2006, 02:53 AM   #6 (permalink)
NamePros Member
Join Date: Nov 2006
Posts: 57
Cybo is on a distinguished road
 



Fun4Free,

Are these tags stored in your database? If they are would be be able to share the layout of the database and I will knock you up a script, the PHP anyway , your need to do the HTML.
Cybo is offline  
Old 12-19-2006, 03:04 AM THREAD STARTER               #7 (permalink)
Account Closed
Join Date: Apr 2006
Location: England, UK
Posts: 494
Marty Rogers is a jewel in the roughMarty Rogers is a jewel in the roughMarty Rogers is a jewel in the rough
 



Yeh they are. what do you mean the layout of the database? (sorry lol) Is it the structure?

Click Here: http://img246.imageshack.us/img246/884/structurepe0.png

I bet it's all wrong heh lol. I use name for the tags. Gotta sort those field names out at some point.
Marty Rogers is offline  
Old 12-19-2006, 03:06 AM   #8 (permalink)
NamePros Member
Join Date: Nov 2006
Posts: 57
Cybo is on a distinguished road
 



Yeah, thats what I need. Which one are the tags stored in? And how are the tags stored? (EG; Are the separated with a space, ect?)
Cybo is offline  
Old 12-19-2006, 03:09 AM THREAD STARTER               #9 (permalink)
Account Closed
Join Date: Apr 2006
Location: England, UK
Posts: 494
Marty Rogers is a jewel in the roughMarty Rogers is a jewel in the roughMarty Rogers is a jewel in the rough
 



I put the tags in the 'name' row. I have them with a comma and then a space. should i just do a comma and no space or is that okay?

Like this: live bands, hanging, cute, music, warped tour

Marty Rogers is offline  
Old 12-19-2006, 03:12 AM   #10 (permalink)
NamePros Member
Join Date: Nov 2006
Posts: 57
Cybo is on a distinguished road
 



Originally Posted by Fun4Free.co.uk
I put the tags in the 'name' row. I have them with a comma and then a space. should i just do a comma and no space or is that okay?

Like this: live bands, hanging, cute, music, warped tour

Nah, that's all fine. Let me knock something up for you and I will post again in this thread so you know i've posted it

I wont do the html, but I will put where you need to put it Give me a little while
Cybo is offline  
Old 12-19-2006, 03:15 AM THREAD STARTER               #11 (permalink)
Account Closed
Join Date: Apr 2006
Location: England, UK
Posts: 494
Marty Rogers is a jewel in the roughMarty Rogers is a jewel in the roughMarty Rogers is a jewel in the rough
 



Thanks alot mate, im well happy lol
Marty Rogers is offline  
Old 12-19-2006, 03:35 AM   #12 (permalink)
NamePros Member
Join Date: Nov 2006
Posts: 57
Cybo is on a distinguished road
 



tags.php

PHP Code:
<?php
// Connect to the database here.


if (!isset($_GET['tags']))
{
      
// No tags sent... Change the below:
      
header("Location: http://yoursite.com/index.php");
}
// Get the tags
$rawtagdata $_GET['tags'];
????: NamePros.com http://www.namepros.com/showthread.php?t=270705

// Explode the raw data
$tags explode("+"$rawtagdata);

$sql "SELECT * FROM thetable WHERE name LIKE '%" $tags[0] . "%'";
$counter1 1;
$loop1done false;

while (
$loop1done false)
{
      if (!isset(
$tags[$counter1]))
????: NamePros.com http://www.namepros.com/showthread.php?t=270705
      {
            
$loop1done true;
      }
      else
      {
            
$sql .= " OR name LIKE '%" $tags[$counter1] . "%'";
            
$counter1 += 1;
      }
}
$results mysql_query($sql);

// Now just loop over the $results :D

Again, hope it helps
Cybo is offline  
Old 12-19-2006, 03:47 AM THREAD STARTER               #13 (permalink)
Account Closed
Join Date: Apr 2006
Location: England, UK
Posts: 494
Marty Rogers is a jewel in the roughMarty Rogers is a jewel in the roughMarty Rogers is a jewel in the rough
 



Thanks for your help cybo but i didn't explain what i needed properly =P

I know how to do the tags.php page to output the video listings for the selected tags. I just don't know how to change the actual tags on the video pages into links, so that a visitor can click on the tag which goes to tags.php?tag=blah. I add the tags to the database as 'tag, tag tag, taggy, tagoo' etc lol. I could add them as links directly into the database but i was just wondering if there is a small php code that would make all the tags that are outputted display as links instead of just text as you see on:

http://www.bangvideobang.com/videos/...out-the-e.html

under video information.

Thanks alot though mate, reallly appreciate it

UPDATE!!!

I've added the tag links now, have a look:

http://www.bangvideobang.com/videos/...out-the-e.html

Marty Rogers is offline  
Closed Thread


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools


Liquid Web Smart Servers  
All times are GMT -7. The time now is 02:06 AM.

Managed Web Hosting by Liquid Web
Domain name forum recommended by Domaining.com Powered by: vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.6.0 Ad Management plugin by RedTyger