Page 2 of 3

Posted: Sun Jul 04, 2004 11:07 am
by scorphus
Mmmm... it seems you're using Internet noteffExplorer so you're not able to see the effect achieved by style="display: block; overflow: auto;". Try Mozilla Firefox to see it.

Anyway, I fiddled a bit with textarea, see what I've got: http://scorphus.no-ip.com/lab/testimonials/

-- Scorphus

Posted: Sun Jul 04, 2004 7:02 pm
by Lucnet
Yes thats what I wanted. Thanks it works great. You can see final here http://www.lsscripts.com/projects/testi ... in/new.php

As you can see I have plans to add some buttons and a couple more options. Like the ability to show ones I have approved and ones I have questions about. All I can do now is show the news one submitted. I am unsure on how to make it view ones on hold and ones already approved. The biggest thing is getting a page to open in itself instead of have three different pages for each button. But I am sure I will figure it out as I have gotten this far already. If you have any ideas on a good way to go about it. I will appreciate the advice.

Thanks, again for the help scorphus. :D

Posted: Mon Jul 05, 2004 2:41 pm
by scorphus
Great! I'm glad it works for you :)

To use only one page to show new, on hold and approved testimonials you could imnplement something like this:

1- Change the links:

Code: Select all

<a href="add.php">Add Testimonials</a>
<a href="show.php?status=new">New Testimonials</a>
<a href="show.php?status=onhold">On Hold Testimonials</a>
<a href="show.php?status=approved">Active Testimonials</a>
2- Create the show.php page, which will be somehow like those new.php, onhold.php and approved.php:

Code: Select all

<?php
// ...
// copy the 'status' passed via GET:
$status = (!empty($_GET['satus']) ? $_GET['satus'] : '%');
// ... connect to DB ...
// change your query i.e.:
$query = "SELECT * FROM testimonials WHERE status LIKE '$status'";
// ... show the testimonials ...
// ...
?>
Hope that helps, looking forward hearing your feedback!

Regards,
Scorphus.

Posted: Mon Jul 05, 2004 4:06 pm
by Lucnet
I made the adjustment, but it has caused an error with my mysql_fetch_object. You can see the full error here http://www.lsscripts.com/projects/testi ... n/show.php

Posted: Tue Jul 06, 2004 12:57 pm
by scorphus
It sems that the query is wrong. You must catch the DB error message this way:

Code: Select all

<?php
// ...
// copy the 'status' passed via GET:
$status = (!empty($_GET['satus']) ? $_GET['satus'] : '%');
// ... connect to and select database ...
// change your query i.e.:
$query = "SELECT * FROM testimonials WHERE status LIKE '$status'";
// query the database:
$result = msql_query("SELECT * FROM table WHERE id=1", $link) or die("query ($query) failed: " . mysql_error()); // do not echo your query, it is just for the sake of a test
// ... show the testimonials ...
// ...
?>
Let us see the error message. Also, please post the code of show.php, you can remove passwords, db and server config and whatever information you think is irrelevant to what we are arguing here.

Regards,
Scorphus.

Posted: Tue Jul 06, 2004 2:16 pm
by Lucnet
Heres the show.php

Code: Select all

