Jump to content

Michael4172

Members
  • Posts

    41
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

Michael4172's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. [code]                        $select_team = "SELECT *";                         $from_team   = " FROM mc_base";                         $where_team = " WHERE mc_sponsor_id = '$myid'";                         $sname_team = mysql_query($select_team . $from_team . $where_team, $dbcnx);                                                $count = 0;                 while ($sname_view_list = mysql_fetch_array($sname_team)) {                 $count++;                 $member_fname = $sname_view_list["mc_fname"];                                         echo("<tr><td>$count</td>");                                         echo("<td>$member_fname</td></tr>");                                         echo("</table> } [/code]
  2. You can get a function at the below link. I believe if you change the content type to whatever image format you have (.gif / .bmp) it would work [a href=\"http://uk.php.net/imagecopyresized\" target=\"_blank\"]PHP Manual - imagecopyresized[/a]
  3. [!--quoteo(post=388351:date=Jun 27 2006, 12:16 AM:name=Crayon Violent)--][div class=\'quotetop\']QUOTE(Crayon Violent @ Jun 27 2006, 12:16 AM) [snapback]388351[/snapback][/div][div class=\'quotemain\'][!--quotec--] the reason why ^ returns blank page is because you do this: $key_row = $row['keyword']; before your if statement. this makes it true, even if there is no value. you are creating the variable, so simply doing if ($key_row == true) ... well it exists, even if it is empty, so it's true. what is your query string? are you expecting more than 1 row returned? something like this should work if you are expecting more than 1 row returned. there are more efficient ways if only 1 row is expected to be returned [code] $found = FALSE; while($row = mysql_fetch_array($result)) {    //not sure how your data is stored, so this should cover your bases    if (($row['keyword'] != NULL) && (!empty($row['keyword'])) && (trim($row['keyword']) != "")){       echo $row['keyword'];       echo "<br />";       echo $row['definition'];       echo "<br />";       $found = TRUE;     } } if ($found == FALSE) {    echo "not found"; } [/code] [/quote] I am just expecting one match per keyword, but the code you supplied works great :) Thanks for that.
  4. [!--quoteo(post=388339:date=Jun 26 2006, 11:37 PM:name=phpstuck)--][div class=\'quotetop\']QUOTE(phpstuck @ Jun 26 2006, 11:37 PM) [snapback]388339[/snapback][/div][div class=\'quotemain\'][!--quotec--] Try this [code] while($row = mysql_fetch_array($result))         $key_row = $row['keyword'];   if ($key_row != ""){       echo $row['keyword'];       echo "<br />";       echo $row['definition'];       echo "<br />";   } else {       echo "The keyword wasn't found";   } [/code] [/quote] This code works correctly if the keyword isn't in the DB...but displays the blank page if it does exist....kinda odd... [code] while($row = mysql_fetch_array($result))   {      $key_row = $row['keyword'];   if ($key_row > 0){       echo $row['keyword'];       echo "<br />";       echo $row['definition'];       echo "<br />";}   else {       echo "The keyword wasn't found";}   } [/code] I tried this, It gives a "Keyword wasn't found" when I type in a keyword that's in the database. It returns a blank page when an incorrect keyword is entered. [code] while($row = mysql_fetch_array($result))   {      $key_row = $row['keyword'];   if (! $key_row){       echo $row['keyword'];       echo "<br />";       echo $row['definition'];       echo "<br />";}   else {       echo "The keyword wasn't found";}   } [/code] This does same thing as #1 [code] while($row = mysql_fetch_array($result))   {      $key_row = $row['keyword'];   if ($key_row == true){       echo $row['keyword'];       echo "<br />";       echo $row['definition'];       echo "<br />";}   else {       echo "The keyword wasn't found";}   } [/code] This returns the keyword when its found. But returns a blank page when the keyword isn't found. :( In addition I've also attempted = true and === true on this one as well. Also tried $key_row = 1... I also have tried this [code] while($row = mysql_fetch_array($result))   {      $key_row = $row['keyword'];   if ($key_row == true){       echo $row['keyword'];       echo "<br />";       echo $row['definition'];       echo "<br />";}   else if ($key_row == false){       echo "The keyword wasn't found";}   } [/code] It returns the keywords if true, but returns a blank page if false :(
  5. I'm doing a simple IF test statement below. I would expect it to return the $rows if $key_row equals anything other than a blank, and would expect it to return keyword wasn't found if its blank. However, when I use the code below it returns keywork and definition if true, but returns a blank page if they weren't found. Am I overlooking something below? [code] while($row = mysql_fetch_array($result))   {      $key_row = $row['keyword'];   if ($key_row != ""){       echo $row['keyword'];       echo "<br />";       echo $row['definition'];       echo "<br />";}   else {       echo "The keyword wasn't found";}   } [/code]
  6. For others who may wanna try this, for it to work, I ended up doing the following: [code] <?php $user = "user"; $pass = "password"; $db = "joa"; $link = mysql_connect( "localhost", $user, $pass ); if ( ! $link )    die( "Couldn't connect to MySQL" ); mysql_select_db( $db, $link )   or die ( "Couldn't open $db: ".mysql_error() ); if (isset($_REQUEST['keyword'])) { // Do this if a keyword was set $result = mysql_query("SELECT * FROM joa WHERE keyword='$keyword'"); while($row = mysql_fetch_array($result))   {   echo $row['keyword'];   echo "<br />";   echo $row['definition'];   echo "<br />";   } } else { echo "Didn't work"; } ?> [/code] Thanks for all the help gentlemen :)
  7. Actually I was echoing $result. :) Thanks for the help
  8. Ok so far here is what I got: [code] <?php $user = "user"; $pass = "pass"; $db = "joa"; $link = mysql_connect( "localhost", $user, $pass ); if ( ! $link )    die( "Couldn't connect to MySQL" ); mysql_select_db( $db, $link )   or die ( "Couldn't open $db: ".mysql_error() ); if (isset($_REQUEST['keyword'])) { // Do this if a keyword was set $keyword = $_REQUEST['keyword']; //Sets $keyword equal to what its the URL $sql = "SELECT * from joa WHERE keyword='$keyword'";  // Selects all fields for the APPLE or whatever the keyword is $result = mysql_query($sql); // Now you are connected to the database, table and the correct row for the keyword } else { echo "Didn't work"; } ?> [/code] However, when I type in a keyword that is in the db... "Apple" as [a href=\"http://www.site.com/keyword.php?keyword=Apple\" target=\"_blank\"]http://www.site.com/keyword.php?keyword=Apple[/a] it just shows as a blank page.....Any ideas?
  9. Thanks, I'm gonna play around with it some :)
  10. The code I displayed is actually the code where I'm inputting the data to MYSQL so I guess that is not a good example. Lets say I create a page whose purpose is to SOLEY display the keyword.php?keyword=APPLE . How would I set it up so if you view keyword.php by itself its blank, but if you input keyword.php?keyword=APPL (assuming APPLE is int he db) it would display that ID, keyword, def ect...
  11. [!--quoteo(post=388129:date=Jun 26 2006, 01:11 PM:name=DaveLinger)--][div class=\'quotetop\']QUOTE(DaveLinger @ Jun 26 2006, 01:11 PM) [snapback]388129[/snapback][/div][div class=\'quotemain\'][!--quotec--] But saying keywords.php?keyword doesnt tell the php code anything. You'd need keywords.php?keyword=thewordtolookfor [/quote] Ok well that is fine as well. Question is, how would I set that up?
  12. Ok here is the code (I have thus far) for the db where I insert the information into the MySql itself: [code] <?php $keyword = $_REQUEST['keyword']; $definition = $_REQUEST['definition']; $user = "user"; $pass = "password"; $db = "joa"; $link = @mysql_connect( "localhost", $user, $pass ); if ( ! $link ){     die( "Couldn't connect to MySql: ".mysql_error() ); } print "<h2>Successfully connected to server</h2>\n\n"; @mysql_select_db( $db )     or die ( "Couldn't open $db: ".mysql_error() ); print "Successfully selected database \"$db\"<br />\n"; $query = "INSERT INTO joa( keyword, definition )     values ( '$keyword', '$definition' )"; print "running query: <br />\n$query<br />\n"; mysql_query( $query, $link )     or die ( "INSERT error: ".mysql_error() ); mysql_close( $link ); ?> [/code] WHat I'm doing is entering keywords and definitions. I have a bit of javascript where you can click on anyword in an article and a popup window comes up. I aim at filling the DB full of words, and if they click one that's not there, it'll take them to a form where they can submit a request for that word. What I"m trying to do is, in the javascript it looks for somthing like [a href=\"http://www.mysite.com/keywords.php?keyword\" target=\"_blank\"]http://www.mysite.com/keywords.php?keyword[/a]. Ideally I could get the ?keyword to show like that :)
  13. [!--quoteo(post=387865:date=Jun 25 2006, 06:40 PM:name=adamwhiles)--][div class=\'quotetop\']QUOTE(adamwhiles @ Jun 25 2006, 06:40 PM) [snapback]387865[/snapback][/div][div class=\'quotemain\'][!--quotec--] the only time you would want to do that is if your passing a variable or value to a page like say, you want to view the 5th post in a database, you will do [a href=\"http://www.yourdomain.com/posts.php?post=5\" target=\"_blank\"]http://www.yourdomain.com/posts.php?post=5[/a] Then in your php code on posts.php you would have something like this: $_GET['post']; the value of $_GET['post'] would be 5 since you had the ?post=5 after posts.php [/quote] I'm actually trying to do the same thing. A couple questions though. Would the name 'post' be the database name or would it be a table in the database itself?
  14. Are you wanting the user to be required to enter in a unique username and password in order to download the files on your site?
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.