[PHP] Link In Frame

Pagina: 1
Acties:
  • 112 views sinds 30-01-2008
  • Reageer

Onderwerpen


Acties:
  • 0 Henk 'm!

  • RV
  • Registratie: Juli 2001
  • Laatst online: 08-09 14:30
Heyz,

Ik heb dus een script he, en daar moet ik dus links in toevoegen. Nu wil ik het zo doen dat ik, als ik zo'n link toevoeg en ik dan op die toegevoegde link klik, diezelfde link in een nieuw frame opent, met bovenaan mijn frame en onderaan de pagina van de link. Hoe doe ik dit, ik heb al het volgende geprobeerd :

PHP:
1
2
3
4
5
6
7
8
9
10
11
      // print link
      if ($LDescription) {
        $LDescription = " - $LDescription";
      }
      echo "  <tr>\n";
      echo "    <td bgcolor='$row3_color' id=linkster-list align='center'><a href=http://www.domein.com/linkdb/galleryframe.php?asd=$URL".$new_window.">$Website</a>$LDescription</td>\n";
      if ($show_clicks == "yes") {
        echo "    <td bgcolor='$row3_color' id=linkster-count>$Clicks</td>\n";
      }
      echo "  </tr>\n";
      $last_CID = $CID;


In de galleryframe.php staat hoe ik het heb gedaan :

PHP:
1
2
3
4
5
6
7
8
<?PHP

include("linkster.php");
error_reporting (E_ALL);

echo "<a href='".$_GET['asd']."'>$URL</a>";

?>


Ik krijg deze error :
Notice: Undefined variable: URL in /home/domein/public_html/linkdb/galleryframe.php on line 8

Wat doe ik fout, want ik krijg een blanke nieuwe pagina ipv link in pagina, want als de link eenmaal werkt kan ik zo een frame erin zetten. Alvast bedankt !

[ Voor 58% gewijzigd door RV op 29-06-2003 13:00 ]


Acties:
  • 0 Henk 'm!

  • curry684
  • Registratie: Juni 2000
  • Laatst online: 06-09 00:37

curry684

left part of the evil twins

Heropend in overleg met The_ReVenger opdat hij z'n openingspost wat beter kan verzorgen.

[ Voor 115% gewijzigd door curry684 op 29-06-2003 12:59 ]

Professionele website nodig?


Acties:
  • 0 Henk 'm!

Verwijderd

De variabele $URL heeft in je 2e stukje PHP toch nog helemaal geen waarde? En als-ie leeg is heb je dus <a href='iets'></a> en dan zie je niks.

Acties:
  • 0 Henk 'm!

  • RV
  • Registratie: Juli 2001
  • Laatst online: 08-09 14:30
Hoe moet ik dat dan doen, want ik kom er echt niet uit :'(

[ Voor 3% gewijzigd door RV op 29-06-2003 13:57 ]


Acties:
  • 0 Henk 'm!

  • marty
  • Registratie: Augustus 2002
  • Laatst online: 27-03-2023
The_ReVenger schreef op 29 juni 2003 @ 13:56:
Hoe moet ik dat dan doen, want ik kom er echt niet uit :'(
eehhh...zorgen dat $URL wel een waarde krijgt? :?

ja, sorry, klinkt een beetje lullig, maar waarom staat dat er zo.? je kan natuurlijk wel een variabele met een leuke naam neerzetten en hopen dat php daar op een soort magische manier iets van maakt, maar dat werkt natuurlijk niet. het moet wel ergens vandaan komen.

Acties:
  • 0 Henk 'm!

  • RV
  • Registratie: Juli 2001
  • Laatst online: 08-09 14:30
Daarom heb ik ook linkster.php geinclude omdat daar de waarde van $URL in staat ... Of doe ik het dan fout ?

Ik krijg de link trouwens wel gewoon in de nav-bar ... : http://www.domein.com/lin...www.tweakersvoorbeeld.net

[ Voor 54% gewijzigd door RV op 29-06-2003 15:31 ]


Acties:
  • 0 Henk 'm!

Verwijderd

