PHP - Php Search (basic Level)
Hi everyone,
I'm very new to PHP and have been following Kevin Yank's "How to build a db driven website using php & mysql" 3rd ed. and am working through Chapter 6, where a basic search page is created. What I would like to be able to do is, in the results, display not only the joketext (as done in the book), but also the author's name (which is located in a different table in the db), as well as the date it was submitted (in the same db as joketext), possibly a link to another site and extra info like the joke category. In general, I would like to be able to understand how to adjust the php code to add data related to the results of any given search. The information is already related through the database, how do I use it in the results of a search? I've used the same names of variables and tables as used in the book. Thank you in advance for any help you can offer! I really appreciate it. Below is the code for the part of the code I would like to change (highlighted parts) followed by the code for whole page (2 main sections "search" and "results". In the main code, the excerpt below is located a few lines from the bottom (in "results"): Note: the only variable currently displaying in the results in $joketext (also highlighted). Ok, enough explaining! /////////// EXCERPT : PART I WANT TO DISPLAY DIFFERENTLY ////////////// <?php echo "<li id=\"jump\"> <article class=\"entry\"> <header> <h3 class=\"entry-title\"><a href=''$VAR for email or weblink from author table">$VAR for author name from author table</a></h3> </header> <div class=\"entry-content\"> <p>$joketext</p></div> <footer class=\"entry-info\"> <abbr class=\"published\" title=\"2011-09-22T14:07:00-07:00\">$VAR for date uploaded in joke table</abbr> <p>$VAR for joke category from jokecategory table</p> </footer> </article> </li>"; } ?> //////////////////////////// MAIN CODE /////////////////////// <html> <body> . <header></header> . <section id="search"> <?php $dbcnx = @mysql_connect('localhost', 'root', 'password'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } if (!@mysql_select_db('ijdb')) { exit('<p>Unable to locate the joke ' . 'database at this time.</p>'); } $authors = @mysql_query('SELECT id, name FROM author'); if (!$authors) { exit('<p>Unable to obtain author list from the database.</p>'); } $cats = @mysql_query('SELECT id, name FROM category'); if (!$cats) { exit( '<p>Unable to obtain category list from the database.</p>'); } $themes = @mysql_query('SELECT id, name FROM theme'); if (!$themes) { exit( '<p>Unable to obtain category list from the database.</p>'); } $geofoci = @mysql_query('SELECT id, name FROM geofocus'); if (!$geofoci) { exit( '<p>Unable to obtain category list from the database.</p>'); } ?> <form class="searchField" name="input" action="main_search.php#jump" method="post"> <input type="text" name="searchtext"> <input type="submit" value="Search"> <ul> <li> <label><select name="aid" size="1"> <option selected value="">Any Author</option> <?php while ($author = mysql_fetch_array($authors)) { $aid = $author['id']; $aname = htmlspecialchars($author['name']); echo "<option value='$aid'>$aname</option>\n"; } ?> </select></label> </li> <li> <label><select name="cid" size="1"> <option selected value="">Any Category</option> <?php while ($cat = mysql_fetch_array($cats)) { $cid = $cat['id']; $cname = htmlspecialchars($cat['name']); echo "<option value='$cid'>$cname</option>\n"; } ?> </select></label> </li> <li> <label><select name="tid" size="1"> <option selected value="">Any Theme</option> <?php while ($theme = mysql_fetch_array($themes)) { $tid = $theme['id']; $tname = htmlspecialchars($theme['name']); echo "<option value='$tid'>$tname</option>\n"; } ?> </select></label> </li> <li> <label><select name="gfid" size="1"> <option selected value="">Any Region</option> <?php while ($geofocus = mysql_fetch_array($geofoci)) { $gfid = $geofocus['id']; $gfname = htmlspecialchars($geofocus['name']); echo "<option value='$gfid'>$gfname</option>\n"; } ?> </select></label> </li> <li><a href="">Closing Date</a></li> </ul> </form> </section> <section id="results"> <?php $dbcnx = @mysql_connect('localhost', 'root', 'password'); if (!$dbcnx) { exit('<p>Unable to connect to the ' . 'database server at this time.</p>'); } if (!@mysql_select_db('ijdb')) { exit('<p>Unable to locate the joke ' . 'database at this time.</p>'); } // The basic SELECT statement $select = 'SELECT DISTINCT id, joketext'; $from = ' FROM joke'; $where = ' WHERE 1=1'; $aid = $_POST['aid']; if ($aid != '') { // An author is selected $where .= " AND authorid='$aid'"; } $cid = $_POST['cid']; if ($cid != '') { // A category is selected $from .= ', jokecategory'; $where .= " AND joke.id=jokecategory.jokeid AND categoryid='$cid'"; } $tid = $_POST['tid']; if ($tid != '') { // A theme is selected $from .= ', joketheme'; $where .= " AND joke.id=joketheme.jokeid AND themeid='$tid'"; } $gfid = $_POST['gfid']; if ($gfid != '') { // A region is selected $from .= ', jokegeofocus'; $where .= " AND joke.id=jokegeofocus.jokeid AND geofocusid='$gfid'"; } $searchtext = $_POST['searchtext']; if ($searchtext != '') { // Some search text was specified $where .= " AND joketext LIKE '%$searchtext%'"; } ?> <ol id="results-list"> <?php $jokes = @mysql_query($select . $from . $where); if (!$jokes) { echo '</table>'; exit('<p>Error retrieving jokes from database!<br />'. 'Error: ' . mysql_error() . '</p>'); } while ($joke = mysql_fetch_array($jokes)) { $id = $joke['id']; $joketext = htmlspecialchars($joke['joketext']); echo "<li id=\"jump\"> <article class=\"entry\"> <header> <h3 class=\"entry-title\"><a href=''>variable title</a></h3> </header> <div class=\"entry-content\"> <p>$joketext</p></div> <footer class=\"entry-info\"> <abbr class=\"published\" title=\"2011-09-22T14:07:00-07:00\">Sept. 22, 2011</abbr> </footer> </article> </li>"; } ?> </ol> </section> . <footer></footer> . . </body> </html> Similar TutorialsThe result pages is supposed to have pagination like google help me please
Hi - I've got a program to allow the user to upload a file and then select, for each column of an existing table, the column from the new source table to insert. However, what I need to do is do the insert using the actual names, but show the user a drop-down menu of the LABELS they've chosen for each of these real, target columns. Is there a "clean" or "tricky" way of doing this? The code to do the inserts works by just reading the translation table that has two columns -- source column fieldname and target column (in the existing table) fieldnames (both real fieldnames, of course). Here's what I've got: <form action="index.php" method="post"> <input type="hidden" id="unique" name="unique" value="<?php echo $unique_nm; ?>" /> <input type="hidden" id="savetotable" name="savetotable" value="1" /> <?php foreach($LabelList as $c_name){ ?> <div> <div style="float: left; width: 300px;"; > <?php echo $c_name; ?> </div> <div style="float: left; width: 400px;"> <select id="<?php echo $c_name; ?>" name="<?php echo $c_name; ?>"> <option value=""></option> <?php foreach($SourceColumns as $h_name){ ?> <option value="<?php echo trim($h_name); ?>"> <?php echo trim($h_name); ?> </option> <?php } ?> </select> </div> <div style="clear: both;"></div> </div> <?php } ?> <input type="submit" value="Save to Database" /> </form> So, while I could load the data into the targetfile pretty easily using the real target table column names, how can I present the user with a drop-down menu of LABELS, but insert the data into the REAL target fields? Here's the list of ACTUAL fields: $output = array(); $gather = 'select FieldName from MapTable where User = UserID' $this->call($gather); foreach($this->data as $row){ $ActualFields[] = $row['COLUMN_NAME']; } return $ActualFields; } Here's the list of LABELS (phony field names): $output = array(); $gather = 'select LabelName from MapTable where User = UserID' $this->call($gather); foreach($this->data as $row){ $LabelList[] = $row['COLUMN_NAME']; } return $LabelList; } The list of fields from the sourcefile the user is loading are all actual, real names ($SourceColumns) I require a page to be added to my website. This page will facilitate a refined search via Google, Bing and Yahoo search engine simultaneously , show the top 5 of each engine. Is this possible using php ? Thank's What am I missing here? The array: protected $form_bonus = array( "Attacker" => array( "Ashwin" => array( "normal" => 1.15, "rps" => 1.38), "Cordelon" => array( "normal" => 1.15, "rps" => 1.38), "Mersan" => array( "normal" => 1.15, "rps" => 1.38), "Phlanixian" => array( "normal" => 1.195, "rps" => 1.494), "Slythe" => array( "normal" => 1.15, "rps" => 1.38) ), "Defender" => array( "Ashwin" => array( "normal" => 1.15, "rps" => 1.38), "Cordelon" => array( "normal" => 1.15, "rps" => 1.38), "Mersan" => array( "normal" => 1.15, "rps" => 1.38), "Phlanixian" => array( "normal" => 1.15, "rps" => 1.38), "Slythe" => array( "normal" => 1.15, "rps" => 1.38) ) ); accessing it: $bonus *= form_bonus[$this->role][$this->race]['rps']; error: PHP Parse error: syntax error, unexpected '[' Hello everybody, i am working on n level category tree structure, for your information the category tree structure image is attached with this post. Let's consider, each of the category have hundreds( n level ) of category in each, i want to traverse each category without using recursive functions, reason being recursive functions are very slow, is there any way to do this?? Thanks, phpeid Hello. Basically I have created a form that you fill in and an email gets sent to your in box and you have an access_level of 1. Within this email there is one field. A validation_id. Now what im trying to do is when you click this link it opens the webpage and updates your access_level to 2. I have wrote my query and array and i can see exactly which bit is wrong. Its where i have validation_id= $validation_id") Now its not working and I can see the error. Problem is im too new at this to understand why its wrong and how to fix it can anyone help? Here is the rest of the code. Also could you please explain? I would really like to understand it before i move any further. p.s. I have already selected my database in the included file <? include('database_name'); session_start(); $validation_id =$_GET['validation_id']; $FullRec__query=sprintf("SELECT * FROM Members WHERE validation_id= $validation_id"); $FullRec = mysql_query($FullRec__query, $database name) or die(mysql_error()); $FullRecArray = mysql_fetch_array($FullRec); $UdateAccessQuery = sprintf("UPDATE Members SET access_level = '2' WHERE validation_id = $validation_id"); mysql_query($UdateAccessQuery, $database_name) or die(mysql_error()); ?> In javascript you can do multiple methods on the same line like: if(document.getElementById('myElement').className.match(/^[0-9]/)){/*Do something*/} in that we have getElementById() and match() on the same line, and it works the same as if you were to split them on multiple lines. Is it possible to do that with php? For example: $obj = new MyObject(); $obj->add(2, 3)->to_string(); Hi all I have a menu function which basically produces a menu which looks like Code: [Select] Products Apple iMac iPod iPhone Microsoft Windows Office and the code I use is; THE FUNCTION function menu($parentID, $mymenu) { $html = ""; if (isset($mymenu['parentID'][$parentID])) { $html .= " <ul>\n"; foreach ($mymenu['parentID'][$parentID] as $menu_id) { if(!isset($mymenu['parentID'][$menu_id])) { $html .= "<li>\n <a href='/".$mymenu['menu_item'][$menu_id]['url']."'>".$mymenu['menu_item'][$menu_id]['value']."</a>\n</li>"; } if(isset($mymenu['parentID'][$menu_id])) { $html .= "<li>\n <a href='/".$mymenu['menu_item'][$menu_id]['url']."'>".$mymenu['menu_item'][$menu_id]['value']."</a>"; $html .= menu($menu_id, $mymenu); $html .= "</li>"; } } $html .= "</ul>"; } return $html; } CREATE MENU CODE $result = mysql_query("SELECT id, value, url, parentID FROM menu WHERE active = 1 AND deleted = 1 ORDER BY position ASC"); $mymenu = array('menu_item' => array(),'parentID' => array()); while ($menu_item = mysql_fetch_assoc($result)) { $mymenu['menu_item'][$menu_item['id']] = $menu_item; $mymenu['parentID'][$menu_item['parentID']][] = $menu_item['id']; } echo menu(0, $mymenu); The problem I have is the URLS, at the moment the menu URLS are outputted as Code: [Select] Products - http://localhost/Products Apple - http://localhost/Apple iMac - http://localhost/iMac iPod - http://localhost/iPod But I need to alter my function so that URLS are outputted as Code: [Select] Products - http://localhost/Products Apple - http://localhost/Products/Apple iMac - http://localhost/Products/Apple/iMac iPod - http://localhost/Products/Apple/iPod Is this at all possible? Thanks very much everyone John When I use ini_get to check my error_reporting level, I get a weird value ( 4983 ) that I can't find anywhere by googling. Also not on the list of possible levels here ( http://itech.hubpages.com/hub/php-error_reporting ) .. does anyone know how to determine what exactly this level is? Thanks! The way I understand posting a form to work is that when you hit submit the information is attached to the end of the url of the new page where your script can then get it and use it. I have a form that is an include on a page, like so: thepage.php include: theform.php When i fill out the form and hit submit.. the next page acts as if it has not received any of the posted information. example: echo $_POST['input1'] results in nothing If i go directly to theform.php and fill out and submit the form it works fine. example: echo $_POST['input1'] results in whatever was typed in the first box. So how can I get it to work while being included? Hi All, I have a function that creates an array using a few sql quereys. I then use the array to output to html. I am wanting to add more data to the array to populate another column in the created table. I am unsure how to add $miqty to the array and then output it in the Qty On Order column. I feel like i need to add the [] to $menuItemsInCat[$mcatname][$miid] = $miname; section but i am not sure where in there it should be.
<?php if (session_status() == PHP_SESSION_NONE) { session_start(); } if (!isset($_SESSION['user_id'])){ header("location: index.php"); exit; } //name of the pagea $_SESSION['this_page'] = 'new-menu'; function getMenuItems($conn){ $output = ''; $stmt = $conn -> query(" SELECT menu_category_name FROM ssm_menu_items INNER JOIN ssm_menu_category on menu_item_category_id = menu_category_id ORDER BY menu_category_display_order "); //create an empty array of all of the menu categories that are in use foreach ($stmt as $item){ $menuItemsInCat[$item['menu_category_name']] = []; } $stmt = $conn -> prepare(" SELECT menu_item_id, menu_item_name, menu_category_name, sum(menu_item_qty) FROM ssm_menu_items mi INNER JOIN ssm_menu_category mcat ON mi.menu_item_category_id = mcat.menu_category_id left join ssm_menu_order USING (menu_item_id) GROUP BY menu_item_id "); $stmt -> execute(); $stmt -> bind_result($miid, $miname, $mcatname, $miqty); while ($row = $stmt -> fetch()) { //put items into the blank array created above under their correct category $menuItemsInCat[$mcatname][$miid] = $miname; } echo "<pre>"; print_r($menuItemsInCat); echo "</pre>"; //foreach thing in $menuItemInCat array there is $menucat array associated with $menuit(ems) array //we want the menu cat foreach ($menuItemsInCat as $menucat => $menuit) { $output .= "<tbody>"; $output .= "<tr class='bg-secondary text-white text-center'><th>$menucat</th>"; $output .= "<th>Qty On Order</th><th>Manage</th></tr>"; //foreach thing in menu items array there is an array of ids and an array of items foreach ($menuit as $itemId => $itemName) { $output .= "<tr><td>$itemName</td>"; $output .= "<td></td>"; $output .= "<td><div class='btn btn-primary'>Manage</div></td></tr>"; } $output .= "</tbody>"; } return $output; } ?> <?php include '_includes/head.php'; ?> <div class="container-fluid"> <div class="row"> <?php include '_includes/header.php'; ?> </div> <div class="row" > <div class="col-sm-2 p-0 bg-dark text-light"> <?php include '_includes/nav.php'; ?> </div> <div class="col-sm-10" style="height: calc(100vh - 80px);overflow:scroll;"> <div class="mt-3"> <table class="table table-striped table-hover table-bordered text-center align-middle"> <?= getMenuItems($conn) ?> </table> </div> <div class="col-sm-12"><?php include '_includes/footer.php'; ?></div> </div> </div> </div> <script> //set sidebar active indicator //XX = name of parent if in dropdown eg "sheet" if(document.getElementById('menu')){ document.getElementById('menu').classList.add('show') } //nav button ID if(document.getElementById('newMenu')){ document.getElementById('newMenu').classList.add('blOrange') } </script> As always your help is very appreciated. Edited February 5, 2020 by AdamhumbugHi, I would like to make a login page with 2 different user level, Admin & Staff. How can i do it using d code below. Thank u. <?php $host="localhost"; $username="root"; $password=""; $db_name="profile"; $tbl_name="company"; mysql_connect("$host", "$username", "$password")or die("cannot connect"); mysql_select_db("$db_name")or die("Cannot Select Database"); // username and password sent from form $myusername=$_POST['myusername']; $mypassword=$_POST['mypassword']; $myusername = stripslashes($myusername); $mypassword = stripslashes($mypassword); $myusername = mysql_real_escape_string($myusername); $mypassword = mysql_real_escape_string($mypassword); $sql="SELECT * FROM $tbl_name WHERE username='$myusername' and password='$mypassword'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); if($count==1){ session_register("myusername"); session_register("mypassword"); header("location:login_success.php"); } else { echo "Wrong Username or Password"; } ?> i need to know how i can check a users level in my login.php page it works i have
$sql = "SELECT * FROM $tbl_name WHERE username = '$username' AND password='$password'"; $result = mysql_query($sql); $count = mysql_num_rows($result); $row = mysql_fetch_assoc($result); $user_level = $row['user_level']; if($count == 1) { $_SESSION['loggedIn'] = true; session_write_close(); header("Location: index.php"); } else { echo "The username or password you entered is incorrect!"; } if($row['user_level'] == 1) { header("Location: admin.php"); } else if($row['user_level'] == -1) { header("Location: banned.php"); }but i need to know how to check it in another file because it is not working i am trying to add it to admin.php to check the users level & if they are not admin then echo you are not admin. <-- it says that although the user is an administrator it is saying they are not. This is what i have in admin.php <?php require 'connect.php'; session_start(); $sql = "SELECT * FROM $tbl_name WHERE username = '$username' AND password='$password'"; $result = mysql_query($sql); $row = mysql_fetch_assoc($result); $user_level = $row['user_level']; if(!isset($_SESSION['loggedIn'])) { echo "You are not currently logged in and to view this page you must be logged in to have access. <a href='login.php'> You can login here </a>"; die(); } if($row['user_level'] == 1) { //DO NOTHING } else { echo "Your not an administrator so you are denied access to this page."; die(); } ?> Edited by Tom8001, 24 November 2014 - 03:02 PM. i try to create login page with two different user level for example admin and staff. i did not get any error on my code but it just did not direct to the page it been set to. it just display wrong username or password. i not really sure what is wrong. here is the code loginForm.php Code: [Select] <form action="login.php" method ="post"> <table> <tr><td>Usernama</td> <td><input name="username" type="text" size = "15" maxlength = "15"/></td></tr> <tr><td>Password</td> <td><input name="password" type="password" size = "15" maxlength = "15"/></td></tr> </table> <br><input name="submit" type ="submit" value ="Login"/></td> </form> login.php Code: [Select] <?php ob_start(); $host="localhost"; $user="root"; $pass=""; $db_name="office"; $tbl_name="login"; mysql_connect("$host", "$user", "$pass")or die("cannot connect"); mysql_select_db("$db_name")or die("Cannot Select Database"); // username and password sent from form $sername=$_POST['username']; $password=$_POST['password']; $username = stripslashes($username); $password = stripslashes($password); $username = mysql_real_escape_string($username); $password = mysql_real_escape_string($password); $sql="SELECT * FROM daftarPenyelia WHERE user='$username' AND pass='$password' AND userLevel='$userLevel'"; $result=mysql_query($sql); // Mysql_num_row is counting table row $count=mysql_num_rows($result); if ($count == $userLevel) { if ($userLevel == 1) { $_SESSION['username'] = $username; $_SESSION['password'] = $password; header("location:adminMenu.php"); } else if ($userLevel == 2) { $_SESSION['username'] = $username; $_SESSION['password'] = $password; header("location:staffMenu.php"); } } else { echo "Wrong Username or Password"; } ?> can someone help me with this code and tell me what is wrong so that i can fix them Hello, Does anyone know a tutorial I can follow to create my own search engine over the items I have in my SQL database? I find a lot of tutorials but they are all 'one word searches' which means if you type two words you will get all results that contain either word (too many hits). If the search engine tutorial displays result with AJAX even better. Thanks for help. df I want to have a multi level dropdown selection tool come out of an array (not database; almost all of available codes on the internet are based on mysql databse). I have an array as each element has this format: "Country | City | ID". Using explode, I want to make a dropdown to choose the country, then choosing the cities of the chosen country. Finally, in a simple search box make action="result.php" to lead to result.php?q=$id Thanks for your kind attention Hi everyone, am developing an application that has two views 1 for administrator and 1 for staff. Administrator can perform all application tasks and Staff can ONLY perform certain task. I have implemented sessions quite alright and are working. Now the problem is that when I login as Staff and then I change the URL to point to an administrator's page the application is allowing that, How can I prevent that from happening. Staff MUST NOT see administrators pages. Here is my login code, logout code and code am using to protect webpages below. Here is my login code <?php //start the session session_start(); $username=$_POST['username']; $password=$_POST['password']; $encrypted=md5($password); // set connection to database $hostname="localhost"; // Host name $mysql_server_username="root"; // Mysql username $server_password=""; // Mysql password $db_name="db_inventory"; // Database name $table = "tbl_users"; // Table name // Connect to server and select database. mysql_connect("$hostname", "$mysql_server_username", "$server_password")or die("cannot connect to database server"); mysql_select_db("$db_name") or die ("Couldn't select the database."); $admin=("select * from $table where username='$username' AND password='$encrypted' AND type = 'admin'"); $staff=("select * from $table where username='$username' AND password='$encrypted' AND type = 'staff'"); //check that at least one row was returned $adminresult=mysql_query($admin); $admincount = mysql_num_rows($adminresult); $staffresult=mysql_query($staff); $staffcount = mysql_num_rows($staffresult); if($admincount> 0){ $_SESSION['valid_user'] = $username ; header( "Location: main_menu.php" ); } else if($staffcount> 0){ $_SESSION['valid_user'] = $username ; header( "Location: staff/main_menu.php" ); } else { ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>title> | Login</title> </head> <body bgcolor="#FFFFFF" background-repeat:no-repeat; background="images/images1.jpg"> <div align="center"> <table width="800" height="501" border="0" cellpadding="1" cellspacing="1"> <tr> <td height="100"> </td> </tr> <tr> <td height="350"> <div align="center"> <form method="post" action="login_process.php"> <h4 align="center"><font color="red">Incorrect Username / Password ! Please Try Again</font></h4> <img name="" src=images/padlock_closed.gif width="34" height="32" alt="" /><br /><br /> <table width="314" border="0" cellspacing="1" cellpadding="1"> <tr> <td>Username:</td> <td><label> <input type="text" name="username" /> </label></td> </tr> <tr> <td>Password:</td> <td><label> <input type="password" name="password" /> </label></td> </tr> <tr> <td colspan="2"> <p> <input type="submit" name ="submit" value="Login" /> <input type="reset" value="Reset" /> </p> </td> </tr> </table> </form> </div> </td> </tr> <tr> <td height="100"> </td> </tr> </table> </div> </body> </html> <?php } ?> Here is my logout code <?php //start the session session_start(); //check to make sure the session variable is registered if(isset($_SESSION['valid_user'])){ //session variable is registered, the user is ready to logout session_unset(); session_destroy(); //the session variable isn't registered, the user shouldn't even be on this page header( "Location: index.php" ); } else { //check to see if the session variable is not registered if(!isset($_SESSION['valid_user'])){ //redirect to login page header( "Location: index.php" ); } } ?> Here is code I am using to protect pages <?php //start the session session_start(); //check to make sure the session variable is registered if(!isset($_SESSION['valid_user'])){ //redirect to login page header( "Location: index.php" ); } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title> | Main Menu</title> <link rel="stylesheet" type="text/css" href="css.css" /> </head> <body> <div id="tabsF"> <ul> <!-- CSS Tabs --> <li id="current"><a href="main_menu.php"><span>MAIN MENU</span></a></li> <li><a href="stockmaster.php"><span>STOCK MASTER</span></a></li> <li><a href="controlpanel.php"><span>CONTROL PANEL</span></a></li> <li><a href="logout.php"><span>LOGOUT</span></a></li> </ul> </div> </body> </html> Thank you. $form_bonus = array( "Attacker" => array( "Ashwin" => array( "normal" => 1.15, "rps" => 1.38), "Cordelon" => array( "normal" => 1.15, "rps" => 1.38), "Mersan" => array( "normal" => 1.15, "rps" => 1.38), "Phlanixian" => array( "normal" => 1.195, "rps" => 1.494), "Slythe" => array( "normal" => 1.15, "rps" => 1.38) ), "Defender" => array( "Ashwin" => array( "normal" => 1.15, "rps" => 1.38), "Cordelon" => array( "normal" => 1.15, "rps" => 1.38), "Mersan" => array( "normal" => 1.15, "rps" => 1.38), "Phlanixian" => array( "normal" => 1.15, "rps" => 1.38), "Slythe" => array( "normal" => 1.15, "rps" => 1.38) ) ); echo "<pre>".print_r($form_bonus)."</pre>"; output: 1 what am i missing here? Code: [Select] $sqlCommand = "CREATE TABLE products ( id int(11) NOT NULL auto_increment, product_name varchar(255) NOT NULL, price varchar(16) NOT NULL, details text NOT NULL, category varchar(16) NOT NULL, subcategory varchar(16) NOT NULL, m_tag text NOT NULL, date_added date NOT NULL, PRIMARY KEY (id), UNIQUE KEY product_name (product_name) ) ";. this is currently my database, i would like to create a stock level count so im assuming i need a new field called (stock) also on my homepage i would like a list of best selling items so im probably going to need a (total sold) my website has a basket, when you click check out it goes to paypal so you can pay for your transaction. i have a ipn script to verify with payal. but i dont have a clue how to update my stock level after each transaction. can someone please help and point me in the right direction I want to create an array from a file with this structure TITLE1, HEADER1, key11, key12, key13, key14 TITLE2, HEADER2, key21, key22, key23, key24 . . . How I can get a foreach with these elements: $title="TITLE" $header="HEADER" $key="(one random key)" If needed, I can change the file structure too. |