kekkaishi 18 Junior Poster

Does anyone know of a php based forum that is easily customizable to work with an existing user base so that members don't have to register or sign in a second time when they access the forum? I heard that this is possible with phpbb3 but I haven't seen anything in their documentation that covers this.

you heard right, but that is the user's choice. If the user TICKS THE REMEMBER ME CHECK BOX, then it remembers the user provided that the user do not clean his/her cookies or cache for that matter. phbb3 is a powerful one with a lot of features and to know more u might wanna give it a test.

kekkaishi 18 Junior Poster

Okay, I am still going around in circles and not getting it to work. Let me put my actual code rather than trying to make up examples. This is for a blog, which I actually had working fine (well, this part of it), but I am building the whole thing into a class now, to make it easier to work with.

This is what I have it at now. The $_ptimeValref that gets passed to the function is right (I got it to echo it.) I tried "SELECT * FROM post WHERE ptime ='$_ptimeValref' and changing the * to post, title, ptime. I realize that I must just not be getting it. Each time I have done this I have gone through the same process, finally getting something that works, but not really sure why it does, and why so many other things I tried didn't.

function getPostValues($_ptimeValref){
          /* This function gets the value of ptime
          and returns the full set of values for a post: 
          post url, title and ptime as a time value */
          
      include 'DB_connection.php';
      $query = "SELECT * FROM post";
      $result = mysql_fetch_assoc($query);
      while ($row = mysql_fetch_array($result)){
          if ($row['ptime'] = $_ptimeValref){
              $post['url'] = $row['post'];
              $post['title'] = $row['title'];
              $post['ptime'] = $row['ptime'];
              }
          }
      return $post;     
  }

i think u r missing the actual queryin part. you'll obviously need mysql_query(....) ainni?
i think ur $result shud be equated to mysql_query($query)

kekkaishi 18 Junior Poster

this is my new code and its works a lot better now thanks, theres still a few changes ive gotta make but the basics is there

$out = "Out of stock";
$in = "In Stock";
$limit = "Limited Stock Available"; 

$qresult = mysql_query("SELECT * FROM crossref WHERE stock >= $qty AND part = \"$pt\"");
    $row = mysql_fetch_array($qresult);
{
do 
{
    echo "<table style='font-size:10px; font-family: arial;' width=1000px>";
    echo "<tr>";
    echo "<td width='20%'>".$row[part]."</td>";
    echo "<td width='40%'>".$row[desc]."</td>";
    echo "<td width='15%'>".$row[xref]."</td>";
    echo "<td width='15%'>".$row[zref_model]."</td>";
    echo "<td width='10%'>"; 
        if ($row['stock'] == $qty){
            echo $limit;
            }
        elseif ($row['stock'] >= $qty){
            echo $in;
            }
        elseif ($row['stock'] <= $qty){
            echo $out;
            }
    echo "</td>";
    echo "</tr>";
    echo "<tr><td colspan='5'><hr></td></tr>";
    echo "</table>";

}
while($row = mysql_fetch_array($qresult));
} 

end quote.

kewl, but u also might wanna keep the table head outside the loop. sorry i couldnt tell u this earlier. slipped ma mind. anyways, if u r gonna keep ur code this way, u r creating a new table each time the loop is run n ur pages MIGHT run slower as ur database gets bigger. so anyways, the best way is to play around with no fear :D it's always hard in the beginning. n now ive gotta go. so good luck.

kekkaishi 18 Junior Poster

ur an absolute genius thanks for this its a massive help and now works great, sorry i wasnt much of a help its just im still getting used to php

thanks again

good luck mate but while u r at it, i think the following blocks of codes are not necessary.

$qresult = mysql_query("SELECT part,stock FROM table WHERE stock >= $qty AND part = \"$pt\"");
//AND
$row = mysql_fetch_array($qresult);

//since u r doing the same with the following code. 

$string = ("SELECT * FROM table WHERE stock >= $qty AND part = \"$pt\"")
or die("Please enter a part number");
//and while at it change $string to the following. u dont need or die() coz u r doin so under $query = mysql_query..... get what i mean?
//$string = "SELECT * FROM table WHERE stock >= $qty AND part = \"$pt\"";
$query = mysql_query($string) or die (mysql_error());