Is die linkster.php het bovenste stukje code? Daar zie ik ook geen toewijzing aan $URL staan. Wel staat er ....php?ads=$URL, maar hoe wordt de waarde van URL dan bepaald? Want dat staat niet in je stukje code volgens mij.
Als je $URL=$_GET['asd'] doet, wordt de waarde van $URL toegewezen aan de hand van de invoer van asd. Post anders even alle twee de bestanden compleet want volgens mij heb je een aantal dingen achterwege gelaten.

Acties:
  • 0 Henk 'm!

  • RV
  • Registratie: Juli 2001
  • Laatst online: 08-09 14:30
Ja ik wil dat wel doen maar ik weet niet of curry684, nou ja als 't niet mag moet je ze maar ff editten curry :) ....

linkster.php
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<?

require("common.php");

######### CLICK COUNT #########
if ($QUERY_STRING && $LID && $URL) {
  mysql_query("UPDATE $link_table SET Clicks = Clicks+1 WHERE ID = $LID");  // add 1 to click count
  header("Location: $URL");  // send user to website
}

######### PRINT HEADER/MENU #########
require("$header_html");
if ($public_add == "yes" || $QUERY_STRING) {
  echo "\n<p align=$tbl_align>\n";
  echo "<table border=0 cellpadding=0 cellspacing=0 width=$tbl_width>\n";
  echo "  <tr>\n";
  echo "    <td>\n";
}
if ($public_add == "yes" && $action != "add_link") {
  echo "    <li><a href=$PHP_SELF?action=add_link>Add a link</a></li>\n";
}
if ($mode == "flat" && $action == "add_link") {
  echo "    <li><a href=$PHP_SELF>Back to links</a></li>\n";
}
if ($mode == "leveled" && $QUERY_STRING) {
  echo "    <li><a href=$PHP_SELF>Back to categories</a></li>\n";
}
if ($public_add == "yes" || $QUERY_STRING) {
  echo "    </td>\n";
  echo "  </tr>\n";
  echo "</table>\n";
  echo "</p>\n";
}

######### FLAT MODE #########
if ($mode == "flat" && !$QUERY_STRING) {
  $query = "SELECT $link_table.ID AS LID, Clicks, Website, URL, $link_table.Description AS LDescription, $cat_table.ID AS CID, Category, $cat_table.Description AS CDescription FROM $cat_table, $link_table WHERE $cat_table.ID = $link_table.Cat_ID ORDER BY $cat_order, $links_order";
  print_table ($query, $PHP_SELF, $tbl_border, $tbl_cellpadding, $tbl_cellspacing, $tbl_width, $tbl_align, $row1_color, $row2_color, $row3_color, $Category, $CDescription, $LID, $URL, $Website, $LDescription, $Clicks, $show_clicks, $show_credit, $credit_html, $new_window, $cat_table, $link_table);
}

