08-22-2006, 01:42 PM
|
#11 (permalink)
|
|
Junior Member
Join Date: Aug 2006
Posts: 19
|
Re: PHP form for entering data to MySQL database
bo i mean why you fill the form in it has a multi line text box and you type it in and hit enter for a new line and send it and when you call the data up again it is how the user saved it
Last edited by penguinsrule : 08-22-2006 at 02:25 PM.
|
|
|
08-22-2006, 08:09 PM
|
#12 (permalink)
|
|
Moderator Of The Year
Join Date: Jul 2006
Location: Cali Breeze
Posts: 716
|
Re: PHP form for entering data to MySQL database
Fair enough let the record show " If your going to use PHP at all on your site its easier to to use all the Extension PHP's"
|
|
|
08-22-2006, 08:20 PM
|
#13 (permalink)
|
|
Junior Member
Join Date: Aug 2006
Posts: 19
|
Re: PHP form for entering data to MySQL database
Any body got a solution to my problem.
when you enter the data into a form you type a bit hit enter do i bit more and when you hit enter can you tell it to add in <br> or somthing to start a new paragrph so when it comes to showing it isnt one big block.
|
|
|
08-22-2006, 10:55 PM
|
#14 (permalink)
|
|
Junior Member
Join Date: May 2006
Location: Near Frankfurt
Posts: 26
|
Re: PHP form for entering data to MySQL database
Quote:
|
Originally Posted by No0oB
Theres an easy function in PHP called nl2br()
So basically, when you call $row['notes'] (or whatever your variable for the MySQL output is) you use the function to do so
PHP Code:
echo nl2br($row['notes']);
|
I have recently posted this in this thread
|
|
|
08-22-2006, 11:00 PM
|
#15 (permalink)
|
|
Junior Member
Join Date: Aug 2006
Posts: 19
|
Re: PHP form for entering data to MySQL database
yeah i know but it selects all the rows of that field and displays them one below the other what i dont want i want one row to do that.
entered in forum
#cheat hello
rfuihriuvbriuvbr;
rviubruivbrvruibv;
ribvruibvrivbrvb;
Comes out like
#cheat hello rfuihriuvbriuvbr; rviubruivbrvruibv; ribvruibvrivbrvb;
I want it like the orginal any ideas please
|
|
|
08-22-2006, 11:01 PM
|
#16 (permalink)
|
|
Junior Member
Join Date: May 2006
Location: Near Frankfurt
Posts: 26
|
Re: PHP form for entering data to MySQL database
But the nl2br() turns all the newlines (\n) into <br> for HTML :/
|
|
|
08-22-2006, 11:04 PM
|
#17 (permalink)
|
|
Junior Member
Join Date: Aug 2006
Posts: 19
|
Re: PHP form for entering data to MySQL database
cool how you use it this is what my show thing looks like
PHP Code:
<script language="javascript" type="text/javascript">
function showCheat(CheatID) {
var codeDIV = document.getElementById("cheat_" + CheatID);
var linkDIV = document.getElementById("cheat_" + CheatID + "_show");
if (codeDIV.style.display == "block") {
linkDIV.childNodes[0].nodeValue = "View Cheat";
codeDIV.style.display = "none";
} else {
linkDIV.childNodes[0].nodeValue = "Hide Cheat";
codeDIV.style.display = "block";
}
}
</script>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
var win = null;
function newWindow(mypage,myname,w,h,features) {
var winl = (screen.width-w)/2;
var wint = (screen.height-h)/2;
if (winl < 0) winl = 0;
if (wint < 0) wint = 0;
var settings = 'height=' + h + ',';
settings += 'width=' + w + ',';
settings += 'top=' + wint + ',';
settings += 'left=' + winl + ',';
settings += features;
win = window.open(mypage,myname,settings);
win.window.focus();
}
// End -->
</script>
<style type="text/css">
<!--
body,td,th {
color: #006699;
}
a {
font-size: 12px;
}
a:link {
color: #006699;
text-decoration: none;
}
a:visited {
text-decoration: none;
color: #006699;
}
a:hover {
text-decoration: underline;
color: #006699;
}
a:active {
text-decoration: none;
color: #006699;
}
.style2 {font-size: 12px}
.style4 {font-size: 10px; }
.style6 {color: #006699}
.style8 {font-size: 12px; color: #cccccc; }
body {
background-color: #CCCCCC;
}
-->
</style>
<?
echo "<b>Environment Codes</b><br><br><br>";
include "config.php";
$query = "SELECT * FROM environment ORDER BY cheat_id DESC";
$result=mysql_query($query) or die (mysql_error());
$aantal = mysql_num_rows($result);
if ($aantal==0) {
echo "There are no Cheats.";
}else{
while ($sql = mysql_fetch_assoc($result)) {
echo "<table width=618 border=0 cellpadding=0 cellspacing=3><tr><td width=15><img src=pictures/ok.PNG width=15 height=15 align=middle /></td><td width=30><a href=#null onclick=newWindow('".$sql['pic']."','','500','300')><img src=pictures/camera.PNG width=30 height=23 border=0 /></a></td><td colspan=5><strong>Title:</strong> ".$sql['cheat_name']."</td></tr><tr><td> </td><td> </td><td colspan=5><span class=style2><strong>Description:</strong>".$sql['cheat_des']."</span></td></tr><tr><td height=19> </td>
<td> </td>
<td colspan=5><div id=cheat_".$sql['cheat_id']." class=cheatlist_code style=display:none;>
"nl2br($row['cheat'])"
</div></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td width=154><span class=style2><strong>Submitted:</strong>".$sql['date']."</span></td>
<td width=60><span class=style8><strong>Size: 8.00kb</strong></span></td>
<td width=200><span class=style2><strong>Author:</strong> ".$sql['author']."</span></td>
<td><div align=right>
<iframe src=countd.php?file=telstadv1 align=right width=20 marginwidth=0 height=20 marginheight=0 scrolling=No frameborder=0 class=style6></iframe>
</div></td>
<td><a href=dntelstadv1.php><img src=pictures/download.gif width=75 height=15 border=0 align=right /></a></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td colspan=2> </td>
<td width=60> <td align=right><a href=javascript:showCheat('".$sql['cheat_id']."'); id=cheat_".$sql['cheat_id']."_show>View Cheat</a>
</div></td>
</tr>
<tr>
<td height=19 colspan=7><hr></td>
</tr>
</table>";
}
}
?>
Last edited by penguinsrule : 08-22-2006 at 11:16 PM.
|
|
|
08-23-2006, 02:29 PM
|
#18 (permalink)
|
|
Junior Member
Join Date: May 2006
Location: Near Frankfurt
Posts: 26
|
Re: PHP form for entering data to MySQL database
PHP Code:
<?
echo "<b>Environment Codes</b><br><br><br>";
include "config.php";
$query = "SELECT * FROM environment ORDER BY cheat_id DESC";
$result=mysql_query($query) or die (mysql_error());
$aantal = mysql_num_rows($result);
if ($aantal==0) {
echo "There are no Cheats.";
}else{
while ($sql = mysql_fetch_assoc($result)) {
echo "<table width=618 border=0 cellpadding=0 cellspacing=3><tr><td width=15><img src=pictures/ok.PNG width=15 height=15 align=middle /></td><td width=30><a href=#null onclick=newWindow('".$sql['pic']."','','500','300')><img src=pictures/camera.PNG width=30 height=23 border=0 /></a></td><td colspan=5><strong>Title:</strong> ".$sql['cheat_name']."</td></tr><tr><td> </td><td> </td><td colspan=5><span class=style2><strong>Description:</strong>".$sql['cheat_des']."</span></td></tr><tr><td height=19> </td>
<td> </td>
<td colspan=5><div id=cheat_".$sql['cheat_id']." class=cheatlist_code style=display:none;>
".nl2br($sql['cheat'])."
</div></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td width=154><span class=style2><strong>Submitted:</strong>".$sql['date']."</span></td>
<td width=60><span class=style8><strong>Size: 8.00kb</strong></span></td>
<td width=200><span class=style2><strong>Author:</strong> ".$sql['author']."</span></td>
<td><div align=right>
<iframe src=countd.php?file=telstadv1 align=right width=20 marginwidth=0 height=20 marginheight=0 scrolling=No frameborder=0 class=style6></iframe>
</div></td>
<td><a href=dntelstadv1.php><img src=pictures/download.gif width=75 height=15 border=0 align=right /></a></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td colspan=2> </td>
<td width=60> <td align=right><a href=javascript:showCheat('".$sql['cheat_id']."'); id=cheat_".$sql['cheat_id']."_show>View Cheat</a>
</div></td>
</tr>
<tr>
<td height=19 colspan=7><hr></td>
</tr>
</table>";
}
}
?>
You don't have a variable called $row, therefore it is stupid to use my example word by word 
Your variable for fetching the MySQL Data is $sql, so you use that instead.
Also, you should have a look at escaping, as you didnt escape nl2br()!
Another thing is that your HTML Code is not valid at all. You forget the " at every attribute
|
|
|
08-23-2006, 02:39 PM
|
#19 (permalink)
|
|
Junior Member
Join Date: Aug 2006
Posts: 19
|
Re: PHP form for entering data to MySQL database
oh i have no other idear to do it how i want, but can you put it the nl2br($row['cheat']) hing in so it works please
|
|
|
08-23-2006, 02:49 PM
|
#20 (permalink)
|
|
Junior Member
Join Date: May 2006
Location: Near Frankfurt
Posts: 26
|
Re: PHP form for entering data to MySQL database
I think I already fixed it, as I escaped the function and changed $row['cheat'] to $sql['cheat']
Have you tried copying my code?
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
Points Per Thread View: 1.00
Points Per Thread: 11.00
Points Per Reply: 5.00
|
|
|
|
|