Issues showing rows

Hi,

I’ve been trying to work something out with Freeway and PHP/MySQL and can’t get it to work right.

What I really want to do is similar to the easibase example called mysql_get_rows-show a list of items and make at least one column in the row a link to be able to edit all the columns of that row. I did choose to use my own scripts to connect to the db like what Mike B.'s examples do. The connection is fine. My problem is I have a table drawn on my Freeway page with Markup items echoing my variables. When I publish the page and look at in Safari, the whole table disappears. I’ve even tried to do it in the same setup as the Axiom example using Actions and basically the same thing happens-the table or html blocks I put the variables in just disappears. I even copied the code from my practice page that works and those items were fine.

I tried making sure my table was in the front or in the back.

I hope this makes sense. I’m sure this is actually really easy but I just don’t see it.

Thanks for any help.

Brian


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Are you looking at it in Safari from your Web server (which is running
PHP and talking to the database)? If so, you may have a PHP error, and
your server may be configured to hide those from you (default behavior).

Add the following as high up in your script as possible – ideally,
right after the opening <?php code.

ini_set('display_errors',1);
error_reporting(E_ALL);

That turns on all the bad news, and then it’s (usually) a matter of
tracking down the problems one at a time until everything works.

If you are trying to view your PHP coded page locally using Freeway’s
internal preview or even Preview in Browser, you won’t ever see
anything, because the PHP interpreter isn’t getting called and thus
the best you can hope to see is a page full of code.

Walter

On Apr 7, 2009, at 3:07 AM, Brisprad wrote:

When I publish the page and look at in Safari, the whole table
disappears. I


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Walter,

Thanks once again for coming to my rescue.

The site is being served on my computer right now. I don’t know if you remember helping me last summer to get PHP and MySQL working.

I added your suggestion and the page now shows:

“Notice: Use of undefined constant track_level - assumed ‘track_level’…on line 19.”

It shows this for the next 2 lines of code as well. Each line are my variables. Do I have the array set up wrong?

My code for the array is:

$query = “SELECT DISTINCT track_name FROM tracks ORDER by track_level”;
$result = @mysql_query($query) or die (mysql_error());

while($row = mysql_fetch_array($result));

{
$level = $row[track_level];
$name = $row[track_name];
$description = $row[track_description];
}

$z = count($level);
?>

Hope this all makes sense. Thanks again for your help.

Brian

On 7 Apr 2009, 7:24 am, waltd wrote:

Are you looking at it in Safari from your Web server (which is running PHP and talking to the database)?


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Quick question. How do I do the code so it shows in the boxes?

Brian


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

These warnings are about code style. PHP corrected your mistake,
effectively turning

$level = $row[track_level];

into

$level = $row['track_level'];

See the (subtle) difference? The $row variable is an array, and you
are choosing one of the elements of the array by adding its index in
square brackets after the variable name. Only numerical indices are
allowed to be “bare” (without quotes).

Walter

On Apr 7, 2009, at 5:53 PM, Brisprad wrote:

“Notice: Use of undefined constant track_level - assumed
‘track_level’…on line 19.”

It shows this for the next 2 lines of code as well. Each line are
my variables. Do I have the array set up wrong?


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Could you pastie the code you’re using to display the variables, after
you’ve gathered them from the database? I’m guessing here that you may
be missing that part, but in any case you haven’t included it in your
code examples so far. If you use pastie.org, you can put the entire
generated page up where we can look at it (obfuscate your passwords if
you’ve got them in this code, please)

Walter

On Apr 7, 2009, at 5:54 PM, Brisprad wrote:

Quick question. How do I do the code so it shows in the boxes?

Brian


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Walter,

Here’s the link to pastie:
http://www.pastie.org/441216

The table I have tried to put the variables in is at the bottom. The table is named cellblock if that helps.

I did make a change and it still doesn’t work. I just put the variable names in the table cells. Previously I had put them in a Markup Item. What’s the difference?

For snippets of code, how do you use the boxes? Is it just embedded using Pastie?

Thanks again for your help. I really appreciate it.

Brian

Could you pastie the code you’re using to display the variables, after
you’ve gathered them from the database?

Walter

On Apr 7, 2009, at 5:54 PM, Brisprad wrote:

Quick question. How do I do the code so it shows in the boxes?

Brian


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Gaaaaaa! Please turn on More Readable in your Document Setup settings
– it’s in the Output pane IIRC.

If you want to make a variable display, you need to set it to a value,
then either use print() or echo() to send it to the browser.
Otherwise, it just sits there in PHP’s model of the page, and goes
nowhere until you tell it to.

<?php
$foo = $row['foo'];
//okay, now it's a named variable

print $foo;
print($foo);
echo $foo;
echo($foo);

//those are all equivalent to one another
?>

Now, if you are going to put a big lump of “get the variables
together” code at the top of your page, you can sprinkle little “print
this variable here” snippets into your layout, you can use the “short
tag” syntax, as long as your server has been configured to use it.