######### LEVELED MODE #########
if ($mode == "leveled" && !$LID && !$URL) {
  // print categories
  if (!$QUERY_STRING) {
    $query = "SELECT * FROM $cat_table ORDER BY $cat_order";
    $result = mysql_query($query) or die("<p><b>Error:</b> No data exists.</p>\n</body>\n</html>\n\n");
    echo "<p align='$tbl_align'>\n";
    echo "<table border='$tbl_border' cellpadding='$tbl_cellpadding' cellspacing='$tbl_cellspacing' width='$tbl_width'>\n";
    echo "  <tr>\n";
    echo "    <td colspan=2 bgcolor='$row1_color'><div id=linkster-title-large>Categories</div></td>\n";
    echo "  </tr>\n";
    echo "  <tr>\n";
    echo "    <td align=center id=linkster-title-small bgcolor='$row2_color'>Category/Description</td>\n";
    echo "    <td align=center id=linkster-title-small bgcolor='$row2_color'>&nbsp;&nbsp;Links&nbsp;&nbsp;</td>\n";
    echo "  </tr>\n";
    while (list($CID, $Count, $Category, $Description) = mysql_fetch_array($result)) {
      if ($Count > 0) {
        $Category = "<a href=$PHP_SELF?CID=$CID>$Category</a>";
      }
      if ($Description) {
        $Description = "- $Description";
      }
      echo "  <tr>\n";
      echo "    <td bgcolor='$row3_color' id=linkster-list>$Category $Description</td>\n";
      echo "    <td bgcolor='$row3_color' align=center id=linkster-count>$Count</td>\n";
      echo "  </tr>\n";
    }
    if ($show_credit == "yes") {
      echo "  <tr>\n";
      echo "    <td colspan=2><br>$credit_html</td>\n";
      echo "  </tr>\n";
    }
    echo "</table>\n";
    echo "</p>\n";
  }
  // print links for specific category
  if ($CID) {
  $query = "SELECT $link_table.ID AS LID, Clicks, Website, URL, $link_table.Description AS LDescription, $cat_table.ID AS CID, Category, $cat_table.Description AS CDescription";
  $query .= " FROM $cat_table, $link_table";
  $query .= " WHERE $cat_table.ID = $link_table.Cat_ID AND $cat_table.ID = $CID";
  $query .= " ORDER BY $links_order";
  print_table ($query, $PHP_SELF, $tbl_border, $tbl_cellpadding, $tbl_cellspacing, $tbl_width, $tbl_align, $row1_color, $row2_color, $row3_color, $Category, $CDescription, $LID, $URL, $Website, $LDescription, $Clicks, $show_clicks, $show_credit, $credit_html, $new_window, $cat_table, $link_table);
  }
}

######### ADD LINK (PUBLIC) #########
if ($action == "add_link" && $public_add == "yes") {
  // process form
  if ($submit) {
    // check for errors
    if (!$Website) {
      $error = "<li>Website Name cannot be left blank</li>\n";
    }
    if (!$URL) {
      $error .= "<li>Website URL cannot be left blank</li>\n";
    }
    if (eregi("http://", $URL) && eregi("\.", $URL)) {  // URL must contain http:// and . to be valid
      $validURL = 1;
    }
    if ($URL && !$validURL) { 
      $error .= "<li>Website URL is invalid</li>\n";
    }
    if (strlen($Description) > 250) {
      $error .= "<li>Description cannot exceed 250 characters (length: " . strlen($Description) . ")</li>\n";
    }
    // add link to database
    if (!$error) {
      $Website = escape_quotes($Website);
      $URL = escape_quotes($URL);
      $Description = escape_quotes($Description);
      mysql_query("INSERT INTO $link_table (Cat_ID, Website, URL, Description) VALUES ('$CID','$Website','$URL','$Description')");
      UpdateCatCounts();
    }
    else {
      $Website = strip_quotes($Website);
      $URL = strip_quotes($URL);
      $Description = strip_quotes($Description);
    }
  }
  // print title and message
  $title = "Add a Link";
  $message = "Fill out the form below to add a link.";
  if ($error) { 
    $title = "Error Adding Link";
    $message = "The following error(s) occured:\n <ul>$error</ul>Please correct any errors and try again.";
  }
  if ($submit && !$error) {
    $title = "Link Added";
    $message = "Your link has been added.";
  } 
  print_title_message($title, $message);
  // print form
  if (!$submit) {  // sets URL before user touches it
    $URL = "http://";
  }
  if (!$submit || $error) {
    echo "<form method=post action=$PHP_SELF?$QUERY_STRING>\n";
    link_form($db, $Cat_ID, $CID, $Website, $URL, $Description, $cat_table);
    echo "<input type=submit name=submit value=' Add Link '>\n";
    echo "</form>\n";
  }
}

########### FOOTER/CLOSE DB ###########
require("$footer_html");
mysql_close($db);  // close db connection

?>


& common.php
PHP:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
<?

// open database connection
$db = @mysql_connect("$mysql_server","$user","$password");
mysql_select_db("$database");

// table names
$cat_table = "linkster_cats";
$link_table = "linkster_links";

// credit HTML
$credit_html = "<span style='font-size: 8pt;'></span>";

