Jump to content


cms help


5 replies to this topic

#1 Jynxis

    Young Padawan

  • Members
  • Pip
  • 132 posts
  • Location:The Shadows

Posted 23 July 2005 - 02:50 PM

okay im creating a lil cms site.... now its all gone great (60% complete)...

but wut i want to do is... when they post... a quote is added.... but how to have it so that its dynamic and changes when the poster changes their quote(signature).

i tried it this way... and it didnt work...

function signature($Author) { 
  $result = @mysql_query("SELECT * FROM members WHERE username = \"$Author\"");
  while ($userinfo = mysql_fetch_array($result)){
 echo"$quote";
}
}

function topics($tid, $cat){

   global $strategy_table_width, $rank, $strategyteam, $userinfo;
$sql = "SELECT * FROM topics WHERE category = $cat AND id = $tid ";
  $result = mysql_query($sql) 
    or die(mysql_error());
  echo"<table width=100% border=0 cellspacing=0 cellpadding=0>
  <tr>
    <th width=94% scope=row>&nbsp;</th>
    <th width=6% scope=row><a href=addtopic.php?sid=$_GET[cat]><img src=images/buttons/newtopic.gif width=95 height=23 border=0></a></th>
  <th width=6% scope=row><a href=postreply.php?tid=$_GET[tid]><img src=images/buttons/newreply.gif width=95 height=23 border=0></a></th>
  </tr>
</table>";
    while ($row = mysql_fetch_array($result)){
echo "<br>
<table width=$strategy_table_width border=1 align=center cellpadding=0 cellspacing=1 bordercolor=999999>
        <tr>
          <th><p>
<table width=100% border=1 cellpadding=0 cellspacing=0 bordercolor=999999 style='border: 1px #000000;'>
 <tr>
    <td width=21% background=images/headerbg.gif colspan=2>Title:$row[Title]</td>
    <td width=51 background=images/headerbg.gif colspan=2><table width=231 height=27  border=0 cellspacing=0 cellpadding=0>
  <tr>
    <th scope=row>Author: $row[Author]</th>
  </tr>
</table></td>
    <td width=81 background=images/headerbg.gif colspan=2><table width=231 border=0 cellspacing=0 cellpadding=0>
  <tr>
    <th scope=row>Date Posted: $row[Date]</th>
  </tr>
</table></td>
  </tr>
  <tr>
    <td><p align=center>$row[Author]<br><br><br>
      D'OH town<br>
      <img src=images/avatars/noavatar.gif><br>
      [Post_count]<br>
      Hellsville<br>
      Warning: 0%</p>
      <p>&nbsp;</p></td>
    <td colspan=5><table width=100% height=100% border=0 cellpadding=0 cellspacing=0>
      <tr valign=top>
        <th scope=row><div align=left>$row[Post] </div></th>
      </tr>
    </table>";
	echo"
      <table width=100% border=0 cellspacing=0 cellpadding=0>
        <tr valign=bottom>
          <th scope=row><div align=left>"; signature('$row[Author]'); echo"</div></th>
        </tr>
      </table></td>
  </tr>
  <tr>
   </tr>
  <tr>
    <td colspan=6 background=images/footerbg.gif><div align=right>";
  
	echo("<table width=100 border=0 align=right cellpadding=0 cellspacing=0>
      <tr>
        <td scope=row><div align=center><a href=postmodify.php?poc=t&tid=$row[id]>Edit</a></div></td>
      </tr>
    </table>"); 
	} 
	echo"</div></td>
  </tr>
</table>
     </th>
        </tr>
      </table><br>

";
}

Edited by PlaGuEX, 24 July 2005 - 02:24 PM.


#2 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 23 July 2005 - 09:39 PM

first off, there's a few things you need to know about php/mysql.
1. When using double quotes on an sql query, you can use single quotes "inside" the query so you don't have to escape everything (example below).
2. mysql_fetch_array() returns an array. Which means that unless you extract the results, then you have to access then through the variable you set in the while() statement.
i.e.
$quote, and $userinfo['quote'], are two completely different variables.

With that said, try changing your function to this:
function signature($Author) { 
 $result = @mysql_query("SELECT * FROM members WHERE username = '$Author'");
 while ($userinfo = mysql_fetch_array($result)){
echo $userinfo['quote'];
}
}


#3 Jynxis

    Young Padawan

  • Members
  • Pip
  • 132 posts
  • Location:The Shadows

Posted 23 July 2005 - 09:59 PM

uhh... thats one of the FIRST things ive tried...

edit:
heh... i got it to work... lol ... i guess i went signature($row['author']);

in a revision... and i didnt notice it... thanks for the help tho.. lol

wut i was really wanting to do was have a global variable for the user... so that i could do $userinfo[quote], $userinfo[location], $userinfo[] n stuff...lol

but if i must to separate functions for each... tehn i shall do that...

#4 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 24 July 2005 - 12:05 PM

Thanks for making great use of the edit feature!

If you want a "global" variable, then do something like this:
function signature($Author) { 
  $result = @mysql_query("SELECT * FROM members WHERE username = '$Author' LIMIT 1");
  return mysql_fetch_array($result);
}

$userinfo = signature($row['author']);


#5 Jynxis

    Young Padawan

  • Members
  • Pip
  • 132 posts
  • Location:The Shadows

Posted 24 July 2005 - 02:32 PM

wut you mean edit... hehe...

ill try that...


but here's another question thats eluded me... sumtin thats worked everywhere else... but here....

$tid = $_GET['tid']; //Added to test if it was problem
mysql_query("DELETE FROM topics WHERE id = '$tid' AND cid = '$tid'");

Edited by PlaGuEX, 24 July 2005 - 02:33 PM.


#6 rc69

    PHP Master PD

  • P2L Staff
  • PipPipPipPip
  • 3,827 posts
  • Gender:Male
  • Location:Here
  • Interests:Web Development

Posted 25 July 2005 - 01:15 AM

and the exact problem is...?





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users