<?
/*Added this*/$status = (!empty($_GET['satus']) ? $_GET['satus'] : '%');
include "../inc/config.php";
switch($action) {
	case "approve":
		db();
		mysql_query("UPDATE ls_testimonials SET approved='y' WHERE id=$id");
		$pagecontent.="Item {$id} Approved<br><br>";
		db_close();
	break;
	case "hold":
		db();
		mysql_query("UPDATE ls_testimonials SET approved='h' WHERE id=$id");
		$pagecontent.="Item {$id} On Hold<br><br>";
		db_close();
	break;
	case "delete":
		db();
		mysql_query("DELETE FROM ls_testimonials WHERE id=$id");
		$pagecontent.="Item {$id} Deleted<br><br>";
		db_close();
	break;
	default:
	break;
}
db();
/*Added this*/ $query = "SELECT * FROM ls_testimonials WHERE status LIKE '$status'"; 
//$formdata_res=mysql_query("SELECT * FROM ls_testimonials WHERE approved='y'");
$pagecontent.="<table width=150 background=../inc/skins/default/images/menu_bg.gif>";
$pagecontent.="<tr><td><font color=#000000><b>Menu</b></font></td></tr>
<tr><td><font color=#000000><a href=add.php>Add Testimonials</a></font></td></tr>
<tr><td><font color=#000000><a href=show.php?status=n>New Testimonials</a></font></td></tr>
<tr><td><font color=#000000><a href=show.php?status=h>On Hold Testimonials</a></font></td></tr>
<tr><td><font color=#000000><a href=show.php?status=y>Active Testimonials</a></font></td></tr>";
$pagecontent.="</table>";
/*$pagecontent.="<table width=760>";
  $pagecontent.="<td width=175><center><a href='?id={$formdata->id}&action=approve'>approve</a> | ";
  $pagecontent.="<a href='?id={$formdata->id}&action=hold'>hold</a> | ";
  $pagecontent.="<a href='?id={$formdata->id}&action=delete'>delete</a> </center></td>";
  $pagecontent.="</tr>";
$pagecontent.="</table>";*/
$pagecontent.="<table width=760>";
$pagecontent.="<tr bgcolor=#CCCCCC><td width=233>Email</td><td width=230>Website</td><td width=233>Testimonial</td><td width=60>Action</td></tr>";
/*Error on this line*/ while ($formdata=mysql_fetch_object($formdata_res)) {
	$link_display=htmlentities($formdata->link_display);
	$email=htmlentities($formdata->email);
	$company=htmlentities($formdata->company);
	$testimonials=htmlentities($formdata->testimonials);
  $pagecontent.="<tr bgcolor=#EEEEEE>";
  $pagecontent.="<td><a href='mailto:{$email}'>{$email}</a></td>";
  $pagecontent.="<td><a href='{$company}' target=new>{$company}</a></td>";
  $pagecontent.="<td><textarea style=width=230; border: 0; rows=1>{$testimonials}</textarea></td>";
  $pagecontent.="<td><center><a href='?id={$formdata->id}&action=approve'><img src=../inc/skins/default/images/approve.gif width=17 height=17 border=0 ALT=Approve></a> ";
  $pagecontent.="<a href='?id={$formdata->id}&action=hold'><img src=../inc/skins/default/images/hold.gif width=17 height=17 border=0 ALT=Hold></a> ";
  $pagecontent.="<a href='?id={$formdata->id}&action=delete'><img src=../inc/skins/default/images/delete.gif width=17 height=17 border=0 ALT=Delete></a> </center></td>";
  $pagecontent.="</tr>";
}
$pagecontent.="</table>";
db_close();
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Approval Page</title>
</head>
<body>
<?=$pagecontent;?>
<br><br><br><br>

<!-- DO NOT REMOVE THIS CODE BELOW -->
<table width="750" border="0" cellpadding="0" cellspacing="0" >
  <tr>
    <td><center>
        <font size="2">Powered by: <a href=http://www.lsscripts.com>LS Testimonials</a></font> 
        <br>
        <font size="2">Ver. 1.0</font> 
      </center></td>
  </tr>
</table>
<!-- COPYRIGHT CODES END -->
</body>
</html>

Posted: Tue Jul 06, 2004 2:25 pm
by scorphus
You've commented the line where you really query the dtabase:

Code: Select all

<?php
// ...
//$formdata_res=mysql_query("SELECT * FROM ls_testimonials WHERE approved='y'");
// ...
?>
Change this line like this:

Code: Select all

<?php
//...
/*Added this*/ $query = "SELECT * FROM ls_testimonials WHERE status LIKE '$status'"; // Here just create a variable holding the query string
$formdata_res=mysql_query($query) or die("query failed: " . mysql_error()); // Here we send the query to the database server
// ...
?>
What you get then?

-- Scorphus

[edit]
Added or die(mysql_error()). Thanks feyd!
[/edit]

Posted: Tue Jul 06, 2004 2:32 pm
by feyd
don't forget to add "or die(mysql_error())" ;)

Posted: Tue Jul 06, 2004 5:38 pm
by Lucnet
That didn't do it ether.

I am getting this error now

Fatal error: Call to undefined function: msql_error() in /home/lsscript/public_html/projects/testimonials/admin/show.php on line 56

Posted: Tue Jul 06, 2004 5:51 pm
by feyd
mysql_error() not msql_error()

Posted: Tue Jul 06, 2004 6:07 pm
by scorphus
Lucnet, sorry for the mistype :oops:

And feyd, thanks again!

-- Scorphus

Posted: Tue Jul 06, 2004 6:15 pm
by Lucnet
OK now we are getting this error.

query failed: Unknown column 'status' in 'where clause'

Posted: Tue Jul 06, 2004 6:47 pm
by scorphus
Oh... just change 'status' to 'approved' ;)

-- Scorphus

Posted: Tue Jul 06, 2004 7:32 pm
by Lucnet
Ok that was it. Thanks.

Ok now another one for you. Hope you don't mind. How can I add a welcome page and add the add testimonial page.

Heres the index.php I am useing for a welcome. http://www.lsscripts.com/projects/testimonials/admin

Heres the add testimonial page
http://www.lsscripts.com/projects/testi ... in/add.php
I can go to it from the menu of the show.php. But it loads the add.php file.

Posted: Tue Jul 06, 2004 8:33 pm
by scorphus
I'm not sure if I understand you, but I think you want the 'Add Testimonial' page with same header (welcome message and stuff) as the main page.

Well, I think you better open a new thread in the Client Side forum. Try to reformulate your question and always post some code if you think it's relevant. I think you might have more chance to get answered there with a new thread.

Hope I can answer you there.

-- Scorphus