// category/link sorting
if ($cat_order == '1') { $cat_order = "Category"; }
if ($cat_order == '2') { $cat_order = "$cat_table.ID DESC"; }
if ($cat_order == '3') { $cat_order = "$cat_table.ID ASC"; }
if ($links_order == '1') { $links_order = "Website"; }
if ($links_order == '2') { $links_order = "$link_table.ID DESC"; }
if ($links_order == '3') { $links_order = "$link_table.ID ASC"; }

// open new window
if ($new_window == "yes") {
  $new_window = " target=_new";
}
else {
  $new_window = "";
}

// print title and message
function print_title_message($title, $message) {
  echo "<div id=linkster-title-large>$title</div>\n";
  echo "<div>$message</div>\n";
}

// print table function
function print_table($query, $PHP_SELF, $tbl_border, $tbl_cellpadding, $tbl_cellspacing, $tbl_width, $tbl_align, $row1_color, $row2_color, $row3_color, $Category, $CDescription, $LID, $URL, $Website, $LDescription, $Clicks, $show_clicks, $show_credit, $credit_html, $new_window, $cat_table, $link_table) {
  $result = mysql_query($query) or die("<p><b>Error:</b> No data exists.</p>\n</body>\n</html>\n\n");
  $link_count = mysql_num_rows($result);
  if ($link_count > 0) {
    echo "<p align=$tbl_align>\n";
    echo "<table border='$tbl_border' cellpadding='$tbl_cellpadding' cellspacing='$tbl_cellspacing' width='$tbl_width'>\n";
    while (list($LID, $Clicks, $Website, $URL, $LDescription, $CID, $Category, $CDescription) = mysql_fetch_array($result)) {
      // print category
      if ($last_CID != $CID) {
        // span cols across two if click col exists
        $colspan = "1";
        if ($show_clicks == "yes") {
          $colspan = "2";
        }
        // print blank cell unless it's above first category
        if ($last_CID) {
          echo "  <tr>\n";
          echo "    <td colspan=$colspan align='center'><br></td>\n";
          echo "  </tr>\n";
       }
        echo "  <tr align='center'>\n";
        if ($CDescription) {
          $CDescription = "<span id=linkster-cat-desc>$CDescription</span>";
        }
        echo "    <td colspan=$colspan bgcolor='$row1_color'><div id=linkster-title-large>$Category</div>$CDescription</td>\n";
        echo "  </tr>\n";
        
      }
      // print link
      if ($LDescription) {
        $LDescription = " - $LDescription";
      }
      echo "  <tr>\n";
      echo "    <td bgcolor='$row3_color' id=linkster-list align='center'><a href=http://www.domein.com/linkdb/galleryframe.php?asd=$URL".$new_window.">$Website</a>$LDescription</td>\n";
      if ($show_clicks == "yes") {
        echo "    <td bgcolor='$row3_color' id=linkster-count>$Clicks</td>\n";
      }
      echo "  </tr>\n";
      $last_CID = $CID;
    }
    if ($show_credit == "yes") {
      echo "  <tr>\n";
      echo "    <td colspan=$colspan><br>$credit_html</td>\n";
      echo "  </tr>\n";
    }
    echo "</table>\n";
    echo "</p>\n";
  }
}

// category select input
function category_select($db, $selected_cat, $selected_cat_error, $cat_table) {
  echo "<select name='CID'>\n";
  $query_cats = mysql_query("SELECT ID, Category FROM $cat_table ORDER BY Category");
  $cat_count = mysql_affected_rows($db); 
  for($i = 0; $i < $cat_count; $i++) {
    list($Cat_ID, $Category) = mysql_fetch_row($query_cats);
    $index++;  // increment the line index by 1
    if ($selected_cat_error) {
      $selected_cat = $selected_cat_error;
    }
    if ($Cat_ID == $selected_cat) {
      $selected = " selected";
    }
    else {
      $selected = "";
    }
    echo "<option value='$Cat_ID'" . $selected . ">$Category</option>\n";
  }
  echo "</select>\n";
}