<?=$foo?>

Note that you don’t need the trailing semi-colon when you use this
format. This is equivalent to

<?php print $foo; ?>

if your server doesn’t allow the short form.

As to the snippets, if you mean on the Web form of this list, then I
use Markdown Extra formatting. If you have a block of code to show,
put four tildes ~ in a row alone on one line, return, add your code,
return, and another four tildes to close it off. If you’re writing on
the Web form, you’ll have a live preview to show if you got it right.
You can also use four spaces in front of each line of your code block,
and at least two full line-breaks before and after the code to
separate it from the nearest paragraph of normal text.

Walter

On Apr 8, 2009, at 6:07 PM, Brisprad wrote:

The table I have tried to put the variables in is at the bottom. The
table is named cellblock if that helps.

I did make a change and it still doesn’t work. I just put the
variable names in the table cells. Previously I had put them in a
Markup Item. What’s the difference?

For snippets of code, how do you use the boxes? Is it just embedded
using Pastie?


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi again,

Sorry it took me a bit to reply but I have good news-I was able to get my table to display what I wanted it to do. I basically followed the setup within the Axiom example. I did it on a new page and it worked!

Thank you for explaining. My next step is to get the table to display a column as a link to an edit page. I have some examples to use-I just need to digest it. I understand it in theory but mess up somehow on execution.

I did have one more question. As far as style, which is it better to do-design a page using the Actions like in the Axiom example or to do it long hand like Mike B’s excellent examples? Having never really done this kind of stuff before, I like the ease of the Action way (that’s also why I started using Freeway to begin with).

Gaaaaaa! Please turn on More Readable in your Document Setup settings
– it’s in the Output pane IIRC.

I’m so sorry my page was so ugly! I never noticed this setting before. Until now, most of my pages have looked the way I intended and I have hardly ever looked at the HTML.

Thanks again Walter for all of your help. I am still amazed that you have the time to help so many here.

Brian


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

It’s not that it’s ugly, it’s that it’s a face only a browser could
love. Browsers don’t need whitespace to figure out what the code
means, but us poor humans need all the help we can get!

Walter

On Apr 10, 2009, at 1:52 AM, Brisprad wrote:

I’m so sorry my page was so ugly! I never noticed this setting before.


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Eventually, you may run out of road with the Actions. They work, and
they work really well. But they are each one-trick-ponies, and once
you’ve used that trick, you can’t get them to do anything else if
that’s what you need. My own recommendation would be that you learn to
do it long-hand, even if you do use the Actions for part of the job.
You can mix and match, if you know how to do it yourself.

Walter

On Apr 10, 2009, at 1:52 AM, Brisprad wrote:

I did have one more question. As far as style, which is it better to
do-design a page using the Actions like in the Axiom example or to
do it long hand like Mike B’s excellent examples? Having never
really done this kind of stuff before, I like the ease of the Action
way (that’s also why I started using Freeway to begin with).


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

On 10 Apr 2009, 5:52 am, Brisprad wrote:

Thank you for explaining. My next step is to get the table to display a column as a link to an edit page. I have some examples to use-I just need to digest it. I understand it in theory but mess up somehow on execution.

You can create links from the data returned simply by adding some code to the while loop.

Say you where pulling $row[‘name’] from the database and you wanted to use that text as the link to the edit page, then you probably get this value as:

$name = $row['name'];
echo $name;

or

echo $row['name'];

or some other way for showing in the results table…

so to show a link to a page called ‘edit.php’ you could do that by using something like:

if ($row['name']) {
 $name = '<a href="add_path_to_file_directory_here/edit.php">' . $row['name'] . '</a>";
} else {
 $name = 'No Name';
}

you can even add to the URL to make another query before loading the edit page, say if you wanted to pull the data from that entry to populate the edit page form elements, simply add the data id to the URL, possibly as follows:

if ($row['name'] && $row['id']>0) {
 $name = '<a href="add_path_to_file_directory_here/edit.php?id=' . $row['id'] . '">' . $row['name'] . '</a>";
} else {
 $name = 'No Name';
}

Now you just include a script to make a query at the top of the edit page, something like:

if ($id >0 && is_int($id)) {
 $query = “SELECT * FROM `tracks` WHERE `id` = $id";
} else {
 // Whatever
}

// mysql_query() here

// while($row = mysql_fetch_array($result)); here

// Now here just set the data variable names as that of the edit form.
// $name = $row['name']
// etc.

The form elements will now be populated with the data from that database entry relative to the query.

HTH


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options

Hi Walter & Mike,

Thanks again for all the good advice. I haven’t had time to try anything since last Thursday due to my regular job and Easter but am eager to.

I’ll let you know how it all works out.

Thanks again!

Brian


dynamo mailing list
email@hidden
Update your subscriptions at:
http://freewaytalk.net/person/options