Jump to content

[SOLVED] how do you repead an if?


gurhy

Recommended Posts

Hi all

 

just wondering if any 1 know how to make this work?

 

<?
$main_page = mysql_query("SELECT * FROM menu") or die(mysql_error()); 

while ($row = mysql_fetch_array ($main_page)) {
if($owh == $row["url"]) { include("$row[url2]"); }
}
?>

 

at the moment it anly displays the first page in the database but I would like it to pull all the info from it (every row) which is only 10 rows.

 

I am not sure what to do :(

Link to comment
Share on other sites

<?php

$sql = "SELECT * FROM `menu`";
$res = mysql_query($sql) or die(mysql_error());

while($row = mysql_fetch_assoc($res)){
if($owh == $row['url']){
	include $row['url2'];
}else {
	include $row['url3'];
}
}

?>

 

something like that i suppose.

Link to comment
Share on other sites

do this:

 

<?php

$sql = "SELECT * FROM `menu`";
$res = mysql_query($sql) or die(mysql_error());

echo "<table border=\"0\" cellspacing=\"3\" cellpadding=\"3\">\n";
echo "<tr><td>Menu ID</td><td>URL One</td><td>URL Two</td></tr>\n";
while($row = mysql_fetch_assoc($res)){
echo "<tr><td>".$row['id']."</td><td>".$row['url']."</td><td>".$row['url2']."</td></tr>\n";
}
echo "</table>\n";

?>

Link to comment
Share on other sites

yea all in database are correct

 

here is whats printed mgallforever

 

Menu ID URL One URL Two

1  main.php

2 ?owh=product /pages/product.php

5 ?owh=Services pages/product.php

6 ?owh=Programs pages/product.php

 

 

10 ?owh=Order pages/product.php

11 ?owh=Policy pages/product.php

12 ?owh=Agreement pages/product.php

13 ?owh=Copyright pages/product.php

 

 

page is not meant to display like that though so I am guessing you wanted to see if it printed any thing out

Link to comment
Share on other sites

I see.

 

Remove ?owh=

 

from each of the $row['url']

 

or you can do something like:

 

<?php

$owh = $_GET['owh'];

$sql = "SELECT * FROM `menu`";
$res = mysql_query($sql) or die(mysql_error());

while($row = mysql_fetch_assoc($res)){
$splode = explode('=',$row['url']);

if($splode[1] == $owh){
	include $row['url2'];
}
}

?>

Link to comment
Share on other sites

I just used that script and now it reports all the pages like I need now I can add propa products and services.

 

1 bit I dont get is why I am now getting this error after adding this in :S

 

Warning: main() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/owhostin/public_html/index1.php on line 56

 

Warning: main() [function.include]: Failed opening '' for inclusion (include_path='.:/usr/lib/php:/usr/local/lib/php') in /home/owhostin/public_html/index1.php on line 56

Link to comment
Share on other sites

hmmm

 

that code u just sent just got rid of the error, but dont want File does not exist! to be showing up on my main page, hehe

 

dont get what file does not exist as all files do exist.

 

Dont get what you mean Check your PHP.INI include path setting. what do you mean about include path setting????

 

I do not control this php.ini so

Link to comment
Share on other sites

well just checked but the page thats loading is there and is showing but that bit of script is also saying that the page dont exist. confusing. guess I have to keep that error and just leave that echo "File does not exist!\n";  blank so its just echo ""; cos I see all pages are loading and at the moment they are all still product.php for every page and no other url is visable

 

 

so I leave that echo blank and no 1 ever notice the differnce while looking at the website :) like a friendly patch on the error hehe :)

 

 

 

Thanks for all you help guys :) as this been bugging me for ages and never woulda got as far as I have with out you all here :)

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.