// add/modify category form
function category_form($Type, $PHP_SELF, $QUERY_STRING, $Category, $Description) {
  echo "<form method='post' action='$PHP_SELF?$QUERY_STRING'>\n";
  echo "<p>\n<span id=linkster-title-small>Category Name:</span><br>\n<input type=text name=Category size=30 maxlength=75 value=\"$Category\">\n</p>\n";
  echo "<p>\n<span id=linkster-title-small>Category Description (Optional):</span><br>\n<textarea cols=40 rows=5 wrap=virtual name=Description>$Description</textarea>\n</p>\n";
  echo "<input type=submit name=submit value=' $Type Category '>\n";
  echo "</form>\n";
}

// add/modify link form
function link_form($db, $Cat_ID, $CID, $Website, $URL, $Description, $cat_table) {
  echo "<p><span id=linkster-title-small>Category:</span><br>\n";
  category_select($db, $Cat_ID, $CID, $cat_table);  // print categories
  echo "</p>\n";    
  echo "<p>\n<span id=linkster-title-small>Website Name:</span><br>\n<input type=text name=Website size=30 maxlength=75 value=\"$Website\">\n</p>\n";
  echo "<p>\n<span id=linkster-title-small>Website URL:</span><br>\n<input type=text name=URL size=30 maxlength=150 value=\"$URL\">\n</p>\n";
  echo "<p>\n<span id=linkster-title-small>Short Description (Optional):</span><br>\n<textarea cols=40 rows=5 wrap=virtual name=Description>$Description</textarea>\n</p>\n";
}

// escape quotes
function escape_quotes($string) {
  if (get_magic_quotes_gpc() == 0) {  // if magic quotes is off
    $string = addslashes($string);  // escape ' and " with \
  }
  $string = ereg_replace("\"", "'", $string);  // replace " with '
  return $string;
}

// strip escaped quotes
function strip_quotes($string) {
  if (get_magic_quotes_gpc() == 1) {  // if magic quotes is on
    $string = stripslashes($string);  // strip \ from ' and "
  }
  $string = ereg_replace("\"", "'", $string);  // replace " with '
  return $string;
}


// update category link count
function update_link_count($ID) {
  global $link_table, $cat_table;
  $query = mysql_query("SELECT COUNT(ID) AS LinkCount FROM $link_table WHERE Cat_ID = '$ID'") or die(mysql_error());
  extract(mysql_fetch_array($query));
  mysql_query("UPDATE $cat_table SET Count = '$LinkCount' WHERE ID = '$ID'");
}

// update all category link counts
function UpdateCatCounts() {

    global $cat_table;

    $query = mysql_query("SELECT ID FROM $cat_table");
    $count = mysql_num_rows($query);

    for ($i = 0; $i < $count; $i++) {
        extract(mysql_fetch_array($query));
        update_link_count($ID);
    }

}



?>

Acties:
  • 0 Henk 'm!

  • curry684
  • Registratie: Juni 2000
  • Laatst online: 06-09 00:37

curry684

left part of the evil twins

The_ReVenger schreef op 29 June 2003 @ 18:21:
Ja ik wil dat wel doen maar ik weet niet of curry684, nou ja als 't niet mag moet je ze maar ff editten curry :) ....
Sja op verzoek van iemand die je wil helpen maakt het mij niet uit. Het is imho pas erg als je begint met 300 regels code neer te pleuren en vervolgens aan ons het verzoek om te debuggen.

Professionele website nodig?


Acties:
  • 0 Henk 'm!

Verwijderd

The_ReVenger heeft via ICQ verder gevraagd en het oorspronkelijke probleem is verholpen ($URL was idd leeg), maar voor de rest is het een kwestie van w3schools doorlezen mbt. de frames dus het zit al goed.

Acties:
  • 0 Henk 'm!

  • curry684
  • Registratie: Juni 2000
  • Laatst online: 06-09 00:37

curry684

left part of the evil twins

Regels bij het posten:
  • Post ook de oplossing!

    Als je probleem is opgelost, kom dan terug om de oplossing te posten. Dan hebben er meer mensen profijt van in de toekomst. Die search is er ook in dit opzicht niet voor niets ;)

  • ;)

    [ Voor 7% gewijzigd door curry684 op 30-06-2003 11:06 ]

    Professionele website nodig?

    Pagina: 1