//AND of course all those if's at the very bottom aint necessary.

and i find this site, http://www.tizag.com/phpT/, very helpful for learnin n for references.

kekkaishi 18 Junior Poster

i dont think im getting anywhere with this, im just not knowledgable enough about php at the moment, i literally only have about 4 weeks of php knowledge.

aany help would be much appreciated

c if this works.

//echo "<td width='20%'>".$result[stock]."</td>";
//instead of this, try the following
echo "<td width='20%'>"; 
if ($result['stock'] == $qty){
   echo $exact; 
}
echo "</td>";
dandixon commented: really took the time to help me out +1
kekkaishi 18 Junior Poster

that is exactly what i want, ill have a mess around with the code now

kewl,:) lemme know what happens, i'll be around for a while if you need any help.

kekkaishi 18 Junior Poster

ive removed the quotes and thats starting to look a lot better, i just need it to put the result ("exact") in place of the stock("3").

just to clarify, u dont want to display the quantity in the table, instead, you want it to be either exact, out of stock or In stock

for example,
A9190 SENSOR ASSY 90DEG 450MM 0233170500 TTC Exact

if this is the case, u might wanna concentrate on this part of ur code.

echo "<td width='20%'>".$result[stock]."</td>";

hint: u want this row to display Exact if $row = $qty.. so on n so forth..

kekkaishi 18 Junior Poster

also u might wanna check the following in ur code

while($result = mysql_fetch_array($query));
}
if(!$qresult || $row['stock'] < $qty) {
//I DONT THINK U NEED "" , try echo $out;
echo "$out";
}
elseif(!$qresult || $row['stock'] > $qty) {
echo "$in";
//change to echo $in;  remove quote
}
elseif(!$qresult || $row['stock'] = $qty) {
echo "$exact";
//remove quote echo $exact;
}
kekkaishi 18 Junior Poster

http://www.dandesign.co.uk/test/stock.php?partnum=a9190&quantity=3&Submit=Search

where the number three is i want it to say exact or not in stock etc and not where it is at the min

ok, let's try to go step by step. i need u to stay here with for a while :D im sure i'll be able to help ya out.

first of all, tell me, what are you trying to achieve here

$string = ("SELECT * FROM table WHERE stock >= $qty AND part = \"$pt\"")
or die("Please enter a part number");

m particularly trying to understand the "or die(..)" part

kekkaishi 18 Junior Poster

Im very new to php, but im trying to create a bit of code that you type in the part number and quantity you want and it returns the part number and the word "limited" if its the same "not enough" if it's less than and "in stock" if its more than, im having trouble getting it to say the word in the end column where i want it.

Here is the code, but please remember im very new to it so it might be a complete mess

<form id="search" name="form" action="stock.php" method="get">
<input type="text" name="partnum" width="50"/>
<input type="text" name="quantity" width="50"/>
<input type="submit" name="Submit" value="Search" />
</form>

<?php
include("namefile");

  $pt = @$_GET['partnum'] ;
  $qty = @$_GET['quantity'] ;

// check for an empty string and display a message.
if ($qty == "")
  {
  echo "<p>Please enter a search...</p>";
  exit;
  }

// check for an empty string and display a message.
if ($pt == "")
  {
  echo "<p>Please enter a search...</p>";
  exit;
  }

//connect to mysql
$connection = mysql_connect($host,$account,$password)
    or die ("Couldn't connect to server");

//select which database you want to edit
$db = mysql_select_db("dbname",$connection)
    or die ("Couln't connect to database");

$out = "Out of stock";
$in = "In Stock";
$exact = "Exact";   

// SQL Query  
$string = ("SELECT * FROM table WHERE stock >= $qty AND part = \"$pt\"")
    or die("Please enter a part number");

$qresult = mysql_query("SELECT part,stock FROM table WHERE stock >= $qty AND part = \"$pt\"");
$query = mysql_query($string) or die (mysql_error());
    $row = mysql_fetch_array($qresult);